Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a4ac1a7

Browse filesBrowse files
committed
minor #20817 [Console] improved code coverage of Command class (ShinDarth)
This PR was squashed before being merged into the 2.7 branch (closes #20817). Discussion ---------- [Console] improved code coverage of Command class | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT This PR increases the code coverage of the Command class from ``86.82%`` to ``96.90%``. Commits ------- d393113 [Console] improved code coverage of Command class
2 parents 9f18585 + d393113 commit a4ac1a7
Copy full SHA for a4ac1a7

File tree

Expand file treeCollapse file tree

1 file changed

+37
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+37
-2
lines changed

‎src/Symfony/Component/Console/Tests/Command/CommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Command/CommandTest.php
+37-2Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public function testSetApplication()
5454
$command = new \TestCommand();
5555
$command->setApplication($application);
5656
$this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application');
57+
$this->assertEquals($application->getHelperSet(), $command->getHelperSet());
58+
}
59+
60+
public function testSetApplicationNull()
61+
{
62+
$command = new \TestCommand();
63+
$command->setApplication(null);
64+
$this->assertNull($command->getHelperSet());
5765
}
5866

5967
public function testSetGetDefinition()
@@ -156,6 +164,13 @@ public function testGetSetAliases()
156164
$this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases');
157165
}
158166

167+
public function testSetAliasesNull()
168+
{
169+
$command = new \TestCommand();
170+
$this->setExpectedException('InvalidArgumentException');
171+
$command->setAliases(null);
172+
}
173+
159174
public function testGetSynopsis()
160175
{
161176
$command = new \TestCommand();
@@ -164,6 +179,15 @@ public function testGetSynopsis()
164179
$this->assertEquals('namespace:name [--foo] [--] [<bar>]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
165180
}
166181

182+
public function testAddGetUsages()
183+
{
184+
$command = new \TestCommand();
185+
$command->addUsage('foo1');
186+
$command->addUsage('foo2');
187+
$this->assertContains('namespace:name foo1', $command->getUsages());
188+
$this->assertContains('namespace:name foo2', $command->getUsages());
189+
}
190+
167191
public function testGetHelper()
168192
{
169193
$application = new Application();
@@ -275,8 +299,8 @@ public function testRunReturnsIntegerExitCode()
275299

276300
$command = $this->getMockBuilder('TestCommand')->setMethods(array('execute'))->getMock();
277301
$command->expects($this->once())
278-
->method('execute')
279-
->will($this->returnValue('2.3'));
302+
->method('execute')
303+
->will($this->returnValue('2.3'));
280304
$exitCode = $command->run(new StringInput(''), new NullOutput());
281305
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
282306
}
@@ -297,6 +321,17 @@ public function testRunReturnsAlwaysInteger()
297321
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
298322
}
299323

324+
public function testRunWithProcessTitle()
325+
{
326+
$command = new \TestCommand();
327+
$command->setApplication(new Application());
328+
$command->setProcessTitle('foo');
329+
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
330+
if (function_exists('cli_set_process_title')) {
331+
$this->assertEquals('foo', cli_get_process_title());
332+
}
333+
}
334+
300335
public function testSetCode()
301336
{
302337
$command = new \TestCommand();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.