1
0
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:
Hayden Pierce 2018-09-16 11:52:28 -05:00
parent c161c74a97
commit 4ecfb28c51
3 changed files with 34 additions and 1 deletions

View File

@ -18,6 +18,7 @@
</testsuite>
<testsuite name="classmap">
<file>test/app1/src/ClassmapTest.php</file>
<directory>test/unit/Classmap</directory>
</testsuite>
</testsuites>
</phpunit>

View 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"));
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace HaydenPierce\ClassFinder\UnitTest;
namespace HaydenPierce\ClassFinder\UnitTest\PSR4;
use HaydenPierce\ClassFinder\PSR4\PSR4Namespace;
use org\bovigo\vfs\vfsStream;