mirror of
https://github.com/danog/class-finder.git
synced 2024-11-30 04:29:03 +01:00
Fix tests a bit
This commit is contained in:
parent
d1f7671588
commit
ff233b606d
@ -28,7 +28,7 @@ class FilesEntry
|
|||||||
*/
|
*/
|
||||||
public function knowsNamespace($namespace)
|
public function knowsNamespace($namespace)
|
||||||
{
|
{
|
||||||
$classes = $this->getClassesInFile();
|
$classes = $this->getClassesInFile(ClassFinder::ALLOW_CLASSES | ClassFinder::ALLOW_INTERFACES | ClassFinder::ALLOW_TRAITS);
|
||||||
|
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
if (strpos($class, $namespace) !== false) {
|
if (strpos($class, $namespace) !== false) {
|
||||||
@ -83,7 +83,7 @@ class FilesEntry
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getClassesInFile($options = ClassFinder::ALLOW_INTERFACES | ClassFinder::ALLOW_TRAITS)
|
private function getClassesInFile($options)
|
||||||
{
|
{
|
||||||
// get_declared_*() returns a bunch of classes|interfaces|traits that are built into PHP. So we need a control here.
|
// get_declared_*() returns a bunch of classes|interfaces|traits that are built into PHP. So we need a control here.
|
||||||
list($initialInterfaces,
|
list($initialInterfaces,
|
||||||
|
@ -166,7 +166,7 @@ class PSR4Namespace
|
|||||||
* @param int $options
|
* @param int $options
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function findClasses($namespace, $options = ClassFinder::STANDARD_MODE)
|
public function findClasses($namespace, $options)
|
||||||
{
|
{
|
||||||
$allowAdditional = $options & ~ClassFinder::MODE_MASK;
|
$allowAdditional = $options & ~ClassFinder::MODE_MASK;
|
||||||
$options &= ClassFinder::MODE_MASK;
|
$options &= ClassFinder::MODE_MASK;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace HaydenPierce\ClassFinder\UnitTest\Files;
|
namespace HaydenPierce\ClassFinder\UnitTest\Files;
|
||||||
|
|
||||||
|
use HaydenPierce\ClassFinder\ClassFinder;
|
||||||
use HaydenPierce\ClassFinder\Files\FilesEntry;
|
use HaydenPierce\ClassFinder\Files\FilesEntry;
|
||||||
use org\bovigo\vfs\vfsStream;
|
use org\bovigo\vfs\vfsStream;
|
||||||
use org\bovigo\vfs\vfsStreamDirectory;
|
use org\bovigo\vfs\vfsStreamDirectory;
|
||||||
@ -46,7 +47,7 @@ EOL
|
|||||||
|
|
||||||
$files = new FilesEntry($tmpFilename, $this->findPHP());
|
$files = new FilesEntry($tmpFilename, $this->findPHP());
|
||||||
|
|
||||||
$classes = $files->getClasses($namespace, 0);
|
$classes = $files->getClasses($namespace, ClassFinder::ALLOW_CLASSES);
|
||||||
|
|
||||||
$this->assertEquals($expected, $classes, 'FilesEntry should be able to determine the classes defined in a given file.');
|
$this->assertEquals($expected, $classes, 'FilesEntry should be able to determine the classes defined in a given file.');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user