Skip to content

Commit

Permalink
Fix tests, and make them work with http://travis-ci.org
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Rabaix committed Nov 13, 2011
1 parent 68a5524 commit 81b704a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
@@ -0,0 +1,4 @@
language: php
php: 5.3.8
before_script: php Tests/tests/vendors.php
script: phpunit
4 changes: 2 additions & 2 deletions Tests/Admin/PoolTest.php
Expand Up @@ -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()
Expand Down Expand Up @@ -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'));
}
Expand Down
25 changes: 25 additions & 0 deletions Tests/tests/autoload.php.dist
@@ -0,0 +1,25 @@
<?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'),
));
$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;
}
});
9 changes: 5 additions & 4 deletions Tests/tests/bootstrap.php
Expand Up @@ -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';
if (file_exists($file = __DIR__.'/autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
}
28 changes: 28 additions & 0 deletions Tests/tests/vendors.php
@@ -0,0 +1,28 @@
#!/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('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)));
}

0 comments on commit 81b704a

Please sign in to comment.