mirror of
https://github.com/danog/class-finder.git
synced 2025-01-22 13:51:42 +01:00
Add classmap unit tests; Fix namespace in PSR4Namespace test.
This commit is contained in:
parent
c161c74a97
commit
4ecfb28c51
@ -18,6 +18,7 @@
|
||||
</testsuite>
|
||||
<testsuite name="classmap">
|
||||
<file>test/app1/src/ClassmapTest.php</file>
|
||||
<directory>test/unit/Classmap</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
32
test/unit/Classmap/ClassmapEntryTest.php
Normal file
32
test/unit/Classmap/ClassmapEntryTest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\UnitTest\Classmap;
|
||||
|
||||
use HaydenPierce\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"));
|
||||
|
||||
$this->assertFalse($entry->matches("MyClassmap"), "Providing only a single segment of a namespace should not be a match.");
|
||||
$this->assertFalse($entry->matches("MyClassmap\Foo\Bar"), "Providing the fully qualified classname doesn't match because only the class's namespace should match.");
|
||||
$this->assertFalse($entry->matches("MyClassmap\Bar"));
|
||||
$this->assertFalse($entry->matches("MyClassmap\Foo\Bar\Baz"));
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\UnitTest;
|
||||
namespace HaydenPierce\ClassFinder\UnitTest\PSR4;
|
||||
|
||||
use HaydenPierce\ClassFinder\PSR4\PSR4Namespace;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user