Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 70aab5e

Browse files
committed
MC-2338: 3rd party library/dependency upgrade for 2.3 pre Alpha
1 parent 5ef85a9 commit 70aab5e

File tree

1 file changed

+85
-35
lines changed

1 file changed

+85
-35
lines changed

app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php

Lines changed: 85 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,100 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Developer\Test\Unit\Console\Command;
7+
// @codingStandardsIgnoreStart
88

9-
use Magento\Developer\Console\Command\DevTestsRunCommand;
10-
use Symfony\Component\Console\Tester\CommandTester;
9+
namespace Magento\Developer\Console\Command {
10+
use Symfony\Component\Console\Tester\CommandTester;
1111

12-
/**
13-
* Class DevTestsRunCommandTest
14-
*
15-
* Tests dev:tests:run command. Only tests error case because DevTestsRunCommand calls phpunit with
16-
* passthru, so there is no good way to mock out running the tests.
17-
*/
18-
class DevTestsRunCommandTest extends \PHPUnit\Framework\TestCase
19-
{
12+
$devTestsRunCommandTestPassthruReturnVar = null;
2013

2114
/**
22-
* @var DevTestsRunCommand
15+
* Mock for PHP builtin passthtru function
16+
*
17+
* @param string $command
18+
* @param int|null $return_var
19+
* @return void
2320
*/
24-
private $command;
25-
26-
protected function setUp()
21+
function passthru($command, &$return_var = null)
2722
{
28-
$this->command = new DevTestsRunCommand();
23+
global $devTestsRunCommandTestPassthruReturnVar;
24+
$return_var = $devTestsRunCommandTestPassthruReturnVar;
2925
}
3026

31-
public function testExecuteBadType()
27+
/**
28+
* Class DevTestsRunCommandTest
29+
*
30+
* Tests dev:tests:run command. Only tests error case because DevTestsRunCommand calls phpunit with
31+
* passthru, so there is no good way to mock out running the tests.
32+
*/
33+
class DevTestsRunCommandTest extends \PHPUnit\Framework\TestCase
3234
{
33-
$commandTester = new CommandTester($this->command);
34-
$commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']);
35-
$this->assertContains('Invalid type: "bad"', $commandTester->getDisplay());
36-
}
3735

38-
public function testPassArgumentsToPHPUnit()
39-
{
40-
$commandTester = new CommandTester($this->command);
41-
$commandTester->execute(
42-
[
43-
DevTestsRunCommand::INPUT_ARG_TYPE => 'unit',
44-
'-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites',
45-
]
46-
);
47-
$this->assertContains(
48-
'phpunit --list-suites',
49-
$commandTester->getDisplay(),
50-
'Parameters should be passed to PHPUnit'
51-
);
36+
/**
37+
* @var DevTestsRunCommand
38+
*/
39+
private $command;
40+
41+
protected function setUp()
42+
{
43+
$this->command = new DevTestsRunCommand();
44+
}
45+
46+
public function testExecuteBadType()
47+
{
48+
$commandTester = new CommandTester($this->command);
49+
$commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']);
50+
$this->assertContains('Invalid type: "bad"', $commandTester->getDisplay());
51+
}
52+
53+
public function testPassArgumentsToPHPUnit()
54+
{
55+
global $devTestsRunCommandTestPassthruReturnVar;
56+
57+
$devTestsRunCommandTestPassthruReturnVar = 0;
58+
59+
$commandTester = new CommandTester($this->command);
60+
$commandTester->execute(
61+
[
62+
DevTestsRunCommand::INPUT_ARG_TYPE => 'unit',
63+
'-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites',
64+
]
65+
);
66+
$this->assertContains(
67+
'phpunit --list-suites',
68+
$commandTester->getDisplay(),
69+
'Parameters should be passed to PHPUnit'
70+
);
71+
$this->assertContains(
72+
'PASSED (',
73+
$commandTester->getDisplay(),
74+
'PHPUnit runs should have passed'
75+
);
76+
}
77+
78+
public function testPassArgumentsToPHPUnitNegative()
79+
{
80+
global $devTestsRunCommandTestPassthruReturnVar;
81+
82+
$devTestsRunCommandTestPassthruReturnVar = 255;
83+
84+
$commandTester = new CommandTester($this->command);
85+
$commandTester->execute(
86+
[
87+
DevTestsRunCommand::INPUT_ARG_TYPE => 'unit',
88+
'-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites',
89+
]
90+
);
91+
$this->assertContains(
92+
'phpunit --list-suites',
93+
$commandTester->getDisplay(),
94+
'Parameters should be passed to PHPUnit'
95+
);
96+
$this->assertContains(
97+
'FAILED - ',
98+
$commandTester->getDisplay(),
99+
'PHPUnit runs should have passed'
100+
);
101+
}
52102
}
53103
}

0 commit comments

Comments
 (0)