aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Command/ListUserCommandTest.php
blob: 9068cf5935ef7b8a4e01ed5e8c55a152af5c544e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

namespace Tests\Wallabag\CoreBundle\Command;

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Command\ListUserCommand;

class ListUserCommandTest extends WallabagCoreTestCase
{
    public function testRunListUserCommand()
    {
        $application = new Application($this->getClient()->getKernel());
        $application->add(new ListUserCommand());

        $command = $application->find('wallabag:user:list');

        $tester = new CommandTester($command);
        $tester->execute([
            'command' => $command->getName(),
        ]);

        $this->assertContains('3/3 user(s) displayed.', $tester->getDisplay());
    }

    public function testRunListUserCommandWithLimit()
    {
        $application = new Application($this->getClient()->getKernel());
        $application->add(new ListUserCommand());

        $command = $application->find('wallabag:user:list');

        $tester = new CommandTester($command);
        $tester->execute([
            'command' => $command->getName(),
            '--limit' => 2,
        ]);

        $this->assertContains('2/3 user(s) displayed.', $tester->getDisplay());
    }

    public function testRunListUserCommandWithSearch()
    {
        $application = new Application($this->getClient()->getKernel());
        $application->add(new ListUserCommand());

        $command = $application->find('wallabag:user:list');

        $tester = new CommandTester($command);
        $tester->execute([
            'command' => $command->getName(),
            'search' => 'boss',
        ]);

        $this->assertContains('1/3 (filtered) user(s) displayed.', $tester->getDisplay());
    }

    public function testRunListUserCommandWithSearchAndLimit()
    {
        $application = new Application($this->getClient()->getKernel());
        $application->add(new ListUserCommand());

        $command = $application->find('wallabag:user:list');

        $tester = new CommandTester($command);
        $tester->execute([
            'command' => $command->getName(),
            'search' => 'bo',
            '--limit' => 1,
        ]);

        $this->assertContains('1/3 (filtered) user(s) displayed.', $tester->getDisplay());
    }
}