Пример #1
0
<?php

namespace mageekguy\atoum\ruler;

use mageekguy\atoum;
$vendorDirectory = __DIR__ . '/vendor';
if (is_dir($vendorDirectory) === false) {
    $vendorDirectory = __DIR__ . '/../..';
}
$hoa = array('hoa/core' => 'Core.php', 'hoa/consistency' => 'Prelude.php', 'hoa/protocol' => 'Wrapper.php', 'hoa/compiler' => null, 'hoa/event' => null, 'hoa/exception' => null, 'hoa/file' => null, 'hoa/iterator' => null, 'hoa/math' => null, 'hoa/regex' => null, 'hoa/ruler' => null, 'hoa/stream' => null, 'hoa/string' => null, 'hoa/ustring' => null, 'hoa/visitor' => null, 'hoa/zformat' => null);
foreach ($hoa as $library => $file) {
    $parts = explode('/', $library);
    $parts = array_map('ucfirst', $parts);
    $namespace = implode('\\', $parts);
    $root = $vendorDirectory . DIRECTORY_SEPARATOR . $library;
    if (is_dir($root)) {
        if (null === $file) {
            atoum\autoloader::get()->addDirectory($namespace, $root);
        } else {
            if (file_exists($root . DIRECTORY_SEPARATOR . $file)) {
                atoum\autoloader::get()->addDirectory($namespace, $root);
                require_once $root . DIRECTORY_SEPARATOR . $file;
            }
        }
    }
}
atoum\autoloader::get()->addNamespaceAlias('atoum\\ruler', __NAMESPACE__)->addDirectory(__NAMESPACE__, __DIR__ . '/classes');
Пример #2
0
<?php

namespace mageekguy\atoum\vw;

use mageekguy\atoum;
atoum\autoloader::get()->addNamespaceAlias('atoum\\vw', __NAMESPACE__)->addDirectory(__NAMESPACE__, __DIR__ . DIRECTORY_SEPARATOR . 'classes');
Пример #3
0
<?php

namespace jdecool\atoum\symfonyDependencyInjection;

use mageekguy\atoum;
atoum\autoloader::get()->addNamespaceAlias('atoum\\symfonyDependencyInjection', __NAMESPACE__)->addDirectory(__NAMESPACE__, __DIR__ . DIRECTORY_SEPARATOR . 'classes');
Пример #4
0
 protected function doRun()
 {
     parent::doRun();
     if ($this->argumentsParser->hasFoundArguments() === false) {
         $this->argumentsParser->parse($this, $this->defaultArguments);
     }
     if (sizeof($this->runner->getTestPaths()) <= 0 && sizeof($this->runner->getDeclaredTestClasses()) <= 0) {
         $this->writeError($this->locale->_('No test found'))->help();
     } else {
         $arguments = $this->argumentsParser->getValues();
         if (sizeof($arguments) <= 0) {
             $this->verbose($this->locale->_('Using no CLI argument…'));
         } else {
             $this->verbose(sprintf($this->locale->__('Using %s CLI argument…', 'Using %s arguments…', sizeof($arguments)), $this->argumentsParser));
         }
         if (sizeof($this->configFiles) > 0) {
             foreach ($this->configFiles as $configFile) {
                 $this->verbose($this->locale->_('Using \'%s\' configuration file…', $configFile));
             }
         }
         $bootstrapFile = $this->runner->getBootstrapFile();
         if ($bootstrapFile !== null) {
             $this->verbose($this->locale->_('Using \'%s\' bootstrap file…', $bootstrapFile));
         }
         foreach (atoum\autoloader::getRegisteredAutoloaders() as $autoloader) {
             $this->verbose($this->locale->_('Using \'%s\' autoloader cache file…', $autoloader->getCacheFileForInstance()));
         }
         foreach ($this->runner->getTestPaths() as $testPath) {
             $this->verbose($this->locale->_('Using \'%s\' test file…', $testPath), 2);
         }
         if ($this->loop === true) {
             $this->loop();
         } else {
             if ($this->runner->hasReports() === false) {
                 $this->addDefaultReport();
             }
             $methods = $this->methods;
             $oldFailMethods = array();
             if ($this->scoreFile !== null && ($scoreFileContents = @file_get_contents($this->scoreFile)) !== false && ($oldScore = @unserialize($scoreFileContents)) instanceof atoum\score) {
                 $oldFailMethods = self::getFailMethods($oldScore);
                 if ($oldFailMethods) {
                     $methods = $oldFailMethods;
                 }
             }
             $newScore = $this->runner->run($this->namespaces, $this->tags, $this->getClassesOf($methods), $methods);
             $this->saveScore($newScore);
             if ($oldFailMethods && sizeof(self::getFailMethods($newScore)) <= 0) {
                 $testMethods = $this->runner->getTestMethods($this->namespaces, $this->tags, $this->methods);
                 if (sizeof($testMethods) > 1 || sizeof(current($testMethods)) > 1) {
                     $this->saveScore($this->runner->run($this->namespaces, $this->tags, $this->getClassesOf($this->methods), $this->methods));
                 }
             }
         }
     }
     return $this;
 }
Пример #5
0
<?php

namespace mageekguy\atoum\reports;

use mageekguy\atoum;
$directories = [__DIR__ . DIRECTORY_SEPARATOR . 'vendor', __DIR__ . DIRECTORY_SEPARATOR . '../..'];
$vendorDir = null;
foreach ($directories as $directory) {
    if (is_dir($directory)) {
        $vendorDir = $directory;
        break;
    }
}
if ($vendorDir === null) {
    throw new \Exception('Unable to find the vendor directory');
}
$filesystemDir = $vendorDir . DIRECTORY_SEPARATOR . 'symfony' . DIRECTORY_SEPARATOR . 'filesystem';
$filesystemSuffix = 'Symfony' . DIRECTORY_SEPARATOR . 'Component' . DIRECTORY_SEPARATOR . 'Filesystem';
if (is_dir($filesystemDir . DIRECTORY_SEPARATOR . $filesystemSuffix) === true) {
    $filesystemDir = $filesystemDir . DIRECTORY_SEPARATOR . $filesystemSuffix;
}
atoum\autoloader::get()->addNamespaceAlias('atoum\\reports', __NAMESPACE__)->addDirectory(__NAMESPACE__, __DIR__ . DIRECTORY_SEPARATOR . 'classes')->addDirectory('Symfony\\Component\\Filesystem', $filesystemDir);
require_once $vendorDir . DIRECTORY_SEPARATOR . 'twig' . DIRECTORY_SEPARATOR . 'twig' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Twig' . DIRECTORY_SEPARATOR . 'Autoloader.php';
$twigAutoloader = new \Twig_Autoloader();
$twigAutoloader->register();
Пример #6
0
<?php

namespace mageekguy\atoum\reports\tests;

use mageekguy\atoum;
require_once __DIR__ . '/../autoloader.php';
atoum\autoloader::get()->addDirectory(__NAMESPACE__, __DIR__);
Пример #7
0
<?php

namespace mageekguy\atoum\phpunit;

use mageekguy\atoum;
atoum\autoloader::get()->addNamespaceAlias('atoum\\phpunit', __NAMESPACE__)->addClassAlias('atoum\\phpunit', __NAMESPACE__ . '\\test')->addClassAlias('mageekguy\\atoum\\phpunit', __NAMESPACE__ . '\\test')->addDirectory(__NAMESPACE__, __DIR__ . DIRECTORY_SEPARATOR . 'classes');
$isPhpUnit = isset($_SERVER['argv'][0]) && preg_match('/phpunit$/', $_SERVER['argv'][0]);
if ($isPhpUnit === false) {
    $aliases = array('PHPUnit_Framework_TestCase' => 'mageekguy\\atoum\\phpunit\\test', 'PHPUnit_Framework_Constraint' => 'mageekguy\\atoum\\phpunit\\constraint', 'PHPUnit_Framework_AssertionFailedError' => 'mageekguy\\atoum\\asserter\\exception', 'PHPUnit_Framework_Exception' => 'mageekguy\\atoum\\exceptions\\runtime', 'PHPUnit_Framework_ExpectationFailedException' => 'mageekguy\\atoum\\phpunit\\constraint\\exception');
    foreach ($aliases as $phpunitClass => $atoumClass) {
        if (class_exists($phpunitClass, false)) {
            throw new atoum\exceptions\logic(sprintf('Class %s already exists', $phpunitClass));
        }
        atoum\autoloader::get()->addClassAlias($phpunitClass, $atoumClass);
    }
}
Пример #8
0
<?php

namespace Sohoa\Framework\Tests\Unit;

use mageekguy\atoum;
require_once __DIR__ . '/../../vendor/autoload.php';
atoum\autoloader::get()->addDirectory(__NAMESPACE__ . '\\Asserters', __DIR__ . '/Asserters');
Пример #9
0
<?php

namespace mageekguy\atoum\tests\units;

require_once __DIR__ . '/../../scripts/runner.php';
\mageekguy\atoum\autoloader::get()->addDirectory(__NAMESPACE__, __DIR__ . '/classes')->addDirectory(__NAMESPACE__ . '\\asserters', __DIR__ . '/asserters');
Пример #10
0
 public function testAddDirectory()
 {
     $this->if($autoloader = new atoum\autoloader())->then->object($autoloader->addDirectory($namespace = uniqid(), $directory = uniqid()))->isIdenticalTo($autoloader)->array($autoloader->getDirectories())->isEqualTo(array('mageekguy\\atoum\\' => array(atoum\directory . (\phar::running() ? '/' : DIRECTORY_SEPARATOR) . 'classes' . DIRECTORY_SEPARATOR), $namespace . '\\' => array($directory . DIRECTORY_SEPARATOR)))->object($autoloader->addDirectory($otherNamespace = uniqid() . '\\', $otherDirectory = uniqid() . DIRECTORY_SEPARATOR))->isIdenticalTo($autoloader)->array($autoloader->getDirectories())->isEqualTo(array('mageekguy\\atoum\\' => array(atoum\directory . (\phar::running() ? '/' : DIRECTORY_SEPARATOR) . 'classes' . DIRECTORY_SEPARATOR), $namespace . '\\' => array($directory . DIRECTORY_SEPARATOR), $otherNamespace => array($otherDirectory)))->object($autoloader->addDirectory($namespace, $secondDirectory = uniqid() . DIRECTORY_SEPARATOR))->isIdenticalTo($autoloader)->array($autoloader->getDirectories())->isEqualTo(array('mageekguy\\atoum\\' => array(atoum\directory . (\phar::running() ? '/' : DIRECTORY_SEPARATOR) . 'classes' . DIRECTORY_SEPARATOR), $namespace . '\\' => array($directory . DIRECTORY_SEPARATOR, $secondDirectory), $otherNamespace => array($otherDirectory)));
 }
Пример #11
0
<?php

namespace mageekguy\atoum\tests\functionals;

use mageekguy\atoum;
if (defined('atoum\\scripts\\runner') === false) {
    define('atoum\\scripts\\runner', __FILE__);
}
require_once __DIR__ . '/../../scripts/runner.php';
atoum\autoloader::get()->addDirectory(__NAMESPACE__ . '\\test', __DIR__ . '/test');
Пример #12
0
<?php

namespace mageekguy\atoum\phpunit\tests;

use mageekguy\atoum;
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoloader.php';
atoum\autoloader::get()->addDirectory(__NAMESPACE__, __DIR__)->addDirectory('mageekguy\\atoum\\autoloop', __DIR__ . DIRECTORY_SEPARATOR . '../vendor/atoum/autoloop-extension/classes')->addDirectory('Lurker', __DIR__ . DIRECTORY_SEPARATOR . '../vendor/henrikbjorn/lurker/src/Lurker')->addDirectory('Symfony\\Component\\EventDispatcher', __DIR__ . DIRECTORY_SEPARATOR . '../vendor/symfony/event-dispatcher')->addDirectory('Symfony\\Component\\Config', __DIR__ . DIRECTORY_SEPARATOR . '../vendor/symfony/config');
Пример #13
0
 public function testSetCacheFileForInstance()
 {
     $this->if($autoloader = new testedClass())->then->object($autoloader->setCacheFileForInstance($path = uniqid()))->isIdenticalTo($autoloader)->string($autoloader->getCacheFileForInstance())->isEqualTo($path);
 }