diff --git a/README.md b/README.md index 1174ccb..9f97d02 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,14 @@ The problem that this project aims to solve is to give you a way to provide a si all those scenarios. ## The Solution -Meet the Drupal Unit Autoload. +Meet the Drupal Unit Autoload. To include it, just add the following to your PHPUnit test class (change the path +depending on the location of your test classes): + +```php +require_once __DIR__ . '/../../vendor/mateu-aguilo-bosch/drupal-unit-autoload/autoload.php'; +``` + +That will load Composer's autoloader + the Drupal capabilities. The only thing that you need to do is add a new `composer.json` key with tokens in the path. diff --git a/autoload.php b/autoload.php new file mode 100644 index 0000000..874c944 --- /dev/null +++ b/autoload.php @@ -0,0 +1,9 @@ +register(); diff --git a/drupal_unit_autoloader.php b/drupal_unit_autoloader.php deleted file mode 100644 index 179a4c6..0000000 --- a/drupal_unit_autoloader.php +++ /dev/null @@ -1,7 +0,0 @@ -checkLoadedAutoloader()) { @@ -132,9 +132,7 @@ protected function registerPsr(array $composer_config) { } /** - * Checks if the autoloader has been added. - * - * @return bool + * {@inheritdoc} */ public function checkLoadedAutoloader() { $functions = spl_autoload_functions(); @@ -142,10 +140,7 @@ public function checkLoadedAutoloader() { } /** - * Gets the configuration for the drupal loader from the Composer loader. - * - * @return array - * The configuration array for the drupal loader. + * {@inheritdoc} */ public function getConfig() { // Initialize empty configuration. @@ -196,4 +191,11 @@ public function getConfig() { return $config; } + /** + * {@inheritdoc} + */ + public function getClassLoader() { + return $this->classLoader; + } + } diff --git a/src/AutoloaderBootstrapInterface.php b/src/AutoloaderBootstrapInterface.php new file mode 100644 index 0000000..daface0 --- /dev/null +++ b/src/AutoloaderBootstrapInterface.php @@ -0,0 +1,42 @@ +assertEquals($expected, $config); } + /** + * Tests the ::getClassLoader method. + * + * @covers ::getClassLoader() + */ + public function test_getClassLoader() { + $loader = m::mock('\Composer\Autoload\ClassLoader'); + $autoloader = new AutoloaderBootstrap($loader, 'data/docroot/sites/all/modules/testmodule/composer.json'); + $this->assertEquals($loader, $autoloader->getClassLoader()); + } + }