This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
increase mutation coverage tests (#77)
* add exception tests * add unit test for parseTableNode * fix lint issue * remove unused spy in exception unit tests * close mockery after tests * remove final keyword for testability * add _beforeStep unit tests * suppress PHPMD.StaticAccess on Mockery::close() * downgrade msi to 70 * fix lint warnings
- Loading branch information
Showing
6 changed files
with
141 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
use \Behat\Gherkin\Node\TableNode; | ||
use \Codeception\Step; | ||
|
||
/** | ||
* Happy path unit tests | ||
* | ||
* @SuppressWarnings(PHPMD.CamelCaseMethodName) | ||
*/ | ||
class GherkinParamTest extends \Codeception\Test\Unit | ||
{ | ||
|
||
/** | ||
* @var \UnitTester | ||
*/ | ||
protected $module; | ||
protected $fixture; | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
protected function _before(): void | ||
{ | ||
$moduleInstance = $this->getModule( | ||
'Codeception\Extension\GherkinParam' | ||
); | ||
|
||
$this->module = Mockery::spy($moduleInstance); | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
protected function _after(): void | ||
{ | ||
Mockery::close(); | ||
} | ||
|
||
public function testBeforeStepCallsGetValueFromParamWhenStepParamIsString(): void | ||
{ | ||
$step = new Step\Action('test', ['test']); | ||
|
||
$this->module->_beforeStep($step); | ||
|
||
$this->module->shouldHaveReceived('getValueFromParam', ['test']); | ||
} | ||
|
||
public function testBeforeStepCallsParseTableNodeWhenStepParamIsTableNode(): void | ||
{ | ||
$param = new TableNode([1 => ['foo', 'bar', 'baz']]); | ||
$step = new Step\Action('test', [$param]); | ||
|
||
$this->module->_beforeStep($step); | ||
|
||
$this->module->shouldHaveReceived('parseTableNode', [$param]); | ||
} | ||
|
||
public function testBeforeStepIteratesGetValueFromParamWhenStepParamIsArray(): void | ||
{ | ||
$param = ['foo', 'bar', 'baz']; | ||
$step = new Step\Action('test', [$param]); | ||
|
||
$this->module->_beforeStep($step); | ||
|
||
$this->module->shouldHaveReceived('getValueFromParam', ['foo']); | ||
$this->module->shouldHaveReceived('getValueFromParam', ['bar']); | ||
$this->module->shouldHaveReceived('getValueFromParam', ['baz']); | ||
} | ||
|
||
public function testParseTableNodeReturnsValuedTableNode(): void | ||
{ | ||
$input = new TableNode([1 => ['foo', 'bar', 'baz']]); | ||
|
||
$tableNode = $this->module | ||
->parseTableNode($input); | ||
|
||
$this->assertEquals($input, $tableNode); | ||
} | ||
} |