diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 24 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Command/GenerateUrlHashesCommandTest.php | 5 |
2 files changed, 13 insertions, 16 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index fc4dc9d9..34de8ec8 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -973,7 +973,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
973 | 973 | ||
974 | public function dataForEntriesExistWithUrl() | 974 | public function dataForEntriesExistWithUrl() |
975 | { | 975 | { |
976 | $url = hash('md5', 'http://0.0.0.0/entry2'); | 976 | $url = hash('sha1', 'http://0.0.0.0/entry2'); |
977 | 977 | ||
978 | return [ | 978 | return [ |
979 | 'with_id' => [ | 979 | 'with_id' => [ |
@@ -1047,37 +1047,37 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
1047 | { | 1047 | { |
1048 | $url1 = 'http://0.0.0.0/entry2'; | 1048 | $url1 = 'http://0.0.0.0/entry2'; |
1049 | $url2 = 'http://0.0.0.0/entry10'; | 1049 | $url2 = 'http://0.0.0.0/entry10'; |
1050 | $this->client->request('GET', '/api/entries/exists?hashed_urls[]=' . hash('md5', $url1) . '&hashed_urls[]=' . hash('md5', $url2) . '&return_id=1'); | 1050 | $this->client->request('GET', '/api/entries/exists?hashed_urls[]=' . hash('sha1', $url1) . '&hashed_urls[]=' . hash('sha1', $url2) . '&return_id=1'); |
1051 | 1051 | ||
1052 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | 1052 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); |
1053 | 1053 | ||
1054 | $content = json_decode($this->client->getResponse()->getContent(), true); | 1054 | $content = json_decode($this->client->getResponse()->getContent(), true); |
1055 | 1055 | ||
1056 | $this->assertArrayHasKey(hash('md5', $url1), $content); | 1056 | $this->assertArrayHasKey(hash('sha1', $url1), $content); |
1057 | $this->assertArrayHasKey(hash('md5', $url2), $content); | 1057 | $this->assertArrayHasKey(hash('sha1', $url2), $content); |
1058 | $this->assertSame(2, $content[hash('md5', $url1)]); | 1058 | $this->assertSame(2, $content[hash('sha1', $url1)]); |
1059 | $this->assertNull($content[hash('md5', $url2)]); | 1059 | $this->assertNull($content[hash('sha1', $url2)]); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | public function testGetEntriesExistsWithManyUrlsHashedReturnBool() | 1062 | public function testGetEntriesExistsWithManyUrlsHashedReturnBool() |
1063 | { | 1063 | { |
1064 | $url1 = 'http://0.0.0.0/entry2'; | 1064 | $url1 = 'http://0.0.0.0/entry2'; |
1065 | $url2 = 'http://0.0.0.0/entry10'; | 1065 | $url2 = 'http://0.0.0.0/entry10'; |
1066 | $this->client->request('GET', '/api/entries/exists?hashed_urls[]=' . hash('md5', $url1) . '&hashed_urls[]=' . hash('md5', $url2)); | 1066 | $this->client->request('GET', '/api/entries/exists?hashed_urls[]=' . hash('sha1', $url1) . '&hashed_urls[]=' . hash('sha1', $url2)); |
1067 | 1067 | ||
1068 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | 1068 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); |
1069 | 1069 | ||
1070 | $content = json_decode($this->client->getResponse()->getContent(), true); | 1070 | $content = json_decode($this->client->getResponse()->getContent(), true); |
1071 | 1071 | ||
1072 | $this->assertArrayHasKey(hash('md5', $url1), $content); | 1072 | $this->assertArrayHasKey(hash('sha1', $url1), $content); |
1073 | $this->assertArrayHasKey(hash('md5', $url2), $content); | 1073 | $this->assertArrayHasKey(hash('sha1', $url2), $content); |
1074 | $this->assertTrue($content[hash('md5', $url1)]); | 1074 | $this->assertTrue($content[hash('sha1', $url1)]); |
1075 | $this->assertFalse($content[hash('md5', $url2)]); | 1075 | $this->assertFalse($content[hash('sha1', $url2)]); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | public function testGetEntriesExistsWhichDoesNotExists() | 1078 | public function testGetEntriesExistsWhichDoesNotExists() |
1079 | { | 1079 | { |
1080 | $this->client->request('GET', '/api/entries/exists?hashed_url=' . hash('md5', 'http://google.com/entry2')); | 1080 | $this->client->request('GET', '/api/entries/exists?hashed_url=' . hash('sha1', 'http://google.com/entry2')); |
1081 | 1081 | ||
1082 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | 1082 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); |
1083 | 1083 | ||
diff --git a/tests/Wallabag/CoreBundle/Command/GenerateUrlHashesCommandTest.php b/tests/Wallabag/CoreBundle/Command/GenerateUrlHashesCommandTest.php index cc1e3fbc..17eed210 100644 --- a/tests/Wallabag/CoreBundle/Command/GenerateUrlHashesCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/GenerateUrlHashesCommandTest.php | |||
@@ -72,11 +72,8 @@ class GenerateUrlHashesCommandTest extends WallabagCoreTestCase | |||
72 | $entry1->setUrl($url); | 72 | $entry1->setUrl($url); |
73 | 73 | ||
74 | $em->persist($entry1); | 74 | $em->persist($entry1); |
75 | |||
76 | $em->flush(); | 75 | $em->flush(); |
77 | 76 | ||
78 | $this->assertNull($entry1->getHashedUrl()); | ||
79 | |||
80 | $application = new Application($this->getClient()->getKernel()); | 77 | $application = new Application($this->getClient()->getKernel()); |
81 | $application->add(new GenerateUrlHashesCommand()); | 78 | $application->add(new GenerateUrlHashesCommand()); |
82 | 79 | ||
@@ -92,7 +89,7 @@ class GenerateUrlHashesCommandTest extends WallabagCoreTestCase | |||
92 | 89 | ||
93 | $entry = $em->getRepository('WallabagCoreBundle:Entry')->findOneByUrl($url); | 90 | $entry = $em->getRepository('WallabagCoreBundle:Entry')->findOneByUrl($url); |
94 | 91 | ||
95 | $this->assertSame($entry->getHashedUrl(), hash('md5', $url)); | 92 | $this->assertSame($entry->getHashedUrl(), hash('sha1', $url)); |
96 | 93 | ||
97 | $query = $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.url = :url'); | 94 | $query = $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.url = :url'); |
98 | $query->setParameter('url', $url); | 95 | $query->setParameter('url', $url); |