diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..412c5216ef --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: php +php: 5.3.8 +before_script: php Tests/tests/vendors.php +script: phpunit \ No newline at end of file diff --git a/Tests/Admin/PoolTest.php b/Tests/Admin/PoolTest.php index 10c82e2f8c..612100e2ca 100644 --- a/Tests/Admin/PoolTest.php +++ b/Tests/Admin/PoolTest.php @@ -22,7 +22,7 @@ class PoolTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->pool = new Pool($this->getContainer()); + $this->pool = new Pool($this->getContainer(), 'Sonata Admin', '/path/to/pic.png'); } public function testGetGroups() @@ -93,7 +93,7 @@ public function testGetAdminByAdminCodeForChildClass() ->method('get') ->will($this->returnValue($adminMock)); - $this->pool = new Pool($containerMock); + $this->pool = new Pool($containerMock, 'Sonata', '/path/to/logo.png'); $this->assertEquals('commentAdminClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post|sonata.news.admin.comment')); } diff --git a/Tests/tests/autoload.php.dist b/Tests/tests/autoload.php.dist new file mode 100644 index 0000000000..ad7afae7e7 --- /dev/null +++ b/Tests/tests/autoload.php.dist @@ -0,0 +1,25 @@ +registerNamespaces(array( + 'Symfony' => array($vendorDir.'/symfony/src'), + 'Knp' => array($vendorDir.'/knpmenu/src'), +)); +$loader->register(); + +spl_autoload_register(function($class) { + if (0 === strpos($class, 'Sonata\\AdminBundle\\')) { + $path = __DIR__.'/../../'.implode('/', array_slice(explode('\\', $class), 2)).'.php'; + + if (!stream_resolve_include_path($path)) { + return false; + } + require_once $path; + return true; + } +}); \ No newline at end of file diff --git a/Tests/tests/bootstrap.php b/Tests/tests/bootstrap.php index 407a3e4692..0a3975ea0a 100644 --- a/Tests/tests/bootstrap.php +++ b/Tests/tests/bootstrap.php @@ -9,7 +9,8 @@ * 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'; \ No newline at end of file +if (file_exists($file = __DIR__.'/autoload.php')) { + require_once $file; +} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) { + require_once $file; +} \ No newline at end of file diff --git a/Tests/tests/vendors.php b/Tests/tests/vendors.php new file mode 100644 index 0000000000..7c16c32815 --- /dev/null +++ b/Tests/tests/vendors.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php + 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))); +}