1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the PHP Translation package. |
5
|
|
|
* |
6
|
|
|
* (c) PHP Translation team <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Translation\Bundle\Tests\Functional\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
15
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
16
|
|
|
use Translation\Bundle\Command\StatusCommand; |
17
|
|
|
use Translation\Bundle\Tests\Functional\BaseTestCase; |
18
|
|
|
|
19
|
|
|
class StatusCommandTest extends BaseTestCase |
20
|
|
|
{ |
21
|
|
|
protected function setUp(): void |
22
|
|
|
{ |
23
|
|
|
parent::setUp(); |
24
|
|
|
$this->kernel->addConfigFile(__DIR__.'/../app/config/normal_config.yaml'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testExecute(): void |
28
|
|
|
{ |
29
|
|
|
$this->bootKernel(); |
30
|
|
|
$application = new Application($this->kernel); |
31
|
|
|
|
32
|
|
|
$container = $this->getContainer(); |
33
|
|
|
$application->add($container->get(StatusCommand::class)); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$command = $application->find('translation:status'); |
36
|
|
|
$commandTester = new CommandTester($command); |
37
|
|
|
$commandTester->execute([ |
38
|
|
|
'command' => $command->getName(), |
39
|
|
|
'configuration' => 'app', |
40
|
|
|
'locale' => 'en', |
41
|
|
|
'--json' => true, |
42
|
|
|
]); |
43
|
|
|
|
44
|
|
|
// the output of the command in the console |
45
|
|
|
$output = $commandTester->getDisplay(); |
46
|
|
|
$data = \json_decode($output, true); |
47
|
|
|
|
48
|
|
|
$this->assertArrayHasKey('en', $data); |
49
|
|
|
$this->assertArrayHasKey('messages', $data['en']); |
50
|
|
|
$this->assertArrayHasKey('_total', $data['en']); |
51
|
|
|
|
52
|
|
|
$total = $data['en']['_total']; |
53
|
|
|
$this->assertArrayHasKey('defined', $total); |
54
|
|
|
$this->assertArrayHasKey('new', $total); |
55
|
|
|
$this->assertArrayHasKey('obsolete', $total); |
56
|
|
|
$this->assertArrayHasKey('approved', $total); |
57
|
|
|
$this->assertEquals(2, $total['defined']); |
58
|
|
|
$this->assertEquals(1, $total['new']); |
59
|
|
|
$this->assertEquals(0, $total['obsolete']); |
60
|
|
|
$this->assertEquals(1, $total['approved']); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|