Skip to content

Commit

Permalink
Add Environment Name To Descriptor Unique Signatures (#5294)
Browse files Browse the repository at this point in the history
* src/Codeception/Test/Descriptor.php: getTestSignatureUnique

- add the current environment name to unique signatures
- closes Codeception/phpunit-wrapper#4

* src/Codeception/Test/Descriptor.php: getTestSignatureUnique()

Issue: Codeception/phpunit-wrapper#4

- initialise $env and $example as empty strings
- keep empty string values for concatenation if there's no scenario or example
  • Loading branch information
Tenzian authored and Naktibalda committed Dec 19, 2018
1 parent 81fe604 commit 9f08d77
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Codeception/Test/Descriptor.php
Expand Up @@ -32,15 +32,22 @@ public static function getTestSignature(\PHPUnit\Framework\SelfDescribing $testC
*/
public static function getTestSignatureUnique(\PHPUnit\Framework\SelfDescribing $testCase)
{
$example = null;
$env = '';
$example = '';

if (method_exists($testCase, 'getScenario')
&& !empty($testCase->getScenario()->current('env'))
) {
$env = ':' . $testCase->getScenario()->current('env');
}

if (method_exists($testCase, 'getMetaData')
&& $example = $testCase->getMetadata()->getCurrent('example')
&& !empty($testCase->getMetadata()->getCurrent('example'))
) {
$example = ':' . substr(sha1(json_encode($example)), 0, 7);
$example = ':' . substr(sha1(json_encode($testCase->getMetadata()->getCurrent('example'))), 0, 7);
}

return self::getTestSignature($testCase) . $example;
return self::getTestSignature($testCase) . $env . $example;
}

public static function getTestAsString(\PHPUnit\Framework\SelfDescribing $testCase)
Expand Down

0 comments on commit 9f08d77

Please sign in to comment.