mirror of
https://github.com/pestphp/pest.git
synced 2026-07-22 09:30:02 +02:00
40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
|
|
use Pest\Arch\Exceptions\ArchExpectationFailedException;
|
|
use Pest\Concerns\Retrievable;
|
|
use Pest\Expectations\EachExpectation;
|
|
use Pest\Expectations\HigherOrderExpectation;
|
|
use Tests\Fixtures\Arch\ToUseTrait\HasInheritedTrait\ChildClassExtendingParent;
|
|
use Tests\Fixtures\Arch\ToUseTrait\HasNestedTrait\NestedTrait;
|
|
use Tests\Fixtures\Arch\ToUseTrait\HasTrait\ParentClassWithTrait;
|
|
use Tests\Fixtures\Arch\ToUseTrait\HasTrait\TestTraitForInheritance;
|
|
|
|
test('pass', function (): void {
|
|
expect(HigherOrderExpectation::class)->toUseTrait(Retrievable::class)
|
|
->and(EachExpectation::class)->not->toUseTrait(Retrievable::class);
|
|
});
|
|
|
|
test('failures', function (): void {
|
|
expect(EachExpectation::class)->toUseTrait('Pest\Concerns\Foo');
|
|
})->throws(ArchExpectationFailedException::class);
|
|
|
|
test('not failures', function (): void {
|
|
expect(HigherOrderExpectation::class)->not->toUseTrait(Retrievable::class);
|
|
})->throws(ArchExpectationFailedException::class);
|
|
|
|
test('trait inheritance - direct usage', function (): void {
|
|
expect(ParentClassWithTrait::class)->toUseTrait(TestTraitForInheritance::class);
|
|
});
|
|
|
|
test('trait inheritance - inherited usage', function (): void {
|
|
expect(ChildClassExtendingParent::class)->toUseTrait(TestTraitForInheritance::class);
|
|
});
|
|
|
|
test('trait inheritance - negative case', function (): void {
|
|
expect(ChildClassExtendingParent::class)->not->toUseTrait('NonExistentTrait');
|
|
});
|
|
|
|
test('nested trait inheritance', function (): void {
|
|
expect(ChildClassExtendingParent::class)->toUseTrait(NestedTrait::class);
|
|
});
|