Skip to content

Commit

Permalink
Merge pull request #6 from fabio-ivona/fix-tests
Browse files Browse the repository at this point in the history
fix tests
  • Loading branch information
nunomaduro committed Aug 21, 2023
2 parents 6408551 + bd7f3a7 commit b29fb41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Factories/ObjectDescriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Pest\Arch\Objects\ObjectDescription;
use Pest\Arch\Objects\VendorObjectDescription;
use Pest\Arch\Support\PhpCoreExpressions;
use PHPUnit\Architecture\Asserts\Dependencies\Elements\ObjectUses;
use PHPUnit\Architecture\Services\ServiceContainer;
use ReflectionClass;
Expand Down Expand Up @@ -75,6 +76,10 @@ private static function ensureServiceContainerIsInitialized(): void
*/
private static function isUserDefined(string $use): bool
{
if(PhpCoreExpressions::getClass($use) !== null){
return false;
}

return match (true) {
enum_exists($use) => (new \ReflectionEnum($use))->isUserDefined(),
function_exists($use) => (new ReflectionFunction($use))->isUserDefined(),
Expand Down
4 changes: 4 additions & 0 deletions tests/Arch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

use Pest\Arch\Exceptions\ArchExpectationFailedException;
use Pest\Arch\Objects\FunctionDescription;
use Pest\Arch\Objects\ObjectDescription;
use Pest\Arch\Objects\ObjectDescriptionBase;
use Pest\Arch\Objects\VendorObjectDescription;
use Pest\Arch\Support\PhpCoreExpressions;
use Pest\Arch\ValueObjects\Dependency;
use Pest\Arch\ValueObjects\Targets;
use Pest\Arch\ValueObjects\Violation;
use Pest\Expectation;
use Tests\Fixtures\Misc\HasNativeFunctions;
use Whoops\Exception\Frame;

test('base')
Expand All @@ -16,6 +19,7 @@
->classes->not->toBeAbstract()
->classes->toExtendNothing()->ignoring([
VendorObjectDescription::class,
ObjectDescription::class,
ObjectDescriptionBase::class,
FunctionDescription::class,
ArchExpectationFailedException::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/ToBeUsedInNothing.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
});

it('passes as aliases', function () {
expect([Env::class, 'die'])->not->toBeUsed();
expect([Env::class, 'error_get_last'])->not->toBeUsed();
});

it('fails 1', function () {
Expand Down

0 comments on commit b29fb41

Please sign in to comment.