Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix in Test Repository use method. #97

Merged
merged 4 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ coverage.xml
.temp/coverage.php
*.swp
*.swo
.vscode/
9 changes: 8 additions & 1 deletion src/Repositories/TestRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ public function use(array $classOrTraits, array $groups, array $paths): void
}

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];
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/.snapshots/success.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions tests/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ public function assertPluginTraitGotRegistered(): void
}
}

trait SecondPluginTrait
{
public function assertSecondPluginTraitGotRegistered(): void
{
assertTrue(true);
}
}

Pest\Plugin::uses(PluginTrait::class);
Pest\Plugin::uses(SecondPluginTrait::class);
2 changes: 2 additions & 0 deletions tests/Plugins/Traits.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php

it('allows global uses')->assertPluginTraitGotRegistered();

it('allows multiple global uses registered in the same path')->assertSecondPluginTraitGotRegistered();