diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-21 16:37:25 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-01-21 16:37:25 +0100 |
commit | a0d6ccc5ca0dc0082467cc65b006150aff2488c4 (patch) | |
tree | a5f405e032a2eb8268427ad8c6106cb7d6ffe4dd /src | |
parent | e56983af1f7b74993784687e7b192a898422fe7f (diff) | |
download | wallabag-a0d6ccc5ca0dc0082467cc65b006150aff2488c4.tar.gz wallabag-a0d6ccc5ca0dc0082467cc65b006150aff2488c4.tar.zst wallabag-a0d6ccc5ca0dc0082467cc65b006150aff2488c4.zip |
Fix bad type after using findByUrlAndUserId
It returns an object since few commits this part of (untested) code still use an array.
Also add test for that part of code.
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 4 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 31 |
2 files changed, 30 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 9dd904f1..3e1b512f 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -54,10 +54,10 @@ class EntryController extends Controller | |||
54 | if (false !== $existingEntry) { | 54 | if (false !== $existingEntry) { |
55 | $this->get('session')->getFlashBag()->add( | 55 | $this->get('session')->getFlashBag()->add( |
56 | 'notice', | 56 | 'notice', |
57 | 'Entry already saved on '.$existingEntry['createdAt']->format('d-m-Y') | 57 | 'Entry already saved on '.$existingEntry->getCreatedAt()->format('d-m-Y') |
58 | ); | 58 | ); |
59 | 59 | ||
60 | return $this->redirect($this->generateUrl('view', array('id' => $existingEntry['id']))); | 60 | return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId()))); |
61 | } | 61 | } |
62 | 62 | ||
63 | $this->updateEntry($entry); | 63 | $this->updateEntry($entry); |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 1d1620dc..32d6a575 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -127,10 +127,35 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
127 | 127 | ||
128 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 128 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
129 | 129 | ||
130 | $crawler = $client->followRedirect(); | 130 | $content = $client->getContainer() |
131 | ->get('doctrine.orm.entity_manager') | ||
132 | ->getRepository('WallabagCoreBundle:Entry') | ||
133 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
134 | |||
135 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | ||
136 | $this->assertEquals($this->url, $content->getUrl()); | ||
137 | $this->assertContains('Google', $content->getTitle()); | ||
138 | } | ||
139 | |||
140 | public function testPostNewOkUrlExist() | ||
141 | { | ||
142 | $this->logInAs('admin'); | ||
143 | $client = $this->getClient(); | ||
144 | |||
145 | $crawler = $client->request('GET', '/new'); | ||
146 | |||
147 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
148 | |||
149 | $form = $crawler->filter('button[type=submit]')->form(); | ||
150 | |||
151 | $data = array( | ||
152 | 'entry[url]' => $this->url, | ||
153 | ); | ||
131 | 154 | ||
132 | $this->assertGreaterThan(1, $alert = $crawler->filter('h2 a')->extract(array('_text'))); | 155 | $client->submit($form, $data); |
133 | $this->assertContains('Google', $alert[0]); | 156 | |
157 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
158 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); | ||
134 | } | 159 | } |
135 | 160 | ||
136 | /** | 161 | /** |