mirror of
https://github.com/danog/class-finder.git
synced 2024-11-30 04:29:03 +01:00
Add some minimal test harness.
This commit is contained in:
parent
f56e0b26d4
commit
77aa8b9460
@ -20,5 +20,9 @@
|
|||||||
<file>test/app1/src/ClassmapTest.php</file>
|
<file>test/app1/src/ClassmapTest.php</file>
|
||||||
<directory>test/unit/Classmap</directory>
|
<directory>test/unit/Classmap</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
<testsuite name="files">
|
||||||
|
<file>test/app1/src/FilesTest.php</file>
|
||||||
|
<directory>test/unit/Files</directory>
|
||||||
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
</phpunit>
|
</phpunit>
|
@ -18,6 +18,7 @@
|
|||||||
"TestApp1\\": "src/",
|
"TestApp1\\": "src/",
|
||||||
"TestApp1\\Multi\\": [ "multi/Jik/", "multi/Jiu/" ]
|
"TestApp1\\Multi\\": [ "multi/Jik/", "multi/Jiu/" ]
|
||||||
},
|
},
|
||||||
"classmap": ["classmap/woc/", "classmap/wop/", "classmap/woj/" ]
|
"classmap": ["classmap/woc/", "classmap/wop/", "classmap/woj/" ],
|
||||||
|
"files": ["files/files1.php", "files/files2.php", "files/more_files/Boom.php" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
test/app1/files/RedHerring.php
Normal file
3
test/app1/files/RedHerring.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TestApp1\FilesClasses;
|
7
test/app1/files/files1.php
Normal file
7
test/app1/files/files1.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TestApp1\FilesClasses;
|
||||||
|
|
||||||
|
class Bam {};
|
||||||
|
class Wam {};
|
||||||
|
class Fam {};
|
10
test/app1/files/files2.php
Normal file
10
test/app1/files/files2.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// This is intentionally made global. There are intentionally classes here in and out of a namespace.
|
||||||
|
// PHPStorm is subborn in it's complaining about this - so I just turn off inspections for this file.
|
||||||
|
class my_global_class_name {}
|
||||||
|
|
||||||
|
namespace TestApp1\FilesClasses;
|
||||||
|
|
||||||
|
class Cam {}
|
||||||
|
class Lam {}
|
7
test/app1/files/more_files/Boom.php
Normal file
7
test/app1/files/more_files/Boom.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MoreFiles;
|
||||||
|
|
||||||
|
class Boom {}
|
||||||
|
class Zoom {}
|
||||||
|
class Loom {}
|
47
test/app1/src/FilesTest.php
Normal file
47
test/app1/src/FilesTest.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TestApp1;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
use HaydenPierce\ClassFinder\ClassFinder;
|
||||||
|
|
||||||
|
class FilesTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function setup()
|
||||||
|
{
|
||||||
|
// Reset ClassFinder back to normal.
|
||||||
|
ClassFinder::setAppRoot(null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @dataProvider classFinderDataProvider
|
||||||
|
*/
|
||||||
|
public function testClassFinder($namespace, $expected, $message)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$classes = ClassFinder::getClassesInNamespace($namespace);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->assertFalse(true, 'An exception occurred: ' . $e->getMessage());
|
||||||
|
$classes = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $classes, $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classFinderDataProvider()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'TestApp1\FilesClasses',
|
||||||
|
array(
|
||||||
|
'TestApp1\FilesClasses\Bam',
|
||||||
|
'TestApp1\FilesClasses\Wam',
|
||||||
|
'TestApp1\FilesClasses\Fam',
|
||||||
|
'TestApp1\FilesClasses\Cam',
|
||||||
|
'TestApp1\FilesClasses\Lam',
|
||||||
|
),
|
||||||
|
'ClassFinder should be able to find 1st party classes included from `files` listed in composer.json.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user