mirror of
https://github.com/danog/class-finder.git
synced 2024-11-26 20:14:59 +01:00
Switch namespace
This commit is contained in:
parent
2bbbde7a5e
commit
7d76667d46
@ -7,7 +7,7 @@ Example PHP:
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
ClassFinder::enableExperimentalFilesSupport();
|
||||
$classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar');
|
||||
|
@ -7,7 +7,7 @@ Example PHP:
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
ClassFinder::enableExperimentalFilesSupport();
|
||||
$classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar');
|
||||
|
@ -7,7 +7,7 @@ Example PHP:
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
$classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar');
|
||||
```
|
||||
@ -25,7 +25,7 @@ is the directory that contains the composer.json configuration and where classes
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
ClassFinder::setAppRoot(realpath(__DIR__ . '../../app/')); // This is suggesting that the app root is really someone else.
|
||||
$classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar');
|
||||
|
@ -9,7 +9,7 @@ Example PHP:
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
$classes = ClassFinder::getClassesInNamespace('Acme\Foo\Bar');
|
||||
```
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder;
|
||||
namespace danog\ClassFinder;
|
||||
|
||||
use HaydenPierce\ClassFinder\Exception\ClassFinderException;
|
||||
use danog\ClassFinder\Exception\ClassFinderException;
|
||||
|
||||
class AppConfig
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder;
|
||||
namespace danog\ClassFinder;
|
||||
|
||||
use HaydenPierce\ClassFinder\Classmap\ClassmapEntryFactory;
|
||||
use HaydenPierce\ClassFinder\Classmap\ClassmapFinder;
|
||||
use HaydenPierce\ClassFinder\Files\FilesEntryFactory;
|
||||
use HaydenPierce\ClassFinder\Files\FilesFinder;
|
||||
use HaydenPierce\ClassFinder\PSR4\PSR4Finder;
|
||||
use HaydenPierce\ClassFinder\PSR4\PSR4NamespaceFactory;
|
||||
use danog\ClassFinder\Classmap\ClassmapEntryFactory;
|
||||
use danog\ClassFinder\Classmap\ClassmapFinder;
|
||||
use danog\ClassFinder\Files\FilesEntryFactory;
|
||||
use danog\ClassFinder\Files\FilesFinder;
|
||||
use danog\ClassFinder\PSR4\PSR4Finder;
|
||||
use danog\ClassFinder\PSR4\PSR4NamespaceFactory;
|
||||
|
||||
class ClassFinder
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\Classmap;
|
||||
namespace danog\ClassFinder\Classmap;
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class ClassmapEntry
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\Classmap;
|
||||
namespace danog\ClassFinder\Classmap;
|
||||
|
||||
use HaydenPierce\ClassFinder\AppConfig;
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\AppConfig;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class ClassmapEntryFactory
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\Classmap;
|
||||
namespace danog\ClassFinder\Classmap;
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use HaydenPierce\ClassFinder\FinderInterface;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\FinderInterface;
|
||||
|
||||
class ClassmapFinder implements FinderInterface
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\Exception;
|
||||
namespace danog\ClassFinder\Exception;
|
||||
|
||||
class ClassFinderException extends \Exception
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\Files;
|
||||
namespace danog\ClassFinder\Files;
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class FilesEntry
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\Files;
|
||||
namespace danog\ClassFinder\Files;
|
||||
|
||||
use HaydenPierce\ClassFinder\AppConfig;
|
||||
use HaydenPierce\ClassFinder\Exception\ClassFinderException;
|
||||
use danog\ClassFinder\AppConfig;
|
||||
use danog\ClassFinder\Exception\ClassFinderException;
|
||||
|
||||
class FilesEntryFactory
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\Files;
|
||||
namespace danog\ClassFinder\Files;
|
||||
|
||||
use HaydenPierce\ClassFinder\Exception\ClassFinderException;
|
||||
use HaydenPierce\ClassFinder\FinderInterface;
|
||||
use danog\ClassFinder\Exception\ClassFinderException;
|
||||
use danog\ClassFinder\FinderInterface;
|
||||
|
||||
class FilesFinder implements FinderInterface
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder;
|
||||
namespace danog\ClassFinder;
|
||||
|
||||
interface FinderInterface
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\PSR4;
|
||||
namespace danog\ClassFinder\PSR4;
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use HaydenPierce\ClassFinder\FinderInterface;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\FinderInterface;
|
||||
|
||||
class PSR4Finder implements FinderInterface
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\PSR4;
|
||||
namespace danog\ClassFinder\PSR4;
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use HaydenPierce\ClassFinder\Exception\ClassFinderException;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\Exception\ClassFinderException;
|
||||
|
||||
class PSR4Namespace
|
||||
{
|
||||
@ -70,7 +70,7 @@ class PSR4Namespace
|
||||
* $b->countMatchingNamespaceSegments("TestApp1\\Multi") -> 2, TestApp1\\Multi matches
|
||||
*
|
||||
* PSR4Namespace $c;
|
||||
* $c->namespace = "HaydenPierce\\Foo\\Bar";
|
||||
* $c->namespace = "danog\\Foo\\Bar";
|
||||
* $c->countMatchingNamespaceSegments("TestApp1\\Multi") -> 0, No matches.
|
||||
*
|
||||
* @param string $namespace
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\PSR4;
|
||||
namespace danog\ClassFinder\PSR4;
|
||||
|
||||
use HaydenPierce\ClassFinder\AppConfig;
|
||||
use HaydenPierce\ClassFinder\Exception\ClassFinderException;
|
||||
use danog\ClassFinder\AppConfig;
|
||||
use danog\ClassFinder\Exception\ClassFinderException;
|
||||
|
||||
class PSR4NamespaceFactory
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "HaydenPierce/testApp",
|
||||
"name": "danog/testApp",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
|
6
test/app1/composer.lock
generated
6
test/app1/composer.lock
generated
@ -81,7 +81,7 @@
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"HaydenPierce\\ClassFinder\\": "src/"
|
||||
"danog\\ClassFinder\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -113,8 +113,8 @@
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"HaydenPierce\\SandboxApp\\": "src/",
|
||||
"HaydenPierce\\SandboxAppMulti\\": [
|
||||
"danog\\SandboxApp\\": "src/",
|
||||
"danog\\SandboxAppMulti\\": [
|
||||
"multi/Bop",
|
||||
"multi/Bot"
|
||||
]
|
||||
|
@ -4,7 +4,7 @@ namespace TestApp1;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
// "vendor/bin/phpunit" "./test/app1/src/ClassFinderTest.php"
|
||||
class ClassFinderTest extends \PHPUnit_Framework_TestCase
|
||||
@ -22,7 +22,7 @@ class ClassFinderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException HaydenPierce\ClassFinder\Exception\ClassFinderException
|
||||
* @expectedException danog\ClassFinder\Exception\ClassFinderException
|
||||
* @expectedExceptionMessage Could not locate composer.json. You can get around this by setting ClassFinder::$appRoot manually.
|
||||
*/
|
||||
public function testThrowsOnMissingComposerConfig()
|
||||
|
@ -4,7 +4,7 @@ namespace TestApp1;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class ClassmapTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -47,22 +47,22 @@ class ClassmapTest extends \PHPUnit_Framework_TestCase
|
||||
'Classfinder should be able to load classes based on a classmap.'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\Classmap',
|
||||
'danog\Classmap',
|
||||
array(
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap\ClassmapClassmap2PHP'
|
||||
'danog\Classmap\Classmap2ClassmapINC',
|
||||
'danog\Classmap\Classmap2ClassmapPHP',
|
||||
'danog\Classmap\Classmap3ClassesPHP',
|
||||
'danog\Classmap\ClassmapClassmap2PHP'
|
||||
),
|
||||
'Classfinder should be able to load classes based on a classmap from 3rd party packages.'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\Classmap2',
|
||||
'danog\Classmap2',
|
||||
array(
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap2\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap2\ClassmapClassmap2PHP'
|
||||
'danog\Classmap2\Classmap2ClassmapINC',
|
||||
'danog\Classmap2\Classmap2ClassmapPHP',
|
||||
'danog\Classmap2\Classmap3ClassesPHP',
|
||||
'danog\Classmap2\ClassmapClassmap2PHP'
|
||||
),
|
||||
'Classfinder should be able to handle multiple namespaces in a single file for a classmap.'
|
||||
)
|
||||
@ -110,16 +110,16 @@ class ClassmapTest extends \PHPUnit_Framework_TestCase
|
||||
'Classfinder should be able to load classes recursively based on a classmap.'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce',
|
||||
'danog',
|
||||
array(
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap2\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap2\ClassmapClassmap2PHP',
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap\ClassmapClassmap2PHP',
|
||||
'danog\Classmap2\Classmap2ClassmapINC',
|
||||
'danog\Classmap2\Classmap2ClassmapPHP',
|
||||
'danog\Classmap2\Classmap3ClassesPHP',
|
||||
'danog\Classmap2\ClassmapClassmap2PHP',
|
||||
'danog\Classmap\Classmap2ClassmapINC',
|
||||
'danog\Classmap\Classmap2ClassmapPHP',
|
||||
'danog\Classmap\Classmap3ClassesPHP',
|
||||
'danog\Classmap\ClassmapClassmap2PHP',
|
||||
),
|
||||
'Classfinder should be able to load third party classes recursively based on a classmap.'
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ namespace TestApp1;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class FilesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -53,14 +53,14 @@ class FilesTest extends \PHPUnit_Framework_TestCase
|
||||
'ClassFinder should be able to find 1st party classes included from `files` listed in composer.json.'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\Files',
|
||||
'danog\Files',
|
||||
array(
|
||||
'HaydenPierce\Files\z',
|
||||
'HaydenPierce\Files\z2',
|
||||
'HaydenPierce\Files\a',
|
||||
'HaydenPierce\Files\a2',
|
||||
'HaydenPierce\Files\b',
|
||||
'HaydenPierce\Files\b2'
|
||||
'danog\Files\z',
|
||||
'danog\Files\z2',
|
||||
'danog\Files\a',
|
||||
'danog\Files\a2',
|
||||
'danog\Files\b',
|
||||
'danog\Files\b2'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes included from `files` listed in composer.json of those projects.'
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ namespace TestApp1;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class PSR4Test extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -58,7 +58,7 @@ class PSR4Test extends \PHPUnit_Framework_TestCase
|
||||
'TestApp1\Multi\Uik',
|
||||
'TestApp1\Multi\Yik'
|
||||
),
|
||||
'ClassFinder should be able to find 1st party classes when a provided namespace root maps to multiple directories (Example: "HaydenPierce\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
'ClassFinder should be able to find 1st party classes when a provided namespace root maps to multiple directories (Example: "danog\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
),
|
||||
array(
|
||||
'TestApp1\Multi\Yop',
|
||||
@ -68,32 +68,32 @@ class PSR4Test extends \PHPUnit_Framework_TestCase
|
||||
'TestApp1\Multi\Yop\Eij',
|
||||
'TestApp1\Multi\Yop\Rij'
|
||||
),
|
||||
'ClassFinder should be able to find 1st party classes when a provided namespace root maps to multiple directories multiple levels deep. (Example: "HaydenPierce\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
'ClassFinder should be able to find 1st party classes when a provided namespace root maps to multiple directories multiple levels deep. (Example: "danog\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\SandboxApp',
|
||||
'danog\SandboxApp',
|
||||
array(
|
||||
'HaydenPierce\SandboxApp\Foy'
|
||||
'danog\SandboxApp\Foy'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\SandboxApp\Foo\Bar',
|
||||
'danog\SandboxApp\Foo\Bar',
|
||||
array(
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barc',
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barp'
|
||||
'danog\SandboxApp\Foo\Bar\Barc',
|
||||
'danog\SandboxApp\Foo\Bar\Barp'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes multiple namespaces deep.'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\SandboxAppMulti',
|
||||
'danog\SandboxAppMulti',
|
||||
array(
|
||||
'HaydenPierce\SandboxAppMulti\Zip',
|
||||
'HaydenPierce\SandboxAppMulti\Zop',
|
||||
'HaydenPierce\SandboxAppMulti\Zap',
|
||||
'HaydenPierce\SandboxAppMulti\Zit'
|
||||
'danog\SandboxAppMulti\Zip',
|
||||
'danog\SandboxAppMulti\Zop',
|
||||
'danog\SandboxAppMulti\Zap',
|
||||
'danog\SandboxAppMulti\Zit'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes when a provided namespace root maps to multiple directories (Example: "HaydenPierce\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
'ClassFinder should be able to find 3rd party classes when a provided namespace root maps to multiple directories (Example: "danog\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
),
|
||||
array(
|
||||
'TestApp1\Foo\Empty',
|
||||
@ -118,10 +118,10 @@ class PSR4Test extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
// ClassFinder has the ability to find itself. This ability, while intended, is incontinent for tests
|
||||
// because of the 'HaydenPierce' test case. Whenever ClassFinder would be updated, we would need to update the
|
||||
// because of the 'danog' test case. Whenever ClassFinder would be updated, we would need to update the
|
||||
// test. To prevent the flakiness, we just remove ClassFinder's classes.
|
||||
$classes = array_filter($classes, function($class) {
|
||||
return strpos($class, 'HaydenPierce\ClassFinder') !== 0;
|
||||
return strpos($class, 'danog\ClassFinder') !== 0;
|
||||
});
|
||||
|
||||
ClassFinder::enableClassmapSupport();
|
||||
@ -165,20 +165,20 @@ class PSR4Test extends \PHPUnit_Framework_TestCase
|
||||
'TestApp1\Multi\Yop\Eij',
|
||||
'TestApp1\Multi\Yop\Rij'
|
||||
),
|
||||
'ClassFinder should be able to find 1st party classes recursively when a provided namespace root maps to multiple directories (Example: "HaydenPierce\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
'ClassFinder should be able to find 1st party classes recursively when a provided namespace root maps to multiple directories (Example: "danog\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce',
|
||||
'danog',
|
||||
array(
|
||||
'HaydenPierce\SandboxApp\Foy',
|
||||
'HaydenPierce\SandboxApp\Fob\Soz',
|
||||
'HaydenPierce\SandboxApp\Foo\Larc',
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barc',
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barp',
|
||||
'HaydenPierce\SandboxAppMulti\Zip',
|
||||
'HaydenPierce\SandboxAppMulti\Zop',
|
||||
'HaydenPierce\SandboxAppMulti\Zap',
|
||||
'HaydenPierce\SandboxAppMulti\Zit'
|
||||
'danog\SandboxApp\Foy',
|
||||
'danog\SandboxApp\Fob\Soz',
|
||||
'danog\SandboxApp\Foo\Larc',
|
||||
'danog\SandboxApp\Foo\Bar\Barc',
|
||||
'danog\SandboxApp\Foo\Bar\Barp',
|
||||
'danog\SandboxAppMulti\Zip',
|
||||
'danog\SandboxAppMulti\Zop',
|
||||
'danog\SandboxAppMulti\Zap',
|
||||
'danog\SandboxAppMulti\Zit'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes'
|
||||
)
|
||||
@ -188,13 +188,13 @@ class PSR4Test extends \PHPUnit_Framework_TestCase
|
||||
public function testForClassesInNamespace()
|
||||
{
|
||||
$this->assertFalse(ClassFinder::namespaceHasClasses('DoesNotExist'));
|
||||
$this->assertTrue(ClassFinder::namespaceHasClasses('HaydenPierce\ClassFinder'));
|
||||
$this->assertTrue(ClassFinder::namespaceHasClasses('danog\ClassFinder'));
|
||||
}
|
||||
|
||||
public function testCanFindSelf()
|
||||
{
|
||||
try {
|
||||
$classes = ClassFinder::getClassesInNamespace('HaydenPierce\ClassFinder', ClassFinder::RECURSIVE_MODE);
|
||||
$classes = ClassFinder::getClassesInNamespace('danog\ClassFinder', ClassFinder::RECURSIVE_MODE);
|
||||
} catch (\Exception $e) {
|
||||
$this->assertFalse(true, 'An exception occurred: ' . $e->getMessage());
|
||||
$classes = array();
|
||||
|
@ -4,7 +4,7 @@ namespace TestApp2;
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class ClassmapNoAutoloadTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -32,22 +32,22 @@ class ClassmapNoAutoloadTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'HaydenPierce\Classmap',
|
||||
'danog\Classmap',
|
||||
array(
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap\ClassmapClassmap2PHP'
|
||||
'danog\Classmap\Classmap2ClassmapINC',
|
||||
'danog\Classmap\Classmap2ClassmapPHP',
|
||||
'danog\Classmap\Classmap3ClassesPHP',
|
||||
'danog\Classmap\ClassmapClassmap2PHP'
|
||||
),
|
||||
'Classfinder should be able to load classes based on a classmap from 3rd party packages.'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\Classmap2',
|
||||
'danog\Classmap2',
|
||||
array(
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap2\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap2\ClassmapClassmap2PHP'
|
||||
'danog\Classmap2\Classmap2ClassmapINC',
|
||||
'danog\Classmap2\Classmap2ClassmapPHP',
|
||||
'danog\Classmap2\Classmap3ClassesPHP',
|
||||
'danog\Classmap2\ClassmapClassmap2PHP'
|
||||
),
|
||||
'Classfinder should be able to handle multiple namespaces in a single file for a classmap.'
|
||||
)
|
||||
@ -77,16 +77,16 @@ class ClassmapNoAutoloadTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'HaydenPierce',
|
||||
'danog',
|
||||
array(
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap2\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap2\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap2\ClassmapClassmap2PHP',
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapINC',
|
||||
'HaydenPierce\Classmap\Classmap2ClassmapPHP',
|
||||
'HaydenPierce\Classmap\Classmap3ClassesPHP',
|
||||
'HaydenPierce\Classmap\ClassmapClassmap2PHP',
|
||||
'danog\Classmap2\Classmap2ClassmapINC',
|
||||
'danog\Classmap2\Classmap2ClassmapPHP',
|
||||
'danog\Classmap2\Classmap3ClassesPHP',
|
||||
'danog\Classmap2\ClassmapClassmap2PHP',
|
||||
'danog\Classmap\Classmap2ClassmapINC',
|
||||
'danog\Classmap\Classmap2ClassmapPHP',
|
||||
'danog\Classmap\Classmap3ClassesPHP',
|
||||
'danog\Classmap\ClassmapClassmap2PHP',
|
||||
),
|
||||
'Classfinder should be able to load third party classes recursively based on a classmap.'
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ namespace TestApp2;
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
|
||||
class PSR4NoAutoloadTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -35,46 +35,46 @@ class PSR4NoAutoloadTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'HaydenPierce\SandboxApp',
|
||||
'danog\SandboxApp',
|
||||
array(
|
||||
'HaydenPierce\SandboxApp\Foy'
|
||||
'danog\SandboxApp\Foy'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\SandboxApp\Foo\Bar',
|
||||
'danog\SandboxApp\Foo\Bar',
|
||||
array(
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barc',
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barp'
|
||||
'danog\SandboxApp\Foo\Bar\Barc',
|
||||
'danog\SandboxApp\Foo\Bar\Barp'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes multiple namespaces deep.'
|
||||
),
|
||||
array(
|
||||
'HaydenPierce\SandboxAppMulti',
|
||||
'danog\SandboxAppMulti',
|
||||
array(
|
||||
'HaydenPierce\SandboxAppMulti\Zip',
|
||||
'HaydenPierce\SandboxAppMulti\Zop',
|
||||
'HaydenPierce\SandboxAppMulti\Zap',
|
||||
'HaydenPierce\SandboxAppMulti\Zit'
|
||||
'danog\SandboxAppMulti\Zip',
|
||||
'danog\SandboxAppMulti\Zop',
|
||||
'danog\SandboxAppMulti\Zap',
|
||||
'danog\SandboxAppMulti\Zit'
|
||||
),
|
||||
'ClassFinder should be able to find 3rd party classes when a provided namespace root maps to multiple directories (Example: "HaydenPierce\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
'ClassFinder should be able to find 3rd party classes when a provided namespace root maps to multiple directories (Example: "danog\\SandboxAppMulti\\": ["multi/Bop", "multi/Bot"] )'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetClassesInNamespaceRecursively()
|
||||
{
|
||||
$namespace = 'HaydenPierce';
|
||||
$namespace = 'danog';
|
||||
$expected = array(
|
||||
'HaydenPierce\SandboxApp\Foy',
|
||||
'HaydenPierce\SandboxApp\Fob\Soz',
|
||||
'HaydenPierce\SandboxApp\Foo\Larc',
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barc',
|
||||
'HaydenPierce\SandboxApp\Foo\Bar\Barp',
|
||||
'HaydenPierce\SandboxAppMulti\Zip',
|
||||
'HaydenPierce\SandboxAppMulti\Zop',
|
||||
'HaydenPierce\SandboxAppMulti\Zap',
|
||||
'HaydenPierce\SandboxAppMulti\Zit'
|
||||
'danog\SandboxApp\Foy',
|
||||
'danog\SandboxApp\Fob\Soz',
|
||||
'danog\SandboxApp\Foo\Larc',
|
||||
'danog\SandboxApp\Foo\Bar\Barc',
|
||||
'danog\SandboxApp\Foo\Bar\Barp',
|
||||
'danog\SandboxAppMulti\Zip',
|
||||
'danog\SandboxAppMulti\Zop',
|
||||
'danog\SandboxAppMulti\Zap',
|
||||
'danog\SandboxAppMulti\Zit'
|
||||
);
|
||||
$message = 'ClassFinder should be able to find 3rd party classes';
|
||||
|
||||
@ -88,10 +88,10 @@ class PSR4NoAutoloadTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
// ClassFinder has the ability to find itself. This ability, while intended, is incontinent for tests
|
||||
// because of the 'HaydenPierce' test case. Whenever ClassFinder would be updated, we would need to update the
|
||||
// because of the 'danog' test case. Whenever ClassFinder would be updated, we would need to update the
|
||||
// test. To prevent the flakiness, we just remove ClassFinder's classes.
|
||||
$classes = array_filter($classes, function($class) {
|
||||
return strpos($class, 'HaydenPierce\ClassFinder') !== 0;
|
||||
return strpos($class, 'danog\ClassFinder') !== 0;
|
||||
});
|
||||
|
||||
ClassFinder::enableClassmapSupport();
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "HaydenPierce/testApp",
|
||||
"name": "danog/testApp",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
|
6
test/app2/composer.lock
generated
6
test/app2/composer.lock
generated
@ -81,7 +81,7 @@
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"HaydenPierce\\ClassFinder\\": "src/"
|
||||
"danog\\ClassFinder\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -113,8 +113,8 @@
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"HaydenPierce\\SandboxApp\\": "src/",
|
||||
"HaydenPierce\\SandboxAppMulti\\": [
|
||||
"danog\\SandboxApp\\": "src/",
|
||||
"danog\\SandboxAppMulti\\": [
|
||||
"multi/Bop",
|
||||
"multi/Bot"
|
||||
]
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\UnitTest\Classmap;
|
||||
namespace danog\ClassFinder\UnitTest\Classmap;
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use HaydenPierce\ClassFinder\Classmap\ClassmapEntry;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\Classmap\ClassmapEntry;
|
||||
|
||||
class ClassmapEntryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\UnitTest\Files;
|
||||
namespace danog\ClassFinder\UnitTest\Files;
|
||||
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
use HaydenPierce\ClassFinder\Files\FilesEntry;
|
||||
use danog\ClassFinder\ClassFinder;
|
||||
use danog\ClassFinder\Files\FilesEntry;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace HaydenPierce\ClassFinder\UnitTest\PSR4;
|
||||
namespace danog\ClassFinder\UnitTest\PSR4;
|
||||
|
||||
use HaydenPierce\ClassFinder\PSR4\PSR4Namespace;
|
||||
use danog\ClassFinder\PSR4\PSR4Namespace;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
|
||||
@ -73,7 +73,7 @@ EOL;
|
||||
|
||||
public function testKnowsNamespace()
|
||||
{
|
||||
$namespace = $this->getMockBuilder('\HaydenPierce\ClassFinder\PSR4\PSR4Namespace')
|
||||
$namespace = $this->getMockBuilder('\danog\ClassFinder\PSR4\PSR4Namespace')
|
||||
->setConstructorArgs(array(
|
||||
'MyPSR4Root\\Foot\\',
|
||||
array($this->root->getChild('Baz')->path())
|
||||
|
Loading…
Reference in New Issue
Block a user