]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add basic tests
authorThomas Citharel <tcit@tcit.fr>
Thu, 30 Mar 2017 15:02:10 +0000 (17:02 +0200)
committerThomas Citharel <tcit@tcit.fr>
Mon, 1 May 2017 11:04:31 +0000 (13:04 +0200)
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php [new file with mode: 0644]

diff --git a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php
new file mode 100644 (file)
index 0000000..9939d43
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+namespace Tests\Wallabag\CoreBundle\Command;
+
+use Symfony\Bundle\FrameworkBundle\Console\Application;
+use Symfony\Component\Console\Tester\CommandTester;
+use Wallabag\CoreBundle\Command\CleanDuplicatesCommand;
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+
+class CleanDuplicatesCommandTest extends WallabagCoreTestCase
+{
+    public function testRunTagAllCommandForAll()
+    {
+        $application = new Application($this->getClient()->getKernel());
+        $application->add(new CleanDuplicatesCommand());
+
+        $command = $application->find('wallabag:clean-duplicates');
+
+        $tester = new CommandTester($command);
+        $tester->execute([
+            'command' => $command->getName(),
+        ]);
+
+        $this->assertContains('Cleaning through 3 user accounts', $tester->getDisplay());
+        $this->assertContains('Finished cleaning. 0 duplicates found in total', $tester->getDisplay());
+    }
+
+    public function testRunTagAllCommandWithBadUsername()
+    {
+        $application = new Application($this->getClient()->getKernel());
+        $application->add(new CleanDuplicatesCommand());
+
+        $command = $application->find('wallabag:clean-duplicates');
+
+        $tester = new CommandTester($command);
+        $tester->execute([
+            'command' => $command->getName(),
+            'username' => 'unknown',
+        ]);
+
+        $this->assertContains('User "unknown" not found', $tester->getDisplay());
+    }
+
+    public function testRunTagAllCommandForUser()
+    {
+        $application = new Application($this->getClient()->getKernel());
+        $application->add(new CleanDuplicatesCommand());
+
+        $command = $application->find('wallabag:clean-duplicates');
+
+        $tester = new CommandTester($command);
+        $tester->execute([
+            'command' => $command->getName(),
+            'username' => 'admin',
+        ]);
+
+        $this->assertContains('Cleaned 0 duplicates for user admin', $tester->getDisplay());
+    }
+}