Passed
Push — master ( 1cf0a9...56b73d )
by Ayan
01:37
created

GetTest::testDisplayedData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php namespace Phprest\Command\Route;
2
3
use Phprest\Application as PhprestApp;
4
use Phprest\Config;
5
use PHPUnit\Framework\TestCase;
6
use Symfony\Component\Console\Application as ConsoleApp;
7
use Symfony\Component\Console\Tester\CommandTester;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class GetTest extends TestCase
11
{
12
    public function testDisplayedData(): void
13
    {
14
        $phprestApp = new PhprestApp(new Config('phprest-test', '2.3', true));
15
        $phprestApp->get('/2.3/get-the-answer-of-everything', 'Phprest\Stub\Controller::getTheAnswerOfEverything');
16
        $phprestApp->get('/2.3/get-welcome-message', static function () {
17
            return new Response('Welcome!');
18
        });
19
20
        $cliApp = new ConsoleApp();
21
        $cliApp->add(new Get($phprestApp));
22
23
        $command = $cliApp->find('routes:get');
24
        $commandTester = new CommandTester($command);
25
        $commandTester->execute(['command' => $command->getName()]);
26
27
        $displayedData = $commandTester->getDisplay();
28
29
        $this->assertContains(
30
            '| GET    | /2.3/get-the-answer-of-everything | Phprest\Stub\Controller::getTheAnswerOfEverything |',
31
            $displayedData
32
        );
33
        $this->assertContains(
34
            '| GET    | /2.3/get-welcome-message          | Closure                                           |',
35
            $displayedData
36
        );
37
    }
38
}
39