Skip to content

Commit

Permalink
[zen-60] Specify doctrine/common dependency
Browse files Browse the repository at this point in the history
- Added doctrine/common dependency to composer.json
- Updated travis configuration to ensure dependencies from composer are
  installed before running tests (suggested by ocramius)
- Modified test autoloader to use composer + StandardAutoloader
  • Loading branch information
weierophinney committed Jun 28, 2012
1 parent 4f5263e commit fb4d379
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 52 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ php:

before_install:
- cp tests/TestConfiguration.php.travis tests/TestConfiguration.php
- curl -s http://getcomposer.org/installer | php
- php composer.phar install

script:
- php ./tests/run-tests.php

notifications:
irc: "irc.freenode.org#zftalk.2"
irc: "irc.freenode.org#zftalk.2"
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"homepage": "http://framework.zend.com/",
"license": "BSD-3-Clause",
"require": {
"php": ">=5.3.3"
"php": ">=5.3.3",
"doctrine/common": ">=2.1"
},
"autoload": {
"psr-0": {
Expand Down
59 changes: 9 additions & 50 deletions tests/_autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,14 @@
/**
* Setup autoloading
*/
function ZendTest_Autoloader($class)
{
$class = ltrim($class, '\\');

if (!preg_match('#^(Zend(Test)?|PHPUnit)(\\\\|_)#', $class)) {
return false;
}

// $segments = explode('\\', $class); // preg_split('#\\\\|_#', $class);//
$segments = preg_split('#[\\\\_]#', $class); // preg_split('#\\\\|_#', $class);//
$ns = array_shift($segments);

switch ($ns) {
case 'Zend':
$file = dirname(__DIR__) . '/library/Zend/';
break;
case 'ZendTest':
// temporary fix for ZendTest namespace until we can migrate files
// into ZendTest dir
$file = __DIR__ . '/Zend/';
break;
default:
$file = false;
break;
}

if ($file) {
$file .= implode('/', $segments) . '.php';
if (file_exists($file)) {
return include_once $file;
}
}

$segments = explode('_', $class);
$ns = array_shift($segments);

switch ($ns) {
case 'Zend':
$file = dirname(__DIR__) . '/library/Zend/';
break;
default:
return false;
}
$file .= implode('/', $segments) . '.php';
if (file_exists($file)) {
return include_once $file;
}

return false;
if (!include_once __DIR__ . '/../vendor/autoload.php') {
throw new UnexpectedValueException('Could not find composer; did you run `php composer.phar install`?');
}
spl_autoload_register('ZendTest_Autoloader', true, true);

$loader = new Zend\Loader\StandardAutoloader(array(
Zend\Loader\StandardAutoloader::LOAD_NS => array(
'Zend' => __DIR__ . '/../library',
'ZendTest' => __DIR__ . '/Zend',
),
));
$loader->register();
5 changes: 5 additions & 0 deletions vendor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!.gitignore
.composer
composer
doctrine
autoload.php

0 comments on commit fb4d379

Please sign in to comment.