When a test created with "it", the depends function doesn't work.
````php
it('can create a converter', function () {
$factory = new ConverterFactory();
$factory->register('md', MarkdownConverter::class);
$converter = $factory->createConverter('md');
expect($converter)->toBeInstanceOf(MarkdownConverter::class);
return $converter;
});
it('can convert markdown', function ($converter) {
$html = $converter->convert('TEST');
expect($html)->toBe('
TEST
');````
WARN Tests\Core\Infrastructure\Converter\ConverterFactoryTest
โ it can create a converter
! it can convert markdown โ This test depends on "P\Tests\Core\Infrastructure\Converter\ConverterFactoryTest::can create a converter" which does not exist.
Tests: 1 warnings, 1 passed
Time: 0.24s
````
Leaving "it" out of the testname doesn't work, but adding "it" twice to the testname works:
php
it('can convert markdown', function ($converter) {
$html = $converter->convert('**TEST**');
expect($html)->toBe('<p><strong>TEST</strong></p>');
})->depends('it it can create a converter');
````
PASS Tests\Core\Infrastructure\Converter\ConverterFactoryTest
โ it can create a converter
โ it can convert markdown
Tests: 2 passed
Time: 0.29s
````
Sorry it's taken so long to reply, I was able to replicate this issue. It looks like this is due to our use of ExecutionOrderDependency in the TestCall object.
The createFromDependsAnnotation call splits the string by a space, which allows support for "clone options".
We should create our own version of this method that doesn't split the call. ๐๐ป Basically just replace the array_map() in TestCall::depends() with:
$tests = array_map(function (string $test) use ($className): ExecutionOrderDependency {
if (strpos($test, '::') === false) {
$test = "{$className}::{$test}";
}
return new ExecutionOrderDependency($test, null, '');
}, $tests);
I've opened #216 to resolve this issue.
Most helpful comment
Sorry it's taken so long to reply, I was able to replicate this issue. It looks like this is due to our use of
ExecutionOrderDependencyin the TestCall object.The
createFromDependsAnnotationcall splits the string by a space, which allows support for "clone options".We should create our own version of this method that doesn't split the call. ๐๐ป Basically just replace the
array_map()inTestCall::depends()with:I've opened #216 to resolve this issue.