Преглед изворни кода

[Test] make them work on travis-ci.org

Thomas Rabaix пре 13 година
родитељ
комит
690ebfbff0
3 измењених фајлова са 64 додато и 4 уклоњено
  1. 28 0
      Tests/tests/autoload.php.dist
  2. 5 4
      Tests/tests/bootstrap.php
  3. 31 0
      Tests/tests/vendors.php

+ 28 - 0
Tests/tests/autoload.php.dist

@@ -0,0 +1,28 @@
+<?php
+
+$vendorDir = __DIR__.'/../../vendor';
+require_once $vendorDir.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
+
+use Symfony\Component\ClassLoader\UniversalClassLoader;
+
+$loader = new UniversalClassLoader();
+$loader->registerNamespaces(array(
+    'Symfony'  => array($vendorDir.'/symfony/src'),
+    'Knp'  => array($vendorDir.'/knpmenu/src'),
+    'Sonata\\AdminBundle'  => array($vendorDir),
+    'Doctrine\\ORM' => array($vendorDir.'/doctrine/lib'),
+    'Doctrine\\Common' => array($vendorDir.'/doctrine-common/lib')
+));
+$loader->register();
+
+spl_autoload_register(function($class) {
+    if (0 === strpos($class, 'Sonata\\DoctrineORMAdminBundle\\')) {
+        $path = __DIR__.'/../../'.implode('/', array_slice(explode('\\', $class), 2)).'.php';
+        
+        if (!stream_resolve_include_path($path)) {
+            return false;
+        }
+        require_once $path;
+        return true;
+    }
+});

+ 5 - 4
Tests/tests/bootstrap.php

@@ -9,7 +9,8 @@
  * file that was distributed with this source code.
  * file that was distributed with this source code.
  */
  */
 
 
-$rootDir = __DIR__.'/../../../../../../';
-
-require_once $rootDir.'/vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
-require_once $rootDir.'/app/autoload.php';
+if (file_exists($file = __DIR__.'/autoload.php')) {
+    require_once $file;
+} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
+    require_once $file;
+}

+ 31 - 0
Tests/tests/vendors.php

@@ -0,0 +1,31 @@
+#!/usr/bin/env php
+<?php
+
+set_time_limit(0);
+
+
+$vendorDir = __DIR__.'/../../vendor';
+if (!is_dir($vendorDir)) {
+  mkdir($vendorDir);
+}
+
+$deps = array(
+    array('symfony', 'git://github.com/symfony/symfony.git', 'v2.0.5'),
+    array('Sonata/AdminBundle', 'git://github.com/sonata-project/SonataAdminBundle.git', 'master'),
+    array('doctrine', 'git://github.com/doctrine/doctrine2.git', 'master'),
+    array('doctrine-common', 'git://github.com/doctrine/common.git', 'master'),
+    array('knpmenu', 'git://github.com/knplabs/KnpMenu.git', 'master')
+);
+
+foreach ($deps as $dep) {
+    list($name, $url, $rev) = $dep;
+
+    echo "> Installing/Updating $name\n";
+
+    $installDir = $vendorDir.'/'.$name;
+    if (!is_dir($installDir)) {
+        system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir)));
+    }
+
+    system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
+}