Merge pull request #97 from fkraefft/fix-traits

Fix in Test Repository use method.
This commit is contained in:
Nuno Maduro
2020-06-17 18:47:00 +02:00
committed by GitHub
5 changed files with 23 additions and 3 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ coverage.xml
.temp/coverage.php
*.swp
*.swo
.vscode/

View File

@ -104,7 +104,14 @@ final class TestRepository
}
foreach ($paths as $path) {
$this->uses[$path] = [$classOrTraits, $groups];
if (array_key_exists($path, $this->uses)) {
$this->uses[$path] = [
array_merge($this->uses[$path][0], $classOrTraits),
array_merge($this->uses[$path][1], $groups),
];
} else {
$this->uses[$path] = [$classOrTraits, $groups];
}
}
}

View File

@ -101,6 +101,7 @@
PASS Tests\Plugins\Traits
✓ it allows global uses
✓ it allows multiple global uses registered in the same path
PASS Tests\Unit\Actions\AddsDefaults
✓ it sets defaults
@ -143,5 +144,5 @@
WARN Tests\Visual\Success
s visual snapshot of test suite on success
Tests: 6 skipped, 78 passed
Time: 3.09s
Tests: 6 skipped, 79 passed
Time: 3.44s

View File

@ -12,4 +12,13 @@ trait PluginTrait
}
}
trait SecondPluginTrait
{
public function assertSecondPluginTraitGotRegistered(): void
{
assertTrue(true);
}
}
Pest\Plugin::uses(PluginTrait::class);
Pest\Plugin::uses(SecondPluginTrait::class);

View File

@ -1,3 +1,5 @@
<?php
it('allows global uses')->assertPluginTraitGotRegistered();
it('allows multiple global uses registered in the same path')->assertSecondPluginTraitGotRegistered();