aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php110
-rw-r--r--tests/Wallabag/ApiBundle/WallabagApiTestCase.php2
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php141
-rw-r--r--tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php108
-rw-r--r--tests/Wallabag/ImportBundle/Import/ChromeImportTest.php7
-rw-r--r--tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php7
-rw-r--r--tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php7
-rw-r--r--tests/Wallabag/ImportBundle/Import/PocketImportTest.php8
-rw-r--r--tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php7
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php8
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php8
-rw-r--r--tests/Wallabag/UserBundle/Controller/ManageControllerTest.php4
12 files changed, 277 insertions, 140 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
new file mode 100644
index 00000000..3f4969a5
--- /dev/null
+++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
@@ -0,0 +1,110 @@
1<?php
2
3namespace Tests\Wallabag\ApiBundle\Controller;
4
5use Tests\Wallabag\ApiBundle\WallabagApiTestCase;
6
7class UserRestControllerTest extends WallabagApiTestCase
8{
9 public function testGetUser()
10 {
11 $this->client->request('GET', '/api/user.json');
12 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
13
14 $content = json_decode($this->client->getResponse()->getContent(), true);
15
16 $this->assertArrayHasKey('id', $content);
17 $this->assertArrayHasKey('email', $content);
18 $this->assertArrayHasKey('name', $content);
19 $this->assertArrayHasKey('username', $content);
20 $this->assertArrayHasKey('created_at', $content);
21 $this->assertArrayHasKey('updated_at', $content);
22
23 $this->assertEquals('bigboss@wallabag.org', $content['email']);
24 $this->assertEquals('Big boss', $content['name']);
25 $this->assertEquals('admin', $content['username']);
26
27 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
28 }
29
30 public function testCreateNewUser()
31 {
32 $this->client->request('PUT', '/api/user.json', [
33 'username' => 'google',
34 'password' => 'googlegoogle',
35 'email' => 'wallabag@google.com',
36 ]);
37
38 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
39
40 $content = json_decode($this->client->getResponse()->getContent(), true);
41
42 $this->assertArrayHasKey('id', $content);
43 $this->assertArrayHasKey('email', $content);
44 $this->assertArrayHasKey('username', $content);
45 $this->assertArrayHasKey('created_at', $content);
46 $this->assertArrayHasKey('updated_at', $content);
47
48 $this->assertEquals('wallabag@google.com', $content['email']);
49 $this->assertEquals('google', $content['username']);
50
51 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
52
53 // remove the created user to avoid side effect on other tests
54 // @todo remove these lines when test will be isolated
55 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
56
57 $query = $em->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Config c WHERE c.user = :user_id');
58 $query->setParameter('user_id', $content['id']);
59 $query->execute();
60
61 $query = $em->createQuery('DELETE FROM Wallabag\UserBundle\Entity\User u WHERE u.id = :id');
62 $query->setParameter('id', $content['id']);
63 $query->execute();
64 }
65
66 public function testCreateNewUserWithExistingEmail()
67 {
68 $this->client->request('PUT', '/api/user.json', [
69 'username' => 'admin',
70 'password' => 'googlegoogle',
71 'email' => 'bigboss@wallabag.org',
72 ]);
73
74 $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
75
76 $content = json_decode($this->client->getResponse()->getContent(), true);
77
78 $this->assertArrayHasKey('error', $content);
79 $this->assertArrayHasKey('username', $content['error']);
80 $this->assertArrayHasKey('email', $content['error']);
81
82 // $this->assertEquals('fos_user.username.already_used', $content['error']['username'][0]);
83 // $this->assertEquals('fos_user.email.already_used', $content['error']['email'][0]);
84 // This shouldn't be translated ...
85 $this->assertEquals('This value is already used.', $content['error']['username'][0]);
86 $this->assertEquals('This value is already used.', $content['error']['email'][0]);
87
88 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
89 }
90
91 public function testCreateNewUserWithTooShortPassword()
92 {
93 $this->client->request('PUT', '/api/user.json', [
94 'username' => 'facebook',
95 'password' => 'face',
96 'email' => 'facebook@wallabag.org',
97 ]);
98
99 $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
100
101 $content = json_decode($this->client->getResponse()->getContent(), true);
102
103 $this->assertArrayHasKey('error', $content);
104 $this->assertArrayHasKey('password', $content['error']);
105
106 $this->assertEquals('validator.password_too_short', $content['error']['password'][0]);
107
108 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
109 }
110}
diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
index cf9b3347..a67655c8 100644
--- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
+++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
@@ -37,7 +37,7 @@ abstract class WallabagApiTestCase extends WebTestCase
37 $firewallName = $container->getParameter('fos_user.firewall_name'); 37 $firewallName = $container->getParameter('fos_user.firewall_name');
38 38
39 $this->user = $userManager->findUserBy(['username' => 'admin']); 39 $this->user = $userManager->findUserBy(['username' => 'admin']);
40 $loginManager->loginUser($firewallName, $this->user); 40 $loginManager->logInUser($firewallName, $this->user);
41 41
42 // save the login token into the session and put it in a cookie 42 // save the login token into the session and put it in a cookie
43 $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken())); 43 $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 8abb1bbb..77dfd5bf 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -7,10 +7,12 @@ use Wallabag\CoreBundle\Helper\ContentProxy;
7use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\Tag; 8use Wallabag\CoreBundle\Entity\Tag;
9use Wallabag\UserBundle\Entity\User; 9use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Repository\TagRepository;
11use Wallabag\CoreBundle\Helper\RuleBasedTagger;
10 12
11class ContentProxyTest extends \PHPUnit_Framework_TestCase 13class ContentProxyTest extends \PHPUnit_Framework_TestCase
12{ 14{
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>.'; 15 private $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.';
14 16
15 public function testWithBadUrl() 17 public function testWithBadUrl()
16 { 18 {
@@ -33,7 +35,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
33 'language' => '', 35 'language' => '',
34 ]); 36 ]);
35 37
36 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); 38 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
37 $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); 39 $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80');
38 40
39 $this->assertEquals('http://user@:80', $entry->getUrl()); 41 $this->assertEquals('http://user@:80', $entry->getUrl());
@@ -67,7 +69,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
67 'language' => '', 69 'language' => '',
68 ]); 70 ]);
69 71
70 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); 72 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
71 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 73 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
72 74
73 $this->assertEquals('http://0.0.0.0', $entry->getUrl()); 75 $this->assertEquals('http://0.0.0.0', $entry->getUrl());
@@ -106,7 +108,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
106 ], 108 ],
107 ]); 109 ]);
108 110
109 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); 111 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
110 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); 112 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
111 113
112 $this->assertEquals('http://domain.io', $entry->getUrl()); 114 $this->assertEquals('http://domain.io', $entry->getUrl());
@@ -147,7 +149,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
147 ], 149 ],
148 ]); 150 ]);
149 151
150 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); 152 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
151 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 153 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
152 154
153 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 155 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
@@ -188,7 +190,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
188 ], 190 ],
189 ]); 191 ]);
190 192
191 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); 193 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
192 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 194 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
193 195
194 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 196 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
@@ -210,7 +212,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
210 212
211 $graby = $this->getMockBuilder('Graby\Graby')->getMock(); 213 $graby = $this->getMockBuilder('Graby\Graby')->getMock();
212 214
213 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); 215 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
214 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 216 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [
215 'html' => str_repeat('this is my content', 325), 217 'html' => str_repeat('this is my content', 325),
216 'title' => 'this is my title', 218 'title' => 'this is my title',
@@ -239,8 +241,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
239 ->method('tag') 241 ->method('tag')
240 ->will($this->throwException(new \Exception())); 242 ->will($this->throwException(new \Exception()));
241 243
242 $tagRepo = $this->getTagRepositoryMock(); 244 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
243 $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
244 245
245 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 246 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [
246 'html' => str_repeat('this is my content', 325), 247 'html' => str_repeat('this is my content', 325),
@@ -253,134 +254,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
253 $this->assertCount(0, $entry->getTags()); 254 $this->assertCount(0, $entry->getTags());
254 } 255 }
255 256
256 public function testAssignTagsWithArrayAndExtraSpaces()
257 {
258 $graby = $this->getMockBuilder('Graby\Graby')
259 ->disableOriginalConstructor()
260 ->getMock();
261
262 $tagRepo = $this->getTagRepositoryMock();
263 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
264
265 $entry = new Entry(new User());
266
267 $proxy->assignTagsToEntry($entry, [' tag1', 'tag2 ']);
268
269 $this->assertCount(2, $entry->getTags());
270 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
271 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
272 }
273
274 public function testAssignTagsWithString()
275 {
276 $graby = $this->getMockBuilder('Graby\Graby')
277 ->disableOriginalConstructor()
278 ->getMock();
279
280 $tagRepo = $this->getTagRepositoryMock();
281 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
282
283 $entry = new Entry(new User());
284
285 $proxy->assignTagsToEntry($entry, 'tag1, tag2');
286
287 $this->assertCount(2, $entry->getTags());
288 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
289 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
290 }
291
292 public function testAssignTagsWithEmptyArray()
293 {
294 $graby = $this->getMockBuilder('Graby\Graby')
295 ->disableOriginalConstructor()
296 ->getMock();
297
298 $tagRepo = $this->getTagRepositoryMock();
299 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
300
301 $entry = new Entry(new User());
302
303 $proxy->assignTagsToEntry($entry, []);
304
305 $this->assertCount(0, $entry->getTags());
306 }
307
308 public function testAssignTagsWithEmptyString()
309 {
310 $graby = $this->getMockBuilder('Graby\Graby')
311 ->disableOriginalConstructor()
312 ->getMock();
313
314 $tagRepo = $this->getTagRepositoryMock();
315 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
316
317 $entry = new Entry(new User());
318
319 $proxy->assignTagsToEntry($entry, '');
320
321 $this->assertCount(0, $entry->getTags());
322 }
323
324 public function testAssignTagsAlreadyAssigned()
325 {
326 $graby = $this->getMockBuilder('Graby\Graby')
327 ->disableOriginalConstructor()
328 ->getMock();
329
330 $tagRepo = $this->getTagRepositoryMock();
331 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
332
333 $tagEntity = new Tag();
334 $tagEntity->setLabel('tag1');
335
336 $entry = new Entry(new User());
337 $entry->addTag($tagEntity);
338
339 $proxy->assignTagsToEntry($entry, 'tag1, tag2');
340
341 $this->assertCount(2, $entry->getTags());
342 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
343 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
344 }
345
346 public function testAssignTagsNotFlushed()
347 {
348 $graby = $this->getMockBuilder('Graby\Graby')
349 ->disableOriginalConstructor()
350 ->getMock();
351
352 $tagRepo = $this->getTagRepositoryMock();
353 $tagRepo->expects($this->never())
354 ->method('__call');
355
356 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
357
358 $tagEntity = new Tag();
359 $tagEntity->setLabel('tag1');
360
361 $entry = new Entry(new User());
362
363 $proxy->assignTagsToEntry($entry, 'tag1', [$tagEntity]);
364
365 $this->assertCount(1, $entry->getTags());
366 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
367 }
368
369 private function getTaggerMock() 257 private function getTaggerMock()
370 { 258 {
371 return $this->getMockBuilder('Wallabag\CoreBundle\Helper\RuleBasedTagger') 259 return $this->getMockBuilder(RuleBasedTagger::class)
372 ->setMethods(['tag']) 260 ->setMethods(['tag'])
373 ->disableOriginalConstructor() 261 ->disableOriginalConstructor()
374 ->getMock(); 262 ->getMock();
375 } 263 }
376 264
377 private function getTagRepositoryMock()
378 {
379 return $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
380 ->disableOriginalConstructor()
381 ->getMock();
382 }
383
384 private function getLogger() 265 private function getLogger()
385 { 266 {
386 return new NullLogger(); 267 return new NullLogger();
diff --git a/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php
new file mode 100644
index 00000000..6d6d6484
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php
@@ -0,0 +1,108 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Helper;
4
5use Wallabag\CoreBundle\Entity\Entry;
6use Wallabag\CoreBundle\Entity\Tag;
7use Wallabag\CoreBundle\Helper\TagsAssigner;
8use Wallabag\UserBundle\Entity\User;
9use Wallabag\CoreBundle\Repository\TagRepository;
10
11class TagsAssignerTest extends \PHPUnit_Framework_TestCase
12{
13 public function testAssignTagsWithArrayAndExtraSpaces()
14 {
15 $tagRepo = $this->getTagRepositoryMock();
16 $tagsAssigner = new TagsAssigner($tagRepo);
17
18 $entry = new Entry(new User());
19
20 $tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']);
21
22 $this->assertCount(2, $entry->getTags());
23 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
24 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
25 }
26
27 public function testAssignTagsWithString()
28 {
29 $tagRepo = $this->getTagRepositoryMock();
30 $tagsAssigner = new TagsAssigner($tagRepo);
31
32 $entry = new Entry(new User());
33
34 $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
35
36 $this->assertCount(2, $entry->getTags());
37 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
38 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
39 }
40
41 public function testAssignTagsWithEmptyArray()
42 {
43 $tagRepo = $this->getTagRepositoryMock();
44 $tagsAssigner = new TagsAssigner($tagRepo);
45
46 $entry = new Entry(new User());
47
48 $tagsAssigner->assignTagsToEntry($entry, []);
49
50 $this->assertCount(0, $entry->getTags());
51 }
52
53 public function testAssignTagsWithEmptyString()
54 {
55 $tagRepo = $this->getTagRepositoryMock();
56 $tagsAssigner = new TagsAssigner($tagRepo);
57
58 $entry = new Entry(new User());
59
60 $tagsAssigner->assignTagsToEntry($entry, '');
61
62 $this->assertCount(0, $entry->getTags());
63 }
64
65 public function testAssignTagsAlreadyAssigned()
66 {
67 $tagRepo = $this->getTagRepositoryMock();
68 $tagsAssigner = new TagsAssigner($tagRepo);
69
70 $tagEntity = new Tag();
71 $tagEntity->setLabel('tag1');
72
73 $entry = new Entry(new User());
74 $entry->addTag($tagEntity);
75
76 $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
77
78 $this->assertCount(2, $entry->getTags());
79 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
80 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel());
81 }
82
83 public function testAssignTagsNotFlushed()
84 {
85 $tagRepo = $this->getTagRepositoryMock();
86 $tagRepo->expects($this->never())
87 ->method('__call');
88
89 $tagsAssigner = new TagsAssigner($tagRepo);
90
91 $tagEntity = new Tag();
92 $tagEntity->setLabel('tag1');
93
94 $entry = new Entry(new User());
95
96 $tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]);
97
98 $this->assertCount(1, $entry->getTags());
99 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel());
100 }
101
102 private function getTagRepositoryMock()
103 {
104 return $this->getMockBuilder(TagRepository::class)
105 ->disableOriginalConstructor()
106 ->getMock();
107 }
108}
diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
index 6b3adda4..cec19534 100644
--- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
@@ -17,6 +17,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
17 protected $em; 17 protected $em;
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner;
20 21
21 private function getChromeImport($unsetUser = false, $dispatched = 0) 22 private function getChromeImport($unsetUser = false, $dispatched = 0)
22 { 23 {
@@ -30,6 +31,10 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 31 ->disableOriginalConstructor()
31 ->getMock(); 32 ->getMock();
32 33
34 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
35 ->disableOriginalConstructor()
36 ->getMock();
37
33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') 38 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor() 39 ->disableOriginalConstructor()
35 ->getMock(); 40 ->getMock();
@@ -38,7 +43,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
38 ->expects($this->exactly($dispatched)) 43 ->expects($this->exactly($dispatched))
39 ->method('dispatch'); 44 ->method('dispatch');
40 45
41 $wallabag = new ChromeImport($this->em, $this->contentProxy, $dispatcher); 46 $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
42 47
43 $this->logHandler = new TestHandler(); 48 $this->logHandler = new TestHandler();
44 $logger = new Logger('test', [$this->logHandler]); 49 $logger = new Logger('test', [$this->logHandler]);
diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
index b516fbc5..c186c820 100644
--- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
@@ -17,6 +17,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
17 protected $em; 17 protected $em;
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner;
20 21
21 private function getFirefoxImport($unsetUser = false, $dispatched = 0) 22 private function getFirefoxImport($unsetUser = false, $dispatched = 0)
22 { 23 {
@@ -30,6 +31,10 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 31 ->disableOriginalConstructor()
31 ->getMock(); 32 ->getMock();
32 33
34 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
35 ->disableOriginalConstructor()
36 ->getMock();
37
33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') 38 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor() 39 ->disableOriginalConstructor()
35 ->getMock(); 40 ->getMock();
@@ -38,7 +43,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
38 ->expects($this->exactly($dispatched)) 43 ->expects($this->exactly($dispatched))
39 ->method('dispatch'); 44 ->method('dispatch');
40 45
41 $wallabag = new FirefoxImport($this->em, $this->contentProxy, $dispatcher); 46 $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
42 47
43 $this->logHandler = new TestHandler(); 48 $this->logHandler = new TestHandler();
44 $logger = new Logger('test', [$this->logHandler]); 49 $logger = new Logger('test', [$this->logHandler]);
diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
index e262a808..6777a02e 100644
--- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
@@ -17,6 +17,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
17 protected $em; 17 protected $em;
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner;
20 21
21 private function getInstapaperImport($unsetUser = false, $dispatched = 0) 22 private function getInstapaperImport($unsetUser = false, $dispatched = 0)
22 { 23 {
@@ -30,6 +31,10 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 31 ->disableOriginalConstructor()
31 ->getMock(); 32 ->getMock();
32 33
34 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
35 ->disableOriginalConstructor()
36 ->getMock();
37
33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') 38 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor() 39 ->disableOriginalConstructor()
35 ->getMock(); 40 ->getMock();
@@ -38,7 +43,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
38 ->expects($this->exactly($dispatched)) 43 ->expects($this->exactly($dispatched))
39 ->method('dispatch'); 44 ->method('dispatch');
40 45
41 $import = new InstapaperImport($this->em, $this->contentProxy, $dispatcher); 46 $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
42 47
43 $this->logHandler = new TestHandler(); 48 $this->logHandler = new TestHandler();
44 $logger = new Logger('test', [$this->logHandler]); 49 $logger = new Logger('test', [$this->logHandler]);
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
index 141ece36..b81ebe15 100644
--- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
@@ -23,6 +23,8 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
23 protected $em; 23 protected $em;
24 protected $contentProxy; 24 protected $contentProxy;
25 protected $logHandler; 25 protected $logHandler;
26 protected $tagsAssigner;
27 protected $uow;
26 28
27 private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0) 29 private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0)
28 { 30 {
@@ -37,6 +39,10 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
37 ->disableOriginalConstructor() 39 ->disableOriginalConstructor()
38 ->getMock(); 40 ->getMock();
39 41
42 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
43 ->disableOriginalConstructor()
44 ->getMock();
45
40 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') 46 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
41 ->disableOriginalConstructor() 47 ->disableOriginalConstructor()
42 ->getMock(); 48 ->getMock();
@@ -63,7 +69,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
63 ->expects($this->exactly($dispatched)) 69 ->expects($this->exactly($dispatched))
64 ->method('dispatch'); 70 ->method('dispatch');
65 71
66 $pocket = new PocketImport($this->em, $this->contentProxy, $dispatcher); 72 $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
67 $pocket->setUser($this->user); 73 $pocket->setUser($this->user);
68 74
69 $this->logHandler = new TestHandler(); 75 $this->logHandler = new TestHandler();
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
index d1bbe648..254f0a25 100644
--- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
@@ -17,6 +17,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
17 protected $em; 17 protected $em;
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner;
20 21
21 private function getReadabilityImport($unsetUser = false, $dispatched = 0) 22 private function getReadabilityImport($unsetUser = false, $dispatched = 0)
22 { 23 {
@@ -30,6 +31,10 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 31 ->disableOriginalConstructor()
31 ->getMock(); 32 ->getMock();
32 33
34 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
35 ->disableOriginalConstructor()
36 ->getMock();
37
33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') 38 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor() 39 ->disableOriginalConstructor()
35 ->getMock(); 40 ->getMock();
@@ -38,7 +43,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
38 ->expects($this->exactly($dispatched)) 43 ->expects($this->exactly($dispatched))
39 ->method('dispatch'); 44 ->method('dispatch');
40 45
41 $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $dispatcher); 46 $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
42 47
43 $this->logHandler = new TestHandler(); 48 $this->logHandler = new TestHandler();
44 $logger = new Logger('test', [$this->logHandler]); 49 $logger = new Logger('test', [$this->logHandler]);
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
index 4dbced60..9f0c5bac 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
@@ -17,6 +17,8 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
17 protected $em; 17 protected $em;
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner;
21 protected $uow;
20 22
21 private function getWallabagV1Import($unsetUser = false, $dispatched = 0) 23 private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
22 { 24 {
@@ -44,6 +46,10 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
44 ->disableOriginalConstructor() 46 ->disableOriginalConstructor()
45 ->getMock(); 47 ->getMock();
46 48
49 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
50 ->disableOriginalConstructor()
51 ->getMock();
52
47 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') 53 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
48 ->disableOriginalConstructor() 54 ->disableOriginalConstructor()
49 ->getMock(); 55 ->getMock();
@@ -52,7 +58,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
52 ->expects($this->exactly($dispatched)) 58 ->expects($this->exactly($dispatched))
53 ->method('dispatch'); 59 ->method('dispatch');
54 60
55 $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $dispatcher); 61 $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
56 62
57 $this->logHandler = new TestHandler(); 63 $this->logHandler = new TestHandler();
58 $logger = new Logger('test', [$this->logHandler]); 64 $logger = new Logger('test', [$this->logHandler]);
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
index 0e50b8b2..efcaeb9e 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
@@ -17,6 +17,8 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
17 protected $em; 17 protected $em;
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner;
21 protected $uow;
20 22
21 private function getWallabagV2Import($unsetUser = false, $dispatched = 0) 23 private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
22 { 24 {
@@ -44,6 +46,10 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
44 ->disableOriginalConstructor() 46 ->disableOriginalConstructor()
45 ->getMock(); 47 ->getMock();
46 48
49 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
50 ->disableOriginalConstructor()
51 ->getMock();
52
47 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') 53 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
48 ->disableOriginalConstructor() 54 ->disableOriginalConstructor()
49 ->getMock(); 55 ->getMock();
@@ -52,7 +58,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
52 ->expects($this->exactly($dispatched)) 58 ->expects($this->exactly($dispatched))
53 ->method('dispatch'); 59 ->method('dispatch');
54 60
55 $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $dispatcher); 61 $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
56 62
57 $this->logHandler = new TestHandler(); 63 $this->logHandler = new TestHandler();
58 $logger = new Logger('test', [$this->logHandler]); 64 $logger = new Logger('test', [$this->logHandler]);
diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
index 44b9a030..b46256a6 100644
--- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
+++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
@@ -30,8 +30,8 @@ class ManageControllerTest extends WallabagCoreTestCase
30 $form = $crawler->selectButton('user.form.save')->form(array( 30 $form = $crawler->selectButton('user.form.save')->form(array(
31 'new_user[username]' => 'test_user', 31 'new_user[username]' => 'test_user',
32 'new_user[email]' => 'test@test.io', 32 'new_user[email]' => 'test@test.io',
33 'new_user[plainPassword][first]' => 'test', 33 'new_user[plainPassword][first]' => 'testtest',
34 'new_user[plainPassword][second]' => 'test', 34 'new_user[plainPassword][second]' => 'testtest',
35 )); 35 ));
36 36
37 $client->submit($form); 37 $client->submit($form);