2016-01-21 15:36:17 +00:00
|
|
|
<?php
|
|
|
|
|
2016-06-01 19:27:35 +00:00
|
|
|
namespace Tests\Wallabag\CoreBundle\Command;
|
2016-01-21 15:36:17 +00:00
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
2016-06-01 19:27:35 +00:00
|
|
|
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
|
2017-07-01 07:52:38 +00:00
|
|
|
use Wallabag\CoreBundle\Command\TagAllCommand;
|
2016-01-21 15:36:17 +00:00
|
|
|
|
|
|
|
class TagAllCommandTest extends WallabagCoreTestCase
|
|
|
|
{
|
|
|
|
public function testRunTagAllCommandWithoutUsername()
|
|
|
|
{
|
2020-06-15 11:37:50 +00:00
|
|
|
$this->expectException(\Symfony\Component\Console\Exception\RuntimeException::class);
|
|
|
|
$this->expectExceptionMessage('Not enough arguments (missing: "username")');
|
|
|
|
|
2016-01-21 15:36:17 +00:00
|
|
|
$application = new Application($this->getClient()->getKernel());
|
|
|
|
$application->add(new TagAllCommand());
|
|
|
|
|
|
|
|
$command = $application->find('wallabag:tag:all');
|
|
|
|
|
|
|
|
$tester = new CommandTester($command);
|
2016-04-12 09:36:01 +00:00
|
|
|
$tester->execute([
|
2016-01-21 15:36:17 +00:00
|
|
|
'command' => $command->getName(),
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2016-01-21 15:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testRunTagAllCommandWithBadUsername()
|
|
|
|
{
|
|
|
|
$application = new Application($this->getClient()->getKernel());
|
|
|
|
$application->add(new TagAllCommand());
|
|
|
|
|
|
|
|
$command = $application->find('wallabag:tag:all');
|
|
|
|
|
|
|
|
$tester = new CommandTester($command);
|
2016-04-12 09:36:01 +00:00
|
|
|
$tester->execute([
|
2016-01-21 15:36:17 +00:00
|
|
|
'command' => $command->getName(),
|
|
|
|
'username' => 'unknown',
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2016-01-21 15:36:17 +00:00
|
|
|
|
2020-06-15 11:37:50 +00:00
|
|
|
$this->assertStringContainsString('User "unknown" not found', $tester->getDisplay());
|
2016-01-21 15:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testRunTagAllCommand()
|
|
|
|
{
|
|
|
|
$application = new Application($this->getClient()->getKernel());
|
|
|
|
$application->add(new TagAllCommand());
|
|
|
|
|
|
|
|
$command = $application->find('wallabag:tag:all');
|
|
|
|
|
|
|
|
$tester = new CommandTester($command);
|
2016-04-12 09:36:01 +00:00
|
|
|
$tester->execute([
|
2016-01-21 15:36:17 +00:00
|
|
|
'command' => $command->getName(),
|
|
|
|
'username' => 'admin',
|
2016-04-12 09:36:01 +00:00
|
|
|
]);
|
2016-01-21 15:36:17 +00:00
|
|
|
|
2020-06-15 11:37:50 +00:00
|
|
|
$this->assertStringContainsString('Tagging entries for user admin...', $tester->getDisplay());
|
|
|
|
$this->assertStringContainsString('Done', $tester->getDisplay());
|
2016-01-21 15:36:17 +00:00
|
|
|
}
|
|
|
|
}
|