[icinga-checkins] icinga.org: icingaweb2/feature/travis: test/bootstrap: Load composer autoload when present

git at icinga.org git at icinga.org
Wed Jan 4 18:14:54 CET 2017


Module: icingaweb2
Branch: feature/travis
Commit: cd4296c728d5f2b363e81bd24a44e0daf0fc5ee9
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=cd4296c728d5f2b363e81bd24a44e0daf0fc5ee9

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Wed Jan  4 17:23:36 2017 +0100

test/bootstrap: Load composer autoload when present

---

 test/php/bootstrap.php |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/test/php/bootstrap.php b/test/php/bootstrap.php
index 9543870..e8df106 100644
--- a/test/php/bootstrap.php
+++ b/test/php/bootstrap.php
@@ -1,9 +1,11 @@
 <?php
 /* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
 
-$applicationPath = realpath(dirname(__FILE__) . '/../../application/');
-$modulePath = realpath(dirname(__FILE__) . '/../../modules/');
-$libraryPath = realpath(dirname(__FILE__) . '/../../library/');
+$basePath = realpath(dirname(__FILE__) . '/../..');
+$applicationPath = $basePath . '/application/';
+$modulePath = $basePath . '/modules/';
+$libraryPath = $basePath . '/library/';
+
 $testLibraryPath = realpath(dirname(__FILE__) . '/library/');
 $configPath = realpath($libraryPath . '/../config');
 
@@ -18,9 +20,16 @@ if (!defined('ICINGA_LIBDIR')) {
 // This is needed to get the Zend Plugin loader working
 set_include_path(implode(PATH_SEPARATOR, array($libraryPath, get_include_path())));
 
-require_once 'Mockery/Loader.php';
-$mockeryLoader = new \Mockery\Loader;
-$mockeryLoader->register();
+// initialize composer autoload when existing
+if (file_exists($autoload = $basePath . '/vendor/autoload.php')) {
+    require_once($autoload);
+}
+
+if (! class_exists('\Mockery')) {
+    require_once 'Mockery/Loader.php';
+    $mockeryLoader = new \Mockery\Loader;
+    $mockeryLoader->register();
+}
 
 require_once($libraryPath . '/Icinga/Test/ClassLoader.php');
 



More information about the icinga-checkins mailing list