mirror of
https://github.com/danog/class-finder.git
synced 2024-12-04 10:28:03 +01:00
33 lines
1.4 KiB
PHP
33 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace danog\ClassFinder\UnitTest\Classmap;
|
|
|
|
use danog\ClassFinder\ClassFinder;
|
|
use danog\ClassFinder\Classmap\ClassmapEntry;
|
|
|
|
class ClassmapEntryTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function testKnowsNamespace()
|
|
{
|
|
$entry = new ClassmapEntry("MyClassmap\Foo\Bar");
|
|
|
|
$this->assertTrue($entry->knowsNamespace("MyClassmap"));
|
|
$this->assertTrue($entry->knowsNamespace("MyClassmap\Foo"));
|
|
$this->assertTrue($entry->knowsNamespace("MyClassmap\Foo\Bar"));
|
|
|
|
$this->assertFalse($entry->knowsNamespace("MyClassmap\Bar"));
|
|
$this->assertFalse($entry->knowsNamespace("MyClassmap\Foo\Bar\Baz"));
|
|
}
|
|
|
|
public function testMatches()
|
|
{
|
|
$entry = new ClassmapEntry("MyClassmap\Foo\Bar");
|
|
|
|
$this->assertTrue($entry->matches("MyClassmap\Foo", ClassFinder::STANDARD_MODE));
|
|
|
|
$this->assertFalse($entry->matches("MyClassmap", ClassFinder::STANDARD_MODE), "Providing only a single segment of a namespace should not be a match.");
|
|
$this->assertFalse($entry->matches("MyClassmap\Foo\Bar", ClassFinder::STANDARD_MODE), "Providing the fully qualified classname doesn't match because only the class's namespace should match.");
|
|
$this->assertFalse($entry->matches("MyClassmap\Bar", ClassFinder::STANDARD_MODE));
|
|
$this->assertFalse($entry->matches("MyClassmap\Foo\Bar\Baz", ClassFinder::STANDARD_MODE));
|
|
}
|
|
} |