Skip to content

Commit

Permalink
basic testability additions
Browse files Browse the repository at this point in the history
Modified phpunit.xml.dist to reflect less poor understanding
of the tool. Added basic composer stuff so that Travis will
work.
  • Loading branch information
winmillwill committed May 16, 2012
1 parent 6015b1f commit c25bec3
Show file tree
Hide file tree
Showing 11 changed files with 282 additions and 10 deletions.
14 changes: 14 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions phpunit.xml.dist
Expand Up @@ -15,14 +15,5 @@
<testsuite name="Negotiator Test Suite">
<directory>./tests/BadFaith</directory>
</testsuite>
<testsuite name="AcceptLike Test Suite">
<directory>./tests/BadFaith</directory>
</testsuite>
<testsuite name="AcceptLikeList Test Suite">
<directory>./tests/BadFaith</directory>
</testsuite>
<testsuite name="AcceptList Test Suite">
<directory>./tests/BadFaith</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion tests/BadFaith/Tests/ItemCollectionTest.php
Expand Up @@ -38,4 +38,4 @@ public function testExpectedOrder($expected, $given)
$this->assertEquals($expected[$i++], $item->getPref());
}
}
}
}
5 changes: 5 additions & 0 deletions vendor/.composer/ClassLoader.php
@@ -0,0 +1,5 @@
<?php
// Deprecated file, use the one in root of vendor dir
trigger_error(__FILE__.' is deprecated, please use vendor/autoload.php or vendor/composer/autoload_* instead'.PHP_EOL.'See https://groups.google.com/forum/#!msg/composer-dev/fWIs3KocwoA/nU3aLko9LhQJ for details', E_USER_DEPRECATED);

return include dirname(__DIR__).'/composer/ClassLoader.php';
5 changes: 5 additions & 0 deletions vendor/.composer/autoload.php
@@ -0,0 +1,5 @@
<?php
// Deprecated file, use the one in root of vendor dir
trigger_error(__FILE__.' is deprecated, please use vendor/autoload.php or vendor/composer/autoload_* instead'.PHP_EOL.'See https://groups.google.com/forum/#!msg/composer-dev/fWIs3KocwoA/nU3aLko9LhQJ for details', E_USER_DEPRECATED);

return include dirname(__DIR__).'/autoload.php';
5 changes: 5 additions & 0 deletions vendor/.composer/autoload_classmap.php
@@ -0,0 +1,5 @@
<?php
// Deprecated file, use the one in root of vendor dir
trigger_error(__FILE__.' is deprecated, please use vendor/autoload.php or vendor/composer/autoload_* instead'.PHP_EOL.'See https://groups.google.com/forum/#!msg/composer-dev/fWIs3KocwoA/nU3aLko9LhQJ for details', E_USER_DEPRECATED);

return include dirname(__DIR__).'/composer/autoload_classmap.php';
5 changes: 5 additions & 0 deletions vendor/.composer/autoload_namespaces.php
@@ -0,0 +1,5 @@
<?php
// Deprecated file, use the one in root of vendor dir
trigger_error(__FILE__.' is deprecated, please use vendor/autoload.php or vendor/composer/autoload_* instead'.PHP_EOL.'See https://groups.google.com/forum/#!msg/composer-dev/fWIs3KocwoA/nU3aLko9LhQJ for details', E_USER_DEPRECATED);

return include dirname(__DIR__).'/composer/autoload_namespaces.php';
25 changes: 25 additions & 0 deletions vendor/autoload.php
@@ -0,0 +1,25 @@
<?php

// autoload.php generated by Composer
if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
require __DIR__ . '/composer' . '/ClassLoader.php';
}

return call_user_func(function() {
$loader = new \Composer\Autoload\ClassLoader();
$composerDir = __DIR__ . '/composer';

$map = require $composerDir . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
}

$classMap = require $composerDir . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}

$loader->register();

return $loader;
});
203 changes: 203 additions & 0 deletions vendor/composer/ClassLoader.php
@@ -0,0 +1,203 @@
<?php

/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Composer\Autoload;

/**
* ClassLoader implements a PSR-0 class loader
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ClassLoader
{
private $prefixes = array();
private $fallbackDirs = array();
private $useIncludePath = false;
private $classMap = array();

public function getPrefixes()
{
return $this->prefixes;
}

public function getFallbackDirs()
{
return $this->fallbackDirs;
}

public function getClassMap()
{
return $this->classMap;
}

/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}

/**
* Registers a set of classes
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
*/
public function add($prefix, $paths)
{
if (!$prefix) {
foreach ((array) $paths as $path) {
$this->fallbackDirs[] = $path;
}
return;
}
if (isset($this->prefixes[$prefix])) {
$this->prefixes[$prefix] = array_merge(
$this->prefixes[$prefix],
(array) $paths
);
} else {
$this->prefixes[$prefix] = (array) $paths;
}
}

/**
* Turns on searching the include path for class files.
*
* @param Boolean $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}

/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return Boolean
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}

/**
* Registers this instance as an autoloader.
*
* @param Boolean $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}

/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}

/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return Boolean|null True, if loaded
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
require $file;
return true;
}
}

/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|null The path, if found
*/
public function findFile($class)
{
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}

if ('\\' == $class[0]) {
$class = substr($class, 1);
}

if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
} else {
// PEAR-like class name
$classPath = null;
$className = $class;
}

$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

foreach ($this->prefixes as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
}
}
}
}

foreach ($this->fallbackDirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
}
}

if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
return $file;
}
}
}
9 changes: 9 additions & 0 deletions vendor/composer/autoload_classmap.php
@@ -0,0 +1,9 @@
<?php

// autoload_classmap.php generated by Composer

$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
);
10 changes: 10 additions & 0 deletions vendor/composer/autoload_namespaces.php
@@ -0,0 +1,10 @@
<?php

// autoload_namespace.php generated by Composer

$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
'BadFaith' => $baseDir . '/lib/',
);

0 comments on commit c25bec3

Please sign in to comment.