Skip to content

Commit eb04f46

Browse files
committed
Fix reference in changelog
1 parent b941c50 commit eb04f46

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66
## Unreleased
77
* ...
88

9+
## 0.1.4 [2020-06-12]
10+
* Add `prepareCommandTester`, to be used in place of `runCommand` to obtain the `CommandTester` before the `execute` call [b941c50](https://github.com/facile-it/symfony-functional-testcase/commit/b941c500a270acdd34c8479440d3c710ca667d1f)
11+
912
## 0.1.3 [2020-03-27]
1013
* Fix Symfony 5 compatibility [#3](https://github.com/facile-it/symfony-functional-testcase/pull/3)
1114
* Improve CI testing [#3](https://github.com/facile-it/symfony-functional-testcase/pull/3)

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ parameters:
99
message: "#^Parameter \\#1 \\$callable of static method Doctrine\\\\Common\\\\Annotations\\\\AnnotationRegistry\\:\\:registerLoader\\(\\) expects callable\\(\\)\\: mixed, array\\(mixed, 'loadClass'\\) given\\.$#"
1010
count: 1
1111
path: tests/App/bootstrap.php
12+
13+
-
14+
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNull\\(\\) with int will always evaluate to false\\.$#"
15+
count: 1
16+
path: tests/Command/CommandTest.php

src/WebTestCase.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ abstract class WebTestCase extends BaseWebTestCase
2525
protected $containers = [];
2626

2727
/**
28-
* Builds up the environment to run the given command.
29-
*
30-
* @param array<string, mixed> $params
28+
* Returns a CommandTester for the console command with the provided name.
29+
* It allows to reuse the same kernel that the test uses, so that you can
30+
* reach in if needed.
3131
*/
32-
protected function runCommand(string $name, array $params = [], bool $reuseKernel = false): CommandTester
32+
protected function prepareCommandTester(string $name, bool $reuseKernel = false): CommandTester
3333
{
3434
if (! $reuseKernel) {
3535
if (null !== static::$kernel) {
@@ -44,11 +44,21 @@ protected function runCommand(string $name, array $params = [], bool $reuseKerne
4444
}
4545

4646
$application = new Application($kernel);
47-
4847
$command = $application->find($name);
49-
$commandTester = new CommandTester($command);
48+
49+
return new CommandTester($command);
50+
}
51+
52+
/**
53+
* Builds up the environment to run the given command.
54+
*
55+
* @param array<string, mixed> $params
56+
*/
57+
protected function runCommand(string $name, array $params = [], bool $reuseKernel = false): CommandTester
58+
{
59+
$commandTester = $this->prepareCommandTester($name, $reuseKernel);
5060
$commandTester->execute(
51-
array_merge(['command' => $command->getName()], $params),
61+
$params,
5262
[
5363
'interactive' => false,
5464
]

tests/Command/CommandTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,12 @@ public function testRunCommandStatusCode(): void
5858

5959
$this->assertSame(10, $commandTester->getStatusCode());
6060
}
61+
62+
public function testPrepareCommandTester(): void
63+
{
64+
$commandTester = $this->prepareCommandTester('facileitsymfonyfunctionaltestcase:test-status-code');
65+
66+
$this->assertInstanceOf(CommandTester::class, $commandTester);
67+
$this->assertNull($commandTester->getStatusCode());
68+
}
6169
}

0 commit comments

Comments
 (0)