Skip to content

Commit

Permalink
Add unit test for namespace check
Browse files Browse the repository at this point in the history
  • Loading branch information
ttk committed Dec 19, 2023
1 parent 2f8e14f commit 16329d6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/Persistence/Mapping/DriverChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ public function testDefaultDriverGetAllClassNames(): void

self::assertSame(['Doctrine\Tests\Models\Company\Foo', 'Other\Class'], $classNames);
}

public function testMatchingNamespace(): void
{
// Expose the protected method as public
$mdc = new class extends MappingDriverChain {
public static function isMatchingNamespace(string $className, string $namespace): bool
{
return parent::isMatchingNamespace($className, $namespace);
}
};

$className = DriverChainEntity::class;

self::assertTrue($mdc::isMatchingNamespace($className, 'Doctrine\Tests\Persistence\Mapping\\'));
self::assertTrue($mdc::isMatchingNamespace($className, 'Doctrine\Tests\Persistence\Mapping'));
self::assertFalse($mdc::isMatchingNamespace($className, 'Doctrine\Tests\Persistence\Map'));
self::assertFalse($mdc::isMatchingNamespace($className, 'Doctrine\Tests\Persistence'));
}
}

class DriverChainEntity
Expand Down

0 comments on commit 16329d6

Please sign in to comment.