Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul M. Jones
committed
Sep 4, 2014
1 parent
0412cae
commit 7f9a1b6
Showing
53 changed files
with
119 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
/tests/tmp | ||
/vendor | ||
/build | ||
/composer.lock | ||
/tests/container/vendor | ||
/tests/container/composer.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,45 @@ | ||
<?php | ||
spl_autoload_register(function ($class) { | ||
|
||
// what namespace prefix should be recognized? | ||
$prefix = 'Aura\Filter\\'; | ||
// the package namespace | ||
$ns = 'Aura\Filter'; | ||
|
||
// does the requested class match the namespace prefix? | ||
$prefix_len = strlen($prefix); | ||
if (substr($class, 0, $prefix_len) !== $prefix) { | ||
return; | ||
} | ||
// what prefixes should be recognized? | ||
$prefixes = array( | ||
"{$ns}\_Config\\" => array( | ||
__DIR__ . '/config', | ||
__DIR__ . '/tests/container/src', | ||
), | ||
"{$ns}\\" => array( | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests/unit/src', | ||
), | ||
); | ||
|
||
// go through the prefixes | ||
foreach ($prefixes as $prefix => $dirs) { | ||
|
||
// strip the prefix off the class | ||
$class = substr($class, $prefix_len); | ||
// does the requested class match the namespace prefix? | ||
$prefix_len = strlen($prefix); | ||
if (substr($class, 0, $prefix_len) !== $prefix) { | ||
continue; | ||
} | ||
|
||
// a partial filename | ||
$part = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; | ||
// strip the prefix off the class | ||
$class = substr($class, $prefix_len); | ||
|
||
// directories where we can find classes | ||
$dirs = array( | ||
__DIR__ . DIRECTORY_SEPARATOR . 'src', | ||
__DIR__ . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'src', | ||
); | ||
foreach ($dirs as $dir) { | ||
$file = $dir . DIRECTORY_SEPARATOR . $part; | ||
if (is_readable($file)) { | ||
require $file; | ||
// a partial filename | ||
$part = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; | ||
|
||
return; | ||
// go through the directories to find classes | ||
foreach ($dirs as $dir) { | ||
$dir = str_replace('/', DIRECTORY_SEPARATOR, $dir); | ||
$file = $dir . DIRECTORY_SEPARATOR . $part; | ||
if (is_readable($file)) { | ||
require $file; | ||
return; | ||
} | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
// turn on all errors | ||
error_reporting(E_ALL); | ||
|
||
// composer autoloader | ||
$composer_autoload = __DIR__ . "/vendor/autoload.php"; | ||
if (! is_readable($composer_autoload)) { | ||
echo "Did not find 'vendor/autoload.php'." . PHP_EOL; | ||
echo "Try ./phpunit.sh instead of phpunit." . PHP_EOL; | ||
exit(1); | ||
} | ||
require $composer_autoload; | ||
|
||
// package autoloader | ||
require dirname(dirname(__DIR__)) . '/autoload.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
if [ -d vendor ] | ||
then | ||
composer update | ||
else | ||
composer require aura/di:dev-develop-2 | ||
fi | ||
phpunit $@ | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<phpunit bootstrap="./bootstrap.php"> | ||
<testsuites> | ||
<testsuite> | ||
<directory>./src</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace Aura\Filter\_Config; | ||
|
||
use Aura\Di\ContainerAssertionsTrait; | ||
|
||
class CommonTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
use ContainerAssertionsTrait; | ||
|
||
public function setUp() | ||
{ | ||
$this->setUpContainer(array( | ||
'Aura\Filter\_Config\Common', | ||
)); | ||
} | ||
|
||
public function test() | ||
{ | ||
$this->assertNewInstance('Aura\Filter\Rule\Any'); | ||
$this->assertNewInstance('Aura\Filter\RuleCollection'); | ||
$this->assertNewInstance('Aura\Filter\RuleLocator'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
// turn on all errors | ||
error_reporting(E_ALL); | ||
|
||
// autoloader | ||
require dirname(dirname(__DIR__)) . '/autoload.php'; | ||
|
||
// default globals | ||
if (is_readable(__DIR__ . '/globals.dist.php')) { | ||
require __DIR__ . '/globals.dist.php'; | ||
} | ||
|
||
// override globals | ||
if (is_readable(__DIR__ . '/globals.php')) { | ||
require __DIR__ . '/globals.php'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
phpunit $@ | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@pmjones why do we want the users to run the phpunit.sh from unit ? Can't they just run the phpunit itself ?