diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle/Helper')
6 files changed, 123 insertions, 123 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index dbddbc5c..7e19631b 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -2,18 +2,18 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | 3 | namespace Tests\Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Psr\Log\NullLogger; | 5 | use Graby\Graby; |
6 | use Monolog\Logger; | ||
7 | use Monolog\Handler\TestHandler; | 6 | use Monolog\Handler\TestHandler; |
8 | use Wallabag\CoreBundle\Helper\ContentProxy; | 7 | use Monolog\Logger; |
8 | use Psr\Log\NullLogger; | ||
9 | use Symfony\Component\Validator\ConstraintViolation; | ||
10 | use Symfony\Component\Validator\ConstraintViolationList; | ||
11 | use Symfony\Component\Validator\Validator\RecursiveValidator; | ||
9 | use Wallabag\CoreBundle\Entity\Entry; | 12 | use Wallabag\CoreBundle\Entity\Entry; |
10 | use Wallabag\CoreBundle\Entity\Tag; | 13 | use Wallabag\CoreBundle\Entity\Tag; |
11 | use Wallabag\UserBundle\Entity\User; | 14 | use Wallabag\CoreBundle\Helper\ContentProxy; |
12 | use Wallabag\CoreBundle\Helper\RuleBasedTagger; | 15 | use Wallabag\CoreBundle\Helper\RuleBasedTagger; |
13 | use Graby\Graby; | 16 | use Wallabag\UserBundle\Entity\User; |
14 | use Symfony\Component\Validator\Validator\RecursiveValidator; | ||
15 | use Symfony\Component\Validator\ConstraintViolationList; | ||
16 | use Symfony\Component\Validator\ConstraintViolation; | ||
17 | 17 | ||
18 | class ContentProxyTest extends \PHPUnit_Framework_TestCase | 18 | class ContentProxyTest extends \PHPUnit_Framework_TestCase |
19 | { | 19 | { |
@@ -44,14 +44,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
44 | $entry = new Entry(new User()); | 44 | $entry = new Entry(new User()); |
45 | $proxy->updateEntry($entry, 'http://user@:80'); | 45 | $proxy->updateEntry($entry, 'http://user@:80'); |
46 | 46 | ||
47 | $this->assertEquals('http://user@:80', $entry->getUrl()); | 47 | $this->assertSame('http://user@:80', $entry->getUrl()); |
48 | $this->assertEmpty($entry->getTitle()); | 48 | $this->assertEmpty($entry->getTitle()); |
49 | $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); | 49 | $this->assertSame($this->fetchingErrorMessage, $entry->getContent()); |
50 | $this->assertEmpty($entry->getPreviewPicture()); | 50 | $this->assertEmpty($entry->getPreviewPicture()); |
51 | $this->assertEmpty($entry->getMimetype()); | 51 | $this->assertEmpty($entry->getMimetype()); |
52 | $this->assertEmpty($entry->getLanguage()); | 52 | $this->assertEmpty($entry->getLanguage()); |
53 | $this->assertEquals(0.0, $entry->getReadingTime()); | 53 | $this->assertSame(0.0, $entry->getReadingTime()); |
54 | $this->assertEquals(false, $entry->getDomainName()); | 54 | $this->assertSame(false, $entry->getDomainName()); |
55 | } | 55 | } |
56 | 56 | ||
57 | public function testWithEmptyContent() | 57 | public function testWithEmptyContent() |
@@ -79,14 +79,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
79 | $entry = new Entry(new User()); | 79 | $entry = new Entry(new User()); |
80 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | 80 | $proxy->updateEntry($entry, 'http://0.0.0.0'); |
81 | 81 | ||
82 | $this->assertEquals('http://0.0.0.0', $entry->getUrl()); | 82 | $this->assertSame('http://0.0.0.0', $entry->getUrl()); |
83 | $this->assertEmpty($entry->getTitle()); | 83 | $this->assertEmpty($entry->getTitle()); |
84 | $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); | 84 | $this->assertSame($this->fetchingErrorMessage, $entry->getContent()); |
85 | $this->assertEmpty($entry->getPreviewPicture()); | 85 | $this->assertEmpty($entry->getPreviewPicture()); |
86 | $this->assertEmpty($entry->getMimetype()); | 86 | $this->assertEmpty($entry->getMimetype()); |
87 | $this->assertEmpty($entry->getLanguage()); | 87 | $this->assertEmpty($entry->getLanguage()); |
88 | $this->assertEquals(0.0, $entry->getReadingTime()); | 88 | $this->assertSame(0.0, $entry->getReadingTime()); |
89 | $this->assertEquals('0.0.0.0', $entry->getDomainName()); | 89 | $this->assertSame('0.0.0.0', $entry->getDomainName()); |
90 | } | 90 | } |
91 | 91 | ||
92 | public function testWithEmptyContentButOG() | 92 | public function testWithEmptyContentButOG() |
@@ -119,15 +119,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
119 | $entry = new Entry(new User()); | 119 | $entry = new Entry(new User()); |
120 | $proxy->updateEntry($entry, 'http://domain.io'); | 120 | $proxy->updateEntry($entry, 'http://domain.io'); |
121 | 121 | ||
122 | $this->assertEquals('http://domain.io', $entry->getUrl()); | 122 | $this->assertSame('http://domain.io', $entry->getUrl()); |
123 | $this->assertEquals('my title', $entry->getTitle()); | 123 | $this->assertSame('my title', $entry->getTitle()); |
124 | $this->assertEquals($this->fetchingErrorMessage.'<p><i>But we found a short description: </i></p>desc', $entry->getContent()); | 124 | $this->assertSame($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent()); |
125 | $this->assertEmpty($entry->getPreviewPicture()); | 125 | $this->assertEmpty($entry->getPreviewPicture()); |
126 | $this->assertEmpty($entry->getLanguage()); | 126 | $this->assertEmpty($entry->getLanguage()); |
127 | $this->assertEmpty($entry->getHttpStatus()); | 127 | $this->assertEmpty($entry->getHttpStatus()); |
128 | $this->assertEmpty($entry->getMimetype()); | 128 | $this->assertEmpty($entry->getMimetype()); |
129 | $this->assertEquals(0.0, $entry->getReadingTime()); | 129 | $this->assertSame(0.0, $entry->getReadingTime()); |
130 | $this->assertEquals('domain.io', $entry->getDomainName()); | 130 | $this->assertSame('domain.io', $entry->getDomainName()); |
131 | } | 131 | } |
132 | 132 | ||
133 | public function testWithContent() | 133 | public function testWithContent() |
@@ -161,15 +161,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
161 | $entry = new Entry(new User()); | 161 | $entry = new Entry(new User()); |
162 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | 162 | $proxy->updateEntry($entry, 'http://0.0.0.0'); |
163 | 163 | ||
164 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 164 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
165 | $this->assertEquals('this is my title', $entry->getTitle()); | 165 | $this->assertSame('this is my title', $entry->getTitle()); |
166 | $this->assertContains('this is my content', $entry->getContent()); | 166 | $this->assertContains('this is my content', $entry->getContent()); |
167 | $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); | 167 | $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); |
168 | $this->assertEquals('text/html', $entry->getMimetype()); | 168 | $this->assertSame('text/html', $entry->getMimetype()); |
169 | $this->assertEquals('fr', $entry->getLanguage()); | 169 | $this->assertSame('fr', $entry->getLanguage()); |
170 | $this->assertEquals('200', $entry->getHttpStatus()); | 170 | $this->assertSame('200', $entry->getHttpStatus()); |
171 | $this->assertEquals(4.0, $entry->getReadingTime()); | 171 | $this->assertSame(4.0, $entry->getReadingTime()); |
172 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 172 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
173 | } | 173 | } |
174 | 174 | ||
175 | public function testWithContentAndNoOgImage() | 175 | public function testWithContentAndNoOgImage() |
@@ -203,15 +203,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
203 | $entry = new Entry(new User()); | 203 | $entry = new Entry(new User()); |
204 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | 204 | $proxy->updateEntry($entry, 'http://0.0.0.0'); |
205 | 205 | ||
206 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 206 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
207 | $this->assertEquals('this is my title', $entry->getTitle()); | 207 | $this->assertSame('this is my title', $entry->getTitle()); |
208 | $this->assertContains('this is my content', $entry->getContent()); | 208 | $this->assertContains('this is my content', $entry->getContent()); |
209 | $this->assertNull($entry->getPreviewPicture()); | 209 | $this->assertNull($entry->getPreviewPicture()); |
210 | $this->assertEquals('text/html', $entry->getMimetype()); | 210 | $this->assertSame('text/html', $entry->getMimetype()); |
211 | $this->assertEquals('fr', $entry->getLanguage()); | 211 | $this->assertSame('fr', $entry->getLanguage()); |
212 | $this->assertEquals('200', $entry->getHttpStatus()); | 212 | $this->assertSame('200', $entry->getHttpStatus()); |
213 | $this->assertEquals(4.0, $entry->getReadingTime()); | 213 | $this->assertSame(4.0, $entry->getReadingTime()); |
214 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 214 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
215 | } | 215 | } |
216 | 216 | ||
217 | public function testWithContentAndBadLanguage() | 217 | public function testWithContentAndBadLanguage() |
@@ -248,14 +248,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
248 | $entry = new Entry(new User()); | 248 | $entry = new Entry(new User()); |
249 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | 249 | $proxy->updateEntry($entry, 'http://0.0.0.0'); |
250 | 250 | ||
251 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 251 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
252 | $this->assertEquals('this is my title', $entry->getTitle()); | 252 | $this->assertSame('this is my title', $entry->getTitle()); |
253 | $this->assertContains('this is my content', $entry->getContent()); | 253 | $this->assertContains('this is my content', $entry->getContent()); |
254 | $this->assertEquals('text/html', $entry->getMimetype()); | 254 | $this->assertSame('text/html', $entry->getMimetype()); |
255 | $this->assertNull($entry->getLanguage()); | 255 | $this->assertNull($entry->getLanguage()); |
256 | $this->assertEquals('200', $entry->getHttpStatus()); | 256 | $this->assertSame('200', $entry->getHttpStatus()); |
257 | $this->assertEquals(4.0, $entry->getReadingTime()); | 257 | $this->assertSame(4.0, $entry->getReadingTime()); |
258 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 258 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
259 | } | 259 | } |
260 | 260 | ||
261 | public function testWithContentAndBadOgImage() | 261 | public function testWithContentAndBadOgImage() |
@@ -297,15 +297,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
297 | $entry = new Entry(new User()); | 297 | $entry = new Entry(new User()); |
298 | $proxy->updateEntry($entry, 'http://0.0.0.0'); | 298 | $proxy->updateEntry($entry, 'http://0.0.0.0'); |
299 | 299 | ||
300 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 300 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
301 | $this->assertEquals('this is my title', $entry->getTitle()); | 301 | $this->assertSame('this is my title', $entry->getTitle()); |
302 | $this->assertContains('this is my content', $entry->getContent()); | 302 | $this->assertContains('this is my content', $entry->getContent()); |
303 | $this->assertNull($entry->getPreviewPicture()); | 303 | $this->assertNull($entry->getPreviewPicture()); |
304 | $this->assertEquals('text/html', $entry->getMimetype()); | 304 | $this->assertSame('text/html', $entry->getMimetype()); |
305 | $this->assertEquals('fr', $entry->getLanguage()); | 305 | $this->assertSame('fr', $entry->getLanguage()); |
306 | $this->assertEquals('200', $entry->getHttpStatus()); | 306 | $this->assertSame('200', $entry->getHttpStatus()); |
307 | $this->assertEquals(4.0, $entry->getReadingTime()); | 307 | $this->assertSame(4.0, $entry->getReadingTime()); |
308 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 308 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
309 | } | 309 | } |
310 | 310 | ||
311 | public function testWithForcedContent() | 311 | public function testWithForcedContent() |
@@ -333,14 +333,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
333 | ] | 333 | ] |
334 | ); | 334 | ); |
335 | 335 | ||
336 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 336 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
337 | $this->assertEquals('this is my title', $entry->getTitle()); | 337 | $this->assertSame('this is my title', $entry->getTitle()); |
338 | $this->assertContains('this is my content', $entry->getContent()); | 338 | $this->assertContains('this is my content', $entry->getContent()); |
339 | $this->assertEquals('text/html', $entry->getMimetype()); | 339 | $this->assertSame('text/html', $entry->getMimetype()); |
340 | $this->assertEquals('fr', $entry->getLanguage()); | 340 | $this->assertSame('fr', $entry->getLanguage()); |
341 | $this->assertEquals(4.0, $entry->getReadingTime()); | 341 | $this->assertSame(4.0, $entry->getReadingTime()); |
342 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 342 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
343 | $this->assertEquals('24/03/2014', $entry->getPublishedAt()->format('d/m/Y')); | 343 | $this->assertSame('24/03/2014', $entry->getPublishedAt()->format('d/m/Y')); |
344 | $this->assertContains('Jeremy', $entry->getPublishedBy()); | 344 | $this->assertContains('Jeremy', $entry->getPublishedBy()); |
345 | $this->assertContains('Nico', $entry->getPublishedBy()); | 345 | $this->assertContains('Nico', $entry->getPublishedBy()); |
346 | $this->assertContains('Thomas', $entry->getPublishedBy()); | 346 | $this->assertContains('Thomas', $entry->getPublishedBy()); |
@@ -371,14 +371,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
371 | ] | 371 | ] |
372 | ); | 372 | ); |
373 | 373 | ||
374 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 374 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
375 | $this->assertEquals('this is my title', $entry->getTitle()); | 375 | $this->assertSame('this is my title', $entry->getTitle()); |
376 | $this->assertContains('this is my content', $entry->getContent()); | 376 | $this->assertContains('this is my content', $entry->getContent()); |
377 | $this->assertEquals('text/html', $entry->getMimetype()); | 377 | $this->assertSame('text/html', $entry->getMimetype()); |
378 | $this->assertEquals('fr', $entry->getLanguage()); | 378 | $this->assertSame('fr', $entry->getLanguage()); |
379 | $this->assertEquals(4.0, $entry->getReadingTime()); | 379 | $this->assertSame(4.0, $entry->getReadingTime()); |
380 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 380 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
381 | $this->assertEquals('08/09/2016', $entry->getPublishedAt()->format('d/m/Y')); | 381 | $this->assertSame('08/09/2016', $entry->getPublishedAt()->format('d/m/Y')); |
382 | } | 382 | } |
383 | 383 | ||
384 | public function testWithForcedContentAndBadDate() | 384 | public function testWithForcedContentAndBadDate() |
@@ -406,13 +406,13 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
406 | ] | 406 | ] |
407 | ); | 407 | ); |
408 | 408 | ||
409 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 409 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
410 | $this->assertEquals('this is my title', $entry->getTitle()); | 410 | $this->assertSame('this is my title', $entry->getTitle()); |
411 | $this->assertContains('this is my content', $entry->getContent()); | 411 | $this->assertContains('this is my content', $entry->getContent()); |
412 | $this->assertEquals('text/html', $entry->getMimetype()); | 412 | $this->assertSame('text/html', $entry->getMimetype()); |
413 | $this->assertEquals('fr', $entry->getLanguage()); | 413 | $this->assertSame('fr', $entry->getLanguage()); |
414 | $this->assertEquals(4.0, $entry->getReadingTime()); | 414 | $this->assertSame(4.0, $entry->getReadingTime()); |
415 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 415 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
416 | $this->assertNull($entry->getPublishedAt()); | 416 | $this->assertNull($entry->getPublishedAt()); |
417 | 417 | ||
418 | $records = $handler->getRecords(); | 418 | $records = $handler->getRecords(); |
@@ -488,14 +488,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
488 | ] | 488 | ] |
489 | ); | 489 | ); |
490 | 490 | ||
491 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 491 | $this->assertSame('http://1.1.1.1', $entry->getUrl()); |
492 | $this->assertEquals('this is my title', $entry->getTitle()); | 492 | $this->assertSame('this is my title', $entry->getTitle()); |
493 | $this->assertNotContains($escapedString, $entry->getContent()); | 493 | $this->assertNotContains($escapedString, $entry->getContent()); |
494 | $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); | 494 | $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); |
495 | $this->assertEquals('text/html', $entry->getMimetype()); | 495 | $this->assertSame('text/html', $entry->getMimetype()); |
496 | $this->assertEquals('fr', $entry->getLanguage()); | 496 | $this->assertSame('fr', $entry->getLanguage()); |
497 | $this->assertEquals('200', $entry->getHttpStatus()); | 497 | $this->assertSame('200', $entry->getHttpStatus()); |
498 | $this->assertEquals('1.1.1.1', $entry->getDomainName()); | 498 | $this->assertSame('1.1.1.1', $entry->getDomainName()); |
499 | } | 499 | } |
500 | 500 | ||
501 | private function getTaggerMock() | 501 | private function getTaggerMock() |
diff --git a/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php index cede8696..782c29c3 100644 --- a/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php | |||
@@ -2,9 +2,9 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | 3 | namespace Tests\Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Psr\Log\NullLogger; | ||
6 | use Monolog\Logger; | ||
7 | use Monolog\Handler\TestHandler; | 5 | use Monolog\Handler\TestHandler; |
6 | use Monolog\Logger; | ||
7 | use Psr\Log\NullLogger; | ||
8 | use Wallabag\CoreBundle\Helper\CryptoProxy; | 8 | use Wallabag\CoreBundle\Helper\CryptoProxy; |
9 | 9 | ||
10 | class CryptoProxyTest extends \PHPUnit_Framework_TestCase | 10 | class CryptoProxyTest extends \PHPUnit_Framework_TestCase |
@@ -14,7 +14,7 @@ class CryptoProxyTest extends \PHPUnit_Framework_TestCase | |||
14 | $logHandler = new TestHandler(); | 14 | $logHandler = new TestHandler(); |
15 | $logger = new Logger('test', [$logHandler]); | 15 | $logger = new Logger('test', [$logHandler]); |
16 | 16 | ||
17 | $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', $logger); | 17 | $crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', $logger); |
18 | $crypted = $crypto->crypt('test'); | 18 | $crypted = $crypto->crypt('test'); |
19 | $decrypted = $crypto->decrypt($crypted); | 19 | $decrypted = $crypto->decrypt($crypted); |
20 | 20 | ||
@@ -27,14 +27,14 @@ class CryptoProxyTest extends \PHPUnit_Framework_TestCase | |||
27 | } | 27 | } |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * @expectedException RuntimeException | 30 | * @expectedException \RuntimeException |
31 | * @expectedExceptionMessage Decrypt fail | 31 | * @expectedExceptionMessage Decrypt fail |
32 | * | 32 | * |
33 | * @return [type] [description] | 33 | * @return [type] [description] |
34 | */ | 34 | */ |
35 | public function testDecryptBadValue() | 35 | public function testDecryptBadValue() |
36 | { | 36 | { |
37 | $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', new NullLogger()); | 37 | $crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', new NullLogger()); |
38 | $crypto->decrypt('badvalue'); | 38 | $crypto->decrypt('badvalue'); |
39 | } | 39 | } |
40 | } | 40 | } |
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php index c02f9658..c61f65d0 100644 --- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php +++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php | |||
@@ -2,13 +2,13 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | 3 | namespace Tests\Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Wallabag\CoreBundle\Helper\DownloadImages; | ||
6 | use Monolog\Logger; | ||
7 | use Monolog\Handler\TestHandler; | ||
8 | use GuzzleHttp\Client; | 5 | use GuzzleHttp\Client; |
9 | use GuzzleHttp\Subscriber\Mock; | ||
10 | use GuzzleHttp\Message\Response; | 6 | use GuzzleHttp\Message\Response; |
11 | use GuzzleHttp\Stream\Stream; | 7 | use GuzzleHttp\Stream\Stream; |
8 | use GuzzleHttp\Subscriber\Mock; | ||
9 | use Monolog\Handler\TestHandler; | ||
10 | use Monolog\Logger; | ||
11 | use Wallabag\CoreBundle\Helper\DownloadImages; | ||
12 | 12 | ||
13 | class DownloadImagesTest extends \PHPUnit_Framework_TestCase | 13 | class DownloadImagesTest extends \PHPUnit_Framework_TestCase |
14 | { | 14 | { |
@@ -34,15 +34,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase | |||
34 | $client = new Client(); | 34 | $client = new Client(); |
35 | 35 | ||
36 | $mock = new Mock([ | 36 | $mock = new Mock([ |
37 | new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))), | 37 | new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))), |
38 | ]); | 38 | ]); |
39 | 39 | ||
40 | $client->getEmitter()->attach($mock); | 40 | $client->getEmitter()->attach($mock); |
41 | 41 | ||
42 | $logHandler = new TestHandler(); | 42 | $logHandler = new TestHandler(); |
43 | $logger = new Logger('test', array($logHandler)); | 43 | $logger = new Logger('test', [$logHandler]); |
44 | 44 | ||
45 | $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); | 45 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); |
46 | 46 | ||
47 | $res = $download->processHtml(123, $html, $url); | 47 | $res = $download->processHtml(123, $html, $url); |
48 | 48 | ||
@@ -61,9 +61,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase | |||
61 | $client->getEmitter()->attach($mock); | 61 | $client->getEmitter()->attach($mock); |
62 | 62 | ||
63 | $logHandler = new TestHandler(); | 63 | $logHandler = new TestHandler(); |
64 | $logger = new Logger('test', array($logHandler)); | 64 | $logger = new Logger('test', [$logHandler]); |
65 | 65 | ||
66 | $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); | 66 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); |
67 | $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY'); | 67 | $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY'); |
68 | 68 | ||
69 | $this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type'); | 69 | $this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type'); |
@@ -87,18 +87,18 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase | |||
87 | $client = new Client(); | 87 | $client = new Client(); |
88 | 88 | ||
89 | $mock = new Mock([ | 89 | $mock = new Mock([ |
90 | new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))), | 90 | new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))), |
91 | ]); | 91 | ]); |
92 | 92 | ||
93 | $client->getEmitter()->attach($mock); | 93 | $client->getEmitter()->attach($mock); |
94 | 94 | ||
95 | $logHandler = new TestHandler(); | 95 | $logHandler = new TestHandler(); |
96 | $logger = new Logger('test', array($logHandler)); | 96 | $logger = new Logger('test', [$logHandler]); |
97 | 97 | ||
98 | $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); | 98 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); |
99 | $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); | 99 | $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); |
100 | 100 | ||
101 | $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.'.$extension, $res); | 101 | $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.' . $extension, $res); |
102 | } | 102 | } |
103 | 103 | ||
104 | public function testProcessSingleImageWithBadUrl() | 104 | public function testProcessSingleImageWithBadUrl() |
@@ -112,9 +112,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase | |||
112 | $client->getEmitter()->attach($mock); | 112 | $client->getEmitter()->attach($mock); |
113 | 113 | ||
114 | $logHandler = new TestHandler(); | 114 | $logHandler = new TestHandler(); |
115 | $logger = new Logger('test', array($logHandler)); | 115 | $logger = new Logger('test', [$logHandler]); |
116 | 116 | ||
117 | $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); | 117 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); |
118 | $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); | 118 | $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); |
119 | 119 | ||
120 | $this->assertFalse($res, 'Image can not be found, so it will not be replaced'); | 120 | $this->assertFalse($res, 'Image can not be found, so it will not be replaced'); |
@@ -131,9 +131,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase | |||
131 | $client->getEmitter()->attach($mock); | 131 | $client->getEmitter()->attach($mock); |
132 | 132 | ||
133 | $logHandler = new TestHandler(); | 133 | $logHandler = new TestHandler(); |
134 | $logger = new Logger('test', array($logHandler)); | 134 | $logger = new Logger('test', [$logHandler]); |
135 | 135 | ||
136 | $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); | 136 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); |
137 | $res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); | 137 | $res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); |
138 | 138 | ||
139 | $this->assertFalse($res, 'Image can not be loaded, so it will not be replaced'); | 139 | $this->assertFalse($res, 'Image can not be loaded, so it will not be replaced'); |
@@ -144,15 +144,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase | |||
144 | $client = new Client(); | 144 | $client = new Client(); |
145 | 145 | ||
146 | $mock = new Mock([ | 146 | $mock = new Mock([ |
147 | new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))), | 147 | new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))), |
148 | ]); | 148 | ]); |
149 | 149 | ||
150 | $client->getEmitter()->attach($mock); | 150 | $client->getEmitter()->attach($mock); |
151 | 151 | ||
152 | $logHandler = new TestHandler(); | 152 | $logHandler = new TestHandler(); |
153 | $logger = new Logger('test', array($logHandler)); | 153 | $logger = new Logger('test', [$logHandler]); |
154 | 154 | ||
155 | $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); | 155 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); |
156 | $res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY'); | 156 | $res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY'); |
157 | 157 | ||
158 | $this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced'); | 158 | $this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced'); |
@@ -163,15 +163,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase | |||
163 | $client = new Client(); | 163 | $client = new Client(); |
164 | 164 | ||
165 | $mock = new Mock([ | 165 | $mock = new Mock([ |
166 | new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__.'/../fixtures/image-no-content-type.jpg'))), | 166 | new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))), |
167 | ]); | 167 | ]); |
168 | 168 | ||
169 | $client->getEmitter()->attach($mock); | 169 | $client->getEmitter()->attach($mock); |
170 | 170 | ||
171 | $logHandler = new TestHandler(); | 171 | $logHandler = new TestHandler(); |
172 | $logger = new Logger('test', array($logHandler)); | 172 | $logger = new Logger('test', [$logHandler]); |
173 | 173 | ||
174 | $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); | 174 | $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger); |
175 | 175 | ||
176 | $res = $download->processSingleImage( | 176 | $res = $download->processSingleImage( |
177 | 123, | 177 | 123, |
diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php index f420d06a..7fd2ea2b 100644 --- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php +++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php | |||
@@ -2,11 +2,11 @@ | |||
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | 3 | namespace Tests\Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | ||
6 | use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; | ||
5 | use Wallabag\CoreBundle\Entity\Config; | 7 | use Wallabag\CoreBundle\Entity\Config; |
6 | use Wallabag\UserBundle\Entity\User; | ||
7 | use Wallabag\CoreBundle\Helper\Redirect; | 8 | use Wallabag\CoreBundle\Helper\Redirect; |
8 | use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; | 9 | use Wallabag\UserBundle\Entity\User; |
9 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | ||
10 | 10 | ||
11 | class RedirectTest extends \PHPUnit_Framework_TestCase | 11 | class RedirectTest extends \PHPUnit_Framework_TestCase |
12 | { | 12 | { |
@@ -56,21 +56,21 @@ class RedirectTest extends \PHPUnit_Framework_TestCase | |||
56 | { | 56 | { |
57 | $redirectUrl = $this->redirect->to(null, 'fallback'); | 57 | $redirectUrl = $this->redirect->to(null, 'fallback'); |
58 | 58 | ||
59 | $this->assertEquals('fallback', $redirectUrl); | 59 | $this->assertSame('fallback', $redirectUrl); |
60 | } | 60 | } |
61 | 61 | ||
62 | public function testRedirectToNullWithoutFallback() | 62 | public function testRedirectToNullWithoutFallback() |
63 | { | 63 | { |
64 | $redirectUrl = $this->redirect->to(null); | 64 | $redirectUrl = $this->redirect->to(null); |
65 | 65 | ||
66 | $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl); | 66 | $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl); |
67 | } | 67 | } |
68 | 68 | ||
69 | public function testRedirectToValidUrl() | 69 | public function testRedirectToValidUrl() |
70 | { | 70 | { |
71 | $redirectUrl = $this->redirect->to('/unread/list'); | 71 | $redirectUrl = $this->redirect->to('/unread/list'); |
72 | 72 | ||
73 | $this->assertEquals('/unread/list', $redirectUrl); | 73 | $this->assertSame('/unread/list', $redirectUrl); |
74 | } | 74 | } |
75 | 75 | ||
76 | public function testWithNotLoggedUser() | 76 | public function testWithNotLoggedUser() |
@@ -78,7 +78,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase | |||
78 | $redirect = new Redirect($this->routerMock, new TokenStorage()); | 78 | $redirect = new Redirect($this->routerMock, new TokenStorage()); |
79 | $redirectUrl = $redirect->to('/unread/list'); | 79 | $redirectUrl = $redirect->to('/unread/list'); |
80 | 80 | ||
81 | $this->assertEquals('/unread/list', $redirectUrl); | 81 | $this->assertSame('/unread/list', $redirectUrl); |
82 | } | 82 | } |
83 | 83 | ||
84 | public function testUserForRedirectToHomepage() | 84 | public function testUserForRedirectToHomepage() |
@@ -87,7 +87,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase | |||
87 | 87 | ||
88 | $redirectUrl = $this->redirect->to('/unread/list'); | 88 | $redirectUrl = $this->redirect->to('/unread/list'); |
89 | 89 | ||
90 | $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl); | 90 | $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl); |
91 | } | 91 | } |
92 | 92 | ||
93 | public function testUserForRedirectWithIgnoreActionMarkAsRead() | 93 | public function testUserForRedirectWithIgnoreActionMarkAsRead() |
@@ -96,7 +96,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase | |||
96 | 96 | ||
97 | $redirectUrl = $this->redirect->to('/unread/list', '', true); | 97 | $redirectUrl = $this->redirect->to('/unread/list', '', true); |
98 | 98 | ||
99 | $this->assertEquals('/unread/list', $redirectUrl); | 99 | $this->assertSame('/unread/list', $redirectUrl); |
100 | } | 100 | } |
101 | 101 | ||
102 | public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead() | 102 | public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead() |
@@ -105,6 +105,6 @@ class RedirectTest extends \PHPUnit_Framework_TestCase | |||
105 | 105 | ||
106 | $redirectUrl = $this->redirect->to(null, 'fallback', true); | 106 | $redirectUrl = $this->redirect->to(null, 'fallback', true); |
107 | 107 | ||
108 | $this->assertEquals('fallback', $redirectUrl); | 108 | $this->assertSame('fallback', $redirectUrl); |
109 | } | 109 | } |
110 | } | 110 | } |
diff --git a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php index 1e21f400..c31af680 100644 --- a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php +++ b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php | |||
@@ -182,7 +182,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase | |||
182 | $tags = $entry->getTags(); | 182 | $tags = $entry->getTags(); |
183 | 183 | ||
184 | $this->assertCount(1, $tags); | 184 | $this->assertCount(1, $tags); |
185 | $this->assertEquals('hey', $tags[0]->getLabel()); | 185 | $this->assertSame('hey', $tags[0]->getLabel()); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
diff --git a/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php index 6d6d6484..475cd349 100644 --- a/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php +++ b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php | |||
@@ -5,8 +5,8 @@ namespace Tests\Wallabag\CoreBundle\Helper; | |||
5 | use Wallabag\CoreBundle\Entity\Entry; | 5 | use Wallabag\CoreBundle\Entity\Entry; |
6 | use Wallabag\CoreBundle\Entity\Tag; | 6 | use Wallabag\CoreBundle\Entity\Tag; |
7 | use Wallabag\CoreBundle\Helper\TagsAssigner; | 7 | use Wallabag\CoreBundle\Helper\TagsAssigner; |
8 | use Wallabag\UserBundle\Entity\User; | ||
9 | use Wallabag\CoreBundle\Repository\TagRepository; | 8 | use Wallabag\CoreBundle\Repository\TagRepository; |
9 | use Wallabag\UserBundle\Entity\User; | ||
10 | 10 | ||
11 | class TagsAssignerTest extends \PHPUnit_Framework_TestCase | 11 | class TagsAssignerTest extends \PHPUnit_Framework_TestCase |
12 | { | 12 | { |
@@ -20,8 +20,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase | |||
20 | $tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']); | 20 | $tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']); |
21 | 21 | ||
22 | $this->assertCount(2, $entry->getTags()); | 22 | $this->assertCount(2, $entry->getTags()); |
23 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | 23 | $this->assertSame('tag1', $entry->getTags()[0]->getLabel()); |
24 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | 24 | $this->assertSame('tag2', $entry->getTags()[1]->getLabel()); |
25 | } | 25 | } |
26 | 26 | ||
27 | public function testAssignTagsWithString() | 27 | public function testAssignTagsWithString() |
@@ -34,8 +34,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase | |||
34 | $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); | 34 | $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); |
35 | 35 | ||
36 | $this->assertCount(2, $entry->getTags()); | 36 | $this->assertCount(2, $entry->getTags()); |
37 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | 37 | $this->assertSame('tag1', $entry->getTags()[0]->getLabel()); |
38 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | 38 | $this->assertSame('tag2', $entry->getTags()[1]->getLabel()); |
39 | } | 39 | } |
40 | 40 | ||
41 | public function testAssignTagsWithEmptyArray() | 41 | public function testAssignTagsWithEmptyArray() |
@@ -76,8 +76,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase | |||
76 | $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); | 76 | $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); |
77 | 77 | ||
78 | $this->assertCount(2, $entry->getTags()); | 78 | $this->assertCount(2, $entry->getTags()); |
79 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | 79 | $this->assertSame('tag1', $entry->getTags()[0]->getLabel()); |
80 | $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); | 80 | $this->assertSame('tag2', $entry->getTags()[1]->getLabel()); |
81 | } | 81 | } |
82 | 82 | ||
83 | public function testAssignTagsNotFlushed() | 83 | public function testAssignTagsNotFlushed() |
@@ -96,7 +96,7 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase | |||
96 | $tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]); | 96 | $tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]); |
97 | 97 | ||
98 | $this->assertCount(1, $entry->getTags()); | 98 | $this->assertCount(1, $entry->getTags()); |
99 | $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); | 99 | $this->assertSame('tag1', $entry->getTags()[0]->getLabel()); |
100 | } | 100 | } |
101 | 101 | ||
102 | private function getTagRepositoryMock() | 102 | private function getTagRepositoryMock() |