Skip to content

Commit

Permalink
Fix file not found exception for Codeception Cests (from branch 0.21)
Browse files Browse the repository at this point in the history
  • Loading branch information
agilov authored and maks-rafalko committed Mar 31, 2021
1 parent 2ca5fd6 commit cee1ab7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ private static function testCaseMapGenerator(string $fullyQualifiedClassName): i

// A format where the class name is inside `file` attribute of `testcase` tag
yield '//testcase[contains(@file, "%s")][1]' => preg_replace('/^(.*):+.*$/', '$1.feature', $fullyQualifiedClassName);

// A format where the class name parsed from feature and is inside `class` attribute of `testcase` tag
yield '//testcase[@class="%s"][1]' => preg_replace('/^(.*):+.*$/', '$1', $fullyQualifiedClassName);
}

private function getXPath(): SafeDOMXPath
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="acceptance" tests="3" assertions="10" errors="0" failures="0" skipped="0" time="0.000003">
<testcase file="/app/controllers/ExampleCest.php" name="FeatureA" class="app\controllers\ExampleCest" feature="featureA" assertions="2" time="0.000001"/>
<testcase file="/app/controllers/ExampleCest.php" name="FeatureB" class="app\controllers\ExampleCest" feature="featureB" assertions="1" time="0.000001"/>
<testcase file="/app/controllers/ExampleCest.php" name="FeatureC" class="app\controllers\ExampleCest" feature="featureC" assertions="7" time="0.000001"/>
</testsuite>
</testsuites>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ final class JUnitTestFileDataProviderTest extends TestCase
private const JUNIT = __DIR__ . '/../../../Fixtures/Files/phpunit/junit.xml';
private const JUNIT_DIFF_FORMAT = __DIR__ . '/../../../Fixtures/Files/phpunit/junit2.xml';
private const JUNIT_FEATURE_FORMAT = __DIR__ . '/../../../Fixtures/Files/phpunit/junit_feature.xml';
private const JUNIT_CODECEPTION_CEST_FORMAT = __DIR__ . '/../../../Fixtures/Files/phpunit/junit_codeception_cest.xml';

/**
* @var JUnitReportLocator|MockObject
Expand Down Expand Up @@ -145,6 +146,18 @@ public function test_it_works_with_feature_junit_format(): void
$this->assertSame('/codeception/tests/bdd/FeatureA.feature', $testFileInfo->path);
}

public function test_it_works_with_codeception_cest_format(): void
{
$this->jUnitLocatorMock
->method('locate')
->willReturn(self::JUNIT_CODECEPTION_CEST_FORMAT)
;

$testFileInfo = $this->provider->getTestFileInfo('app\controllers\ExampleCest:FeatureA');

$this->assertSame('/app/controllers/ExampleCest.php', $testFileInfo->path);
}

/**
* @dataProvider xmlProvider
*/
Expand Down

0 comments on commit cee1ab7

Please sign in to comment.