2018-09-16 18:52:28 +02:00
< ? php
2020-10-11 18:24:12 +02:00
namespace danog\ClassFinder\UnitTest\Classmap ;
2018-09-16 18:52:28 +02:00
2020-10-11 18:24:12 +02:00
use danog\ClassFinder\ClassFinder ;
use danog\ClassFinder\Classmap\ClassmapEntry ;
2018-09-16 18:52:28 +02:00
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 " );
2018-12-31 20:33:39 +01:00
$this -> assertTrue ( $entry -> matches ( " MyClassmap \ Foo " , ClassFinder :: STANDARD_MODE ));
2018-09-16 18:52:28 +02:00
2018-12-31 20:33:39 +01:00
$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 ));
2018-09-16 18:52:28 +02:00
}
}