aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php23
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php32
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php8
-rw-r--r--tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php2
4 files changed, 46 insertions, 19 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index 447feb4f..beb0598a 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -515,6 +515,29 @@ class ConfigControllerTest extends WallabagCoreTestCase
515 } 515 }
516 } 516 }
517 517
518 public function testTaggingRuleTooLong()
519 {
520 $this->logInAs('admin');
521 $client = $this->getClient();
522
523 $crawler = $client->request('GET', '/config');
524
525 $this->assertEquals(200, $client->getResponse()->getStatusCode());
526
527 $form = $crawler->filter('button[id=tagging_rule_save]')->form();
528
529 $crawler = $client->submit($form, [
530 'tagging_rule[rule]' => str_repeat('title', 60),
531 'tagging_rule[tags]' => 'cool tag',
532 ]);
533
534 $this->assertEquals(200, $client->getResponse()->getStatusCode());
535
536 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
537
538 $this->assertContains('255 characters', $body[0]);
539 }
540
518 public function testDeletingTaggingRuleFromAnOtherUser() 541 public function testDeletingTaggingRuleFromAnOtherUser()
519 { 542 {
520 $this->logInAs('bob'); 543 $this->logInAs('bob');
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 33b3ff2a..2ca13b91 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -10,6 +10,8 @@ use Wallabag\UserBundle\Entity\User;
10 10
11class ContentProxyTest extends \PHPUnit_Framework_TestCase 11class ContentProxyTest extends \PHPUnit_Framework_TestCase
12{ 12{
13 private $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.';
14
13 public function testWithBadUrl() 15 public function testWithBadUrl()
14 { 16 {
15 $tagger = $this->getTaggerMock(); 17 $tagger = $this->getTaggerMock();
@@ -31,12 +33,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
31 'language' => '', 33 'language' => '',
32 ]); 34 ]);
33 35
34 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 36 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
35 $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); 37 $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80');
36 38
37 $this->assertEquals('http://user@:80', $entry->getUrl()); 39 $this->assertEquals('http://user@:80', $entry->getUrl());
38 $this->assertEmpty($entry->getTitle()); 40 $this->assertEmpty($entry->getTitle());
39 $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); 41 $this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
40 $this->assertEmpty($entry->getPreviewPicture()); 42 $this->assertEmpty($entry->getPreviewPicture());
41 $this->assertEmpty($entry->getMimetype()); 43 $this->assertEmpty($entry->getMimetype());
42 $this->assertEmpty($entry->getLanguage()); 44 $this->assertEmpty($entry->getLanguage());
@@ -65,12 +67,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
65 'language' => '', 67 'language' => '',
66 ]); 68 ]);
67 69
68 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 70 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
69 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 71 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
70 72
71 $this->assertEquals('http://0.0.0.0', $entry->getUrl()); 73 $this->assertEquals('http://0.0.0.0', $entry->getUrl());
72 $this->assertEmpty($entry->getTitle()); 74 $this->assertEmpty($entry->getTitle());
73 $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); 75 $this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
74 $this->assertEmpty($entry->getPreviewPicture()); 76 $this->assertEmpty($entry->getPreviewPicture());
75 $this->assertEmpty($entry->getMimetype()); 77 $this->assertEmpty($entry->getMimetype());
76 $this->assertEmpty($entry->getLanguage()); 78 $this->assertEmpty($entry->getLanguage());
@@ -104,12 +106,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
104 ], 106 ],
105 ]); 107 ]);
106 108
107 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 109 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
108 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); 110 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
109 111
110 $this->assertEquals('http://domain.io', $entry->getUrl()); 112 $this->assertEquals('http://domain.io', $entry->getUrl());
111 $this->assertEquals('my title', $entry->getTitle()); 113 $this->assertEquals('my title', $entry->getTitle());
112 $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent()); 114 $this->assertEquals($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent());
113 $this->assertEmpty($entry->getPreviewPicture()); 115 $this->assertEmpty($entry->getPreviewPicture());
114 $this->assertEmpty($entry->getLanguage()); 116 $this->assertEmpty($entry->getLanguage());
115 $this->assertEmpty($entry->getHttpStatus()); 117 $this->assertEmpty($entry->getHttpStatus());
@@ -145,7 +147,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
145 ], 147 ],
146 ]); 148 ]);
147 149
148 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 150 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
149 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 151 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
150 152
151 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 153 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
@@ -167,7 +169,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
167 169
168 $graby = $this->getMockBuilder('Graby\Graby')->getMock(); 170 $graby = $this->getMockBuilder('Graby\Graby')->getMock();
169 171
170 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 172 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
171 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 173 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [
172 'html' => str_repeat('this is my content', 325), 174 'html' => str_repeat('this is my content', 325),
173 'title' => 'this is my title', 175 'title' => 'this is my title',
@@ -197,7 +199,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
197 ->will($this->throwException(new \Exception())); 199 ->will($this->throwException(new \Exception()));
198 200
199 $tagRepo = $this->getTagRepositoryMock(); 201 $tagRepo = $this->getTagRepositoryMock();
200 $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger()); 202 $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
201 203
202 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 204 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [
203 'html' => str_repeat('this is my content', 325), 205 'html' => str_repeat('this is my content', 325),
@@ -217,7 +219,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
217 ->getMock(); 219 ->getMock();
218 220
219 $tagRepo = $this->getTagRepositoryMock(); 221 $tagRepo = $this->getTagRepositoryMock();
220 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 222 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
221 223
222 $entry = new Entry(new User()); 224 $entry = new Entry(new User());
223 225
@@ -235,7 +237,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
235 ->getMock(); 237 ->getMock();
236 238
237 $tagRepo = $this->getTagRepositoryMock(); 239 $tagRepo = $this->getTagRepositoryMock();
238 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 240 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
239 241
240 $entry = new Entry(new User()); 242 $entry = new Entry(new User());
241 243
@@ -253,7 +255,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
253 ->getMock(); 255 ->getMock();
254 256
255 $tagRepo = $this->getTagRepositoryMock(); 257 $tagRepo = $this->getTagRepositoryMock();
256 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 258 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
257 259
258 $entry = new Entry(new User()); 260 $entry = new Entry(new User());
259 261
@@ -269,7 +271,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
269 ->getMock(); 271 ->getMock();
270 272
271 $tagRepo = $this->getTagRepositoryMock(); 273 $tagRepo = $this->getTagRepositoryMock();
272 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 274 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
273 275
274 $entry = new Entry(new User()); 276 $entry = new Entry(new User());
275 277
@@ -285,7 +287,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
285 ->getMock(); 287 ->getMock();
286 288
287 $tagRepo = $this->getTagRepositoryMock(); 289 $tagRepo = $this->getTagRepositoryMock();
288 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 290 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
289 291
290 $tagEntity = new Tag(); 292 $tagEntity = new Tag();
291 $tagEntity->setLabel('tag1'); 293 $tagEntity->setLabel('tag1');
@@ -310,7 +312,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
310 $tagRepo->expects($this->never()) 312 $tagRepo->expects($this->never())
311 ->method('__call'); 313 ->method('__call');
312 314
313 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 315 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
314 316
315 $tagEntity = new Tag(); 317 $tagEntity = new Tag();
316 $tagEntity->setLabel('tag1'); 318 $tagEntity->setLabel('tag1');
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index 2c370ed9..acc39997 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -112,7 +112,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
112 ->get('doctrine.orm.entity_manager') 112 ->get('doctrine.orm.entity_manager')
113 ->getRepository('WallabagCoreBundle:Entry') 113 ->getRepository('WallabagCoreBundle:Entry')
114 ->findByUrlAndUserId( 114 ->findByUrlAndUserId(
115 'http://www.framablog.org/index.php/post/2014/02/05/Framabag-service-libre-gratuit-interview-developpeur', 115 'https://framablog.org/2014/02/05/framabag-service-libre-gratuit-interview-developpeur/',
116 $this->getLoggedInUserId() 116 $this->getLoggedInUserId()
117 ); 117 );
118 118
@@ -126,9 +126,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
126 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 126 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
127 $this->assertContains('flashes.import.notice.summary', $body[0]); 127 $this->assertContains('flashes.import.notice.summary', $body[0]);
128 128
129 $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); 129 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok');
130 $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); 130 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok');
131 $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); 131 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok');
132 $this->assertEquals(1, count($content->getTags())); 132 $this->assertEquals(1, count($content->getTags()));
133 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 133 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
134 } 134 }
diff --git a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
index a78b77bc..01796ded 100644
--- a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
+++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
@@ -31,6 +31,8 @@ class CreateConfigListenerTest extends \PHPUnit_Framework_TestCase
31 20, 31 20,
32 50, 32 50,
33 'fr', 33 'fr',
34 1,
35 1,
34 1 36 1
35 ); 37 );
36 38