Skip to content

Commit

Permalink
travis-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Nov 12, 2011
1 parent a2f9af0 commit b8af36f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/phpunit.xml

vendor/imagine
vendor/symfony
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: php
php: 5.3.8
before_script: php vendor/vendors.php
script: phpunit --colors -c phpunit.xml.dist
24 changes: 24 additions & 0 deletions Tests/autoload.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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'),
'Imagine' => array($vendorDir.'/imagine/lib'),
));
$loader->register();

spl_autoload_register(function($class) {
if (0 === strpos($class, 'Liip\\ImagineBundle\\')) {
$path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 2)).'.php';
if (!stream_resolve_include_path($path)) {
return false;
}
require_once $path;
return true;
}
});
27 changes: 4 additions & 23 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
<?php

spl_autoload_register(function($class) {
$class = ltrim($class, '\\');
if (0 === strpos($class, 'Liip\ImagineBundle\\')) {
$file = __DIR__.'/../'.str_replace('\\', '/', substr($class, strlen('Liip\ImagineBundle\\'))).'.php';
if (file_exists($file)) {
require $file;
}
}
});

if (!defined('SYMFONY_SRC_DIR') || 'NOT_SET' === SYMFONY_SRC_DIR) {
throw new \RuntimeException('You must set the Symfony src dir');
}

if (!defined('IMAGINE_SRC_DIR') || 'NOT_SET' === IMAGINE_SRC_DIR) {
throw new \RuntimeException('You must set the Imagine src dir');
if (file_exists($file = __DIR__.'/autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
}

require_once SYMFONY_SRC_DIR.'/Symfony/Component/ClassLoader/UniversalClassLoader.php';

$loader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
$loader->registerNamespace('Symfony', SYMFONY_SRC_DIR);
$loader->registerNamespace('Imagine', IMAGINE_SRC_DIR);
$loader->register();
6 changes: 0 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,4 @@
</whitelist>
</filter>

<php>
<!-- path to the Symfony src dir -->
<const name="SYMFONY_SRC_DIR" value="../../../symfony/src" />
<!-- path to the Imagine src dir -->
<const name="IMAGINE_SRC_DIR" value="../../../imagine/src" />
</php>
</phpunit>
28 changes: 28 additions & 0 deletions vendor/vendors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env php
<?php

set_time_limit(0);

if (!is_dir($vendorDir = __DIR__)) {
mkdir($vendorDir, 0777, true);
}

$deps = array(
array('symfony', 'http://github.com/symfony/symfony', 'v2.0.5'),
array('imagine', 'http://github.com/avalanche123/Imagine', 'v0.2.6'),
);

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)));
}

if ($rev) {
system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
}
}

0 comments on commit b8af36f

Please sign in to comment.