diff options
Diffstat (limited to 'tests/Wallabag')
5 files changed, 198 insertions, 6 deletions
diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php index 25de2730..210b2ab6 100644 --- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php | |||
@@ -55,7 +55,8 @@ class ExportCommandTest extends WallabagCoreTestCase | |||
55 | 'username' => 'admin', | 55 | 'username' => 'admin', |
56 | ]); | 56 | ]); |
57 | 57 | ||
58 | $this->assertContains('Exporting 5 entrie(s) for user « admin »... Done', $tester->getDisplay()); | 58 | $this->assertContains('Exporting 5 entrie(s) for user admin...', $tester->getDisplay()); |
59 | $this->assertContains('Done', $tester->getDisplay()); | ||
59 | $this->assertFileExists('admin-export.json'); | 60 | $this->assertFileExists('admin-export.json'); |
60 | } | 61 | } |
61 | 62 | ||
diff --git a/tests/Wallabag/CoreBundle/Command/ListUserCommandTest.php b/tests/Wallabag/CoreBundle/Command/ListUserCommandTest.php new file mode 100644 index 00000000..9068cf59 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Command/ListUserCommandTest.php | |||
@@ -0,0 +1,75 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
6 | use Symfony\Component\Console\Tester\CommandTester; | ||
7 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
8 | use Wallabag\CoreBundle\Command\ListUserCommand; | ||
9 | |||
10 | class ListUserCommandTest extends WallabagCoreTestCase | ||
11 | { | ||
12 | public function testRunListUserCommand() | ||
13 | { | ||
14 | $application = new Application($this->getClient()->getKernel()); | ||
15 | $application->add(new ListUserCommand()); | ||
16 | |||
17 | $command = $application->find('wallabag:user:list'); | ||
18 | |||
19 | $tester = new CommandTester($command); | ||
20 | $tester->execute([ | ||
21 | 'command' => $command->getName(), | ||
22 | ]); | ||
23 | |||
24 | $this->assertContains('3/3 user(s) displayed.', $tester->getDisplay()); | ||
25 | } | ||
26 | |||
27 | public function testRunListUserCommandWithLimit() | ||
28 | { | ||
29 | $application = new Application($this->getClient()->getKernel()); | ||
30 | $application->add(new ListUserCommand()); | ||
31 | |||
32 | $command = $application->find('wallabag:user:list'); | ||
33 | |||
34 | $tester = new CommandTester($command); | ||
35 | $tester->execute([ | ||
36 | 'command' => $command->getName(), | ||
37 | '--limit' => 2, | ||
38 | ]); | ||
39 | |||
40 | $this->assertContains('2/3 user(s) displayed.', $tester->getDisplay()); | ||
41 | } | ||
42 | |||
43 | public function testRunListUserCommandWithSearch() | ||
44 | { | ||
45 | $application = new Application($this->getClient()->getKernel()); | ||
46 | $application->add(new ListUserCommand()); | ||
47 | |||
48 | $command = $application->find('wallabag:user:list'); | ||
49 | |||
50 | $tester = new CommandTester($command); | ||
51 | $tester->execute([ | ||
52 | 'command' => $command->getName(), | ||
53 | 'search' => 'boss', | ||
54 | ]); | ||
55 | |||
56 | $this->assertContains('1/3 (filtered) user(s) displayed.', $tester->getDisplay()); | ||
57 | } | ||
58 | |||
59 | public function testRunListUserCommandWithSearchAndLimit() | ||
60 | { | ||
61 | $application = new Application($this->getClient()->getKernel()); | ||
62 | $application->add(new ListUserCommand()); | ||
63 | |||
64 | $command = $application->find('wallabag:user:list'); | ||
65 | |||
66 | $tester = new CommandTester($command); | ||
67 | $tester->execute([ | ||
68 | 'command' => $command->getName(), | ||
69 | 'search' => 'bo', | ||
70 | '--limit' => 1, | ||
71 | ]); | ||
72 | |||
73 | $this->assertContains('1/3 (filtered) user(s) displayed.', $tester->getDisplay()); | ||
74 | } | ||
75 | } | ||
diff --git a/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php new file mode 100644 index 00000000..63c068b4 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php | |||
@@ -0,0 +1,115 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Command; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
6 | use Symfony\Component\Console\Tester\CommandTester; | ||
7 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
8 | use Wallabag\CoreBundle\Command\ReloadEntryCommand; | ||
9 | use Wallabag\CoreBundle\Entity\Entry; | ||
10 | |||
11 | class ReloadEntryCommandTest extends WallabagCoreTestCase | ||
12 | { | ||
13 | public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; | ||
14 | |||
15 | /** | ||
16 | * @var entry | ||
17 | */ | ||
18 | public $adminEntry; | ||
19 | |||
20 | /** | ||
21 | * @var Entry | ||
22 | */ | ||
23 | public $bobEntry; | ||
24 | |||
25 | public function setUp() | ||
26 | { | ||
27 | parent::setUp(); | ||
28 | |||
29 | $userRepository = $this->getClient()->getContainer()->get('wallabag_user.user_repository'); | ||
30 | |||
31 | $user = $userRepository->findOneByUserName('admin'); | ||
32 | $this->adminEntry = new Entry($user); | ||
33 | $this->adminEntry->setUrl($this->url); | ||
34 | $this->adminEntry->setTitle('title foo'); | ||
35 | $this->adminEntry->setContent(''); | ||
36 | $this->getEntityManager()->persist($this->adminEntry); | ||
37 | |||
38 | $user = $userRepository->findOneByUserName('bob'); | ||
39 | $this->bobEntry = new Entry($user); | ||
40 | $this->bobEntry->setUrl($this->url); | ||
41 | $this->bobEntry->setTitle('title foo'); | ||
42 | $this->bobEntry->setContent(''); | ||
43 | $this->getEntityManager()->persist($this->bobEntry); | ||
44 | |||
45 | $this->getEntityManager()->flush(); | ||
46 | } | ||
47 | |||
48 | public function testRunReloadEntryCommand() | ||
49 | { | ||
50 | $application = new Application($this->getClient()->getKernel()); | ||
51 | $application->add(new ReloadEntryCommand()); | ||
52 | |||
53 | $command = $application->find('wallabag:entry:reload'); | ||
54 | $tester = new CommandTester($command); | ||
55 | $tester->execute([ | ||
56 | 'command' => $command->getName(), | ||
57 | ], [ | ||
58 | 'interactive' => false, | ||
59 | ]); | ||
60 | |||
61 | $reloadedEntries = $this->getClient() | ||
62 | ->getContainer() | ||
63 | ->get('wallabag_core.entry_repository') | ||
64 | ->findById([$this->adminEntry->getId(), $this->bobEntry->getId()]); | ||
65 | |||
66 | foreach ($reloadedEntries as $reloadedEntry) { | ||
67 | $this->assertNotEmpty($reloadedEntry->getContent()); | ||
68 | } | ||
69 | |||
70 | $this->assertContains('Done', $tester->getDisplay()); | ||
71 | } | ||
72 | |||
73 | public function testRunReloadEntryWithUsernameCommand() | ||
74 | { | ||
75 | $application = new Application($this->getClient()->getKernel()); | ||
76 | $application->add(new ReloadEntryCommand()); | ||
77 | |||
78 | $command = $application->find('wallabag:entry:reload'); | ||
79 | $tester = new CommandTester($command); | ||
80 | $tester->execute([ | ||
81 | 'command' => $command->getName(), | ||
82 | 'username' => 'admin', | ||
83 | ], [ | ||
84 | 'interactive' => false, | ||
85 | ]); | ||
86 | |||
87 | $entryRepository = $this->getClient()->getContainer()->get('wallabag_core.entry_repository'); | ||
88 | |||
89 | $reloadedAdminEntry = $entryRepository->find($this->adminEntry->getId()); | ||
90 | $this->assertNotEmpty($reloadedAdminEntry->getContent()); | ||
91 | |||
92 | $reloadedBobEntry = $entryRepository->find($this->bobEntry->getId()); | ||
93 | $this->assertEmpty($reloadedBobEntry->getContent()); | ||
94 | |||
95 | $this->assertContains('Done', $tester->getDisplay()); | ||
96 | } | ||
97 | |||
98 | public function testRunReloadEntryWithoutEntryCommand() | ||
99 | { | ||
100 | $application = new Application($this->getClient()->getKernel()); | ||
101 | $application->add(new ReloadEntryCommand()); | ||
102 | |||
103 | $command = $application->find('wallabag:entry:reload'); | ||
104 | $tester = new CommandTester($command); | ||
105 | $tester->execute([ | ||
106 | 'command' => $command->getName(), | ||
107 | 'username' => 'empty', | ||
108 | ], [ | ||
109 | 'interactive' => false, | ||
110 | ]); | ||
111 | |||
112 | $this->assertContains('No entry to reload', $tester->getDisplay()); | ||
113 | $this->assertNotContains('Done', $tester->getDisplay()); | ||
114 | } | ||
115 | } | ||
diff --git a/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php index c0a4acfa..9b34f2a0 100644 --- a/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/ShowUserCommandTest.php | |||
@@ -56,9 +56,9 @@ class ShowUserCommandTest extends WallabagCoreTestCase | |||
56 | 'username' => 'admin', | 56 | 'username' => 'admin', |
57 | ]); | 57 | ]); |
58 | 58 | ||
59 | $this->assertContains('Username : admin', $tester->getDisplay()); | 59 | $this->assertContains('Username: admin', $tester->getDisplay()); |
60 | $this->assertContains('Email : bigboss@wallabag.org', $tester->getDisplay()); | 60 | $this->assertContains('Email: bigboss@wallabag.org', $tester->getDisplay()); |
61 | $this->assertContains('Display name : Big boss', $tester->getDisplay()); | 61 | $this->assertContains('Display name: Big boss', $tester->getDisplay()); |
62 | $this->assertContains('2FA activated: no', $tester->getDisplay()); | 62 | $this->assertContains('2FA activated: no', $tester->getDisplay()); |
63 | } | 63 | } |
64 | 64 | ||
@@ -88,6 +88,6 @@ class ShowUserCommandTest extends WallabagCoreTestCase | |||
88 | 'username' => 'admin', | 88 | 'username' => 'admin', |
89 | ]); | 89 | ]); |
90 | 90 | ||
91 | $this->assertContains('Display name : Bug boss', $tester->getDisplay()); | 91 | $this->assertContains('Display name: Bug boss', $tester->getDisplay()); |
92 | } | 92 | } |
93 | } | 93 | } |
diff --git a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php index 96d0e91f..b1e56a10 100644 --- a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php | |||
@@ -55,6 +55,7 @@ class TagAllCommandTest extends WallabagCoreTestCase | |||
55 | 'username' => 'admin', | 55 | 'username' => 'admin', |
56 | ]); | 56 | ]); |
57 | 57 | ||
58 | $this->assertContains('Tagging entries for user « admin »... Done', $tester->getDisplay()); | 58 | $this->assertContains('Tagging entries for user admin...', $tester->getDisplay()); |
59 | $this->assertContains('Done', $tester->getDisplay()); | ||
59 | } | 60 | } |
60 | } | 61 | } |