Skip to content

Commit

Permalink
Merge pull request #14 from CameronHall/phpcs-fixes
Browse files Browse the repository at this point in the history
PHPCS fixes
  • Loading branch information
CameronHall committed Oct 27, 2019
2 parents 0cfc472 + dea7667 commit b3260ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/Parser.php
Expand Up @@ -230,5 +230,4 @@ public function getParsedCommands(): array
{
return $this->parsedCommands;
}

}
26 changes: 16 additions & 10 deletions tests/ParserTest.php
Expand Up @@ -69,7 +69,7 @@ public function shouldTransformParamsToBool($params, $expect)
$this->assertEquals($expect, $this->parser->getBoolean($params['key'], $params['default']));
}

public function testGetParsedCommands_shouldReturnAnEmptyArrayIfObjectIsFresh()
public function testGetParsedCommandsShouldReturnEmptyArrayOnNewObject()
{
$parser = new Parser();
$this->assertEmpty(
Expand All @@ -85,7 +85,7 @@ public function testGetParsedCommands_shouldReturnAnEmptyArrayIfObjectIsFresh()
* @param array $params
* @param array $expect
*/
public function testGetParsedCommands_shouldReturnParsedCommand(array $params, array $expect)
public function testGetParsedCommandsShouldReturnParsedCommand(array $params, array $expect)
{
$this->parser->parse($params["command"]);
$this->assertEquals(
Expand All @@ -96,7 +96,8 @@ public function testGetParsedCommands_shouldReturnParsedCommand(array $params, a
$this->parser->parse(["script-with-no-parameters"]);
$this->assertEmpty(
$this->parser->getParsedCommands(),
"Parser state should be modified absolutely, if overridden by another parse call."
"Parser state should be modified absolutely,
if overridden by another parse call."
);

$this->parser->parse($params["command"]);
Expand All @@ -114,7 +115,7 @@ public function testGetParsedCommands_shouldReturnParsedCommand(array $params, a
* @param array $params
* @param array $expect
*/
public function testGet_returnsBoundDefaultValueIfValueNotSet(array $params, array $expect)
public function testGetReturnsBoundDefaultValueIfNotSet(array $params, array $expect)
{
$expectedDefaultValues = [
123,
Expand All @@ -123,13 +124,15 @@ public function testGet_returnsBoundDefaultValueIfValueNotSet(array $params, arr
true,
new stdClass()
];

$nonExistingParameterKey = "non-existing-parameter-key";

foreach ($expectedDefaultValues as $expectedDefaultValue) {
$this->assertEquals(
$expectedDefaultValue,
$this->parser->get($nonExistingParameterKey, $expectedDefaultValue),
"Should return the provided default value, if the queried parameter doesn't exist in an empty/fresh object."
"Should return the provided default value,
if the queried parameter doesn't exist in an empty/fresh object."
);
}

Expand All @@ -139,7 +142,8 @@ public function testGet_returnsBoundDefaultValueIfValueNotSet(array $params, arr
$this->assertEquals(
$expectedDefaultValue,
$this->parser->get($nonExistingParameterKey, $expectedDefaultValue),
"Should return null, if the queried parameter doesn't exist in a populated/parsed object."
"Should return null,
if the queried parameter doesn't exist in a populated/parsed object."
);
}
}
Expand All @@ -151,18 +155,20 @@ public function testGet_returnsBoundDefaultValueIfValueNotSet(array $params, arr
* @param array $params
* @param array $expect
*/
public function testGet_returnsNullIfParamDoesNotExist(array $params, array $expect)
public function testGetReturnsNullIfParamDoesNotExist(array $params, array $expect)
{
$nonExistingParameterKey = "non-existing-parameter-key";
$this->assertNull(
$this->parser->get($nonExistingParameterKey),
"Should return null, if the queried parameter doesn't exist in an empty/fresh object."
"Should return null,
if the queried parameter doesn't exist in an empty/fresh object."
);

$this->parser->parse($params["command"]);
$this->assertNull(
$this->parser->get($nonExistingParameterKey),
"Should return null, if the queried parameter doesn't exist in a populated/parsed object."
"Should return null,
if the queried parameter doesn't exist in a populated/parsed object."
);
}

Expand All @@ -173,7 +179,7 @@ public function testGet_returnsNullIfParamDoesNotExist(array $params, array $exp
* @param array $params
* @param array $expect
*/
public function testGet_returnsValueIfParamDoesExist(array $params, array $expect)
public function testGetReturnsValueIfParamDoesExist(array $params, array $expect)
{
$this->parser->parse($params["command"]);
foreach ($expect as $parameterKey => $expectedValue) {
Expand Down

0 comments on commit b3260ed

Please sign in to comment.