Exemplo n.º 1
0
/**/
/*
CODE COVERAGE SETUP
*/
if (!file_exists('/home/travis')) {
    // Please replace in next line "Project Name" by your project name and "/path/to/destination/directory" by your destination directory path for html files.
    $coverageField = new atoum\report\fields\runner\coverage\html('BFW', '/home/bfw/www/reports/bfw-v2');
    // Please replace in next line http://url/of/web/site by the root url of your code coverage web site.
    $coverageField->setRootUrl('http://bfw.test.bulton.fr/reports/bfw-v2/');
    $report->addField($coverageField);
}
/**/
/*
TEST GENERATOR SETUP
*/
$testGenerator = new atoum\test\generator();
// Please replace in next line "/path/to/your/tests/units/classes/directory" by your unit test's directory.
$testGenerator->setTestClassesDirectory(__DIR__ . '/test/classes');
// Please replace in next line "your\project\namespace\tests\units" by your unit test's namespace.
$testGenerator->setTestClassNamespace('BFW\\test\\unit');
// Please replace in next line "/path/to/your/classes/directory" by your classes directory.
$testGenerator->setTestedClassesDirectory(__DIR__ . '/src/classes');
// Please replace in next line "your\project\namespace" by your project namespace.
$testGenerator->setTestedClassNamespace('BFW');
// Please replace in next line "path/to/your/tests/units/runner.php" by path to your unit test's runner.
//$testGenerator->setRunnerPath('path/to/your/tests/units/runner.php');
$script->getRunner()->setTestGenerator($testGenerator);
/**/
if (file_exists('/home/travis')) {
    /*
    Publish code coverage report on coveralls.io
<?php

use mageekguy\atoum;
$runner = $script->getRunner();
if (false === $runner->hasReports()) {
    $report = $script->addDefaultReport();
    $report->addField(new atoum\report\fields\runner\atoum\logo());
} else {
    $reports = $runner->getReports();
    $report = current($reports);
}
$testGenerator = new atoum\test\generator();
$runner->setTestGenerator($testGenerator->setTestClassesDirectory($testsDirectory = __DIR__ . '/Tests/Units')->setTestClassNamespace('Hoathis\\Bundle\\ResourceLocatorBundle\\Tests\\Units')->setTestedClassesDirectory(__DIR__)->setTestedClassNamespace('Hoathis\\Bundle\\ResourceLocatorBundle'))->addTestsFromDirectory($testsDirectory);
$script->noCodeCoverageForNamespaces('Symfony')->noCodeCoverageForClasses('Hoa');
Exemplo n.º 3
0
$coverageField->setRootUrl('http://url/of/web/site');

$report->addField($coverageField);
*/
/*
TEST GENERATOR SETUP

$testGenerator = new atoum\test\generator();

// Please replace in next line "/path/to/your/tests/units/classes/directory" by your unit test's directory.
$testGenerator->setTestClassesDirectory('path/to/your/tests/units/classes/directory');

// Please replace in next line "your\project\namespace\tests\units" by your unit test's namespace.
$testGenerator->setTestClassNamespace('your\project\namespace\tests\units');

// Please replace in next line "/path/to/your/classes/directory" by your classes directory.
$testGenerator->setTestedClassesDirectory('path/to/your/classes/directory');

// Please replace in next line "your\project\namespace" by your project namespace.
$testGenerator->setTestedClassNamespace('your\project\namespace');

// Please replace in next line "path/to/your/tests/units/runner.php" by path to your unit test's runner.
$testGenerator->setRunnerPath('path/to/your/tests/units/runner.php');

$script->getRunner()->setTestGenerator($testGenerator);
*/
$testGenerator = new atoum\test\generator();
$testGenerator->setTestClassesDirectory(__DIR__ . "/tests/unitse");
$testGenerator->setTestedClassesDirectory(__DIR__ . "/src");
$testGenerator->setTestedClassNamespace('fullPhp/');
$script->getRunner()->setTestGenerator($testGenerator);
Exemplo n.º 4
0
 public function testGenerate()
 {
     $this->if($generator = new testedClass())->and($generator->setAdapter($adapter = new atoum\test\adapter()))->and($generator->setPathFactory($pathFactory = new \mock\mageekguy\atoum\fs\path\factory()))->and($generator->setTemplateParser($templateParser = new \mock\mageekguy\atoum\template\parser()))->then->exception(function () use($generator) {
         $generator->generate(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\test\\generator\\exception')->hasMessage('Tested classes directory is undefined')->if($generator->setTestedClassesDirectory($classesDirectory = uniqid()))->then->exception(function () use($generator) {
         $generator->generate(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\test\\generator\\exception')->hasMessage('Tests directory is undefined')->if($generator->setTestClassesDirectory($testsDirectory = DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('a', 'b', 'c'))))->then->exception(function () use($generator) {
         $generator->generate(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\test\\generator\\exception')->hasMessage('Tested class namespace is undefined')->if($generator->setTestedClassNamespace($testedClassNamespace = uniqid()))->then->exception(function () use($generator) {
         $generator->generate(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\test\\generator\\exception')->hasMessage('Test class namespace is undefined')->if($generator->setTestClassNamespace($testClassNamespace = uniqid()))->and($testClassesDirectoryPath = new \mock\mageekguy\atoum\fs\path(DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('a', 'b', 'c'))))->and($this->calling($testClassesDirectoryPath)->exists = true)->and($this->calling($testClassesDirectoryPath)->getRealPath = $testClassesDirectoryPath)->and($testedClassPath = new \mock\mageekguy\atoum\fs\path(DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('x', 'y', 'z', 'f.php'))))->and($this->calling($testedClassPath)->putContents = $testedClassPath)->and($testClassPath = new \mock\mageekguy\atoum\fs\path(DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('a', 'b', 'c', 'd', 'e', 'f.php'))))->and($this->calling($testClassPath)->getRealParentDirectoryPath = new \mock\mageekguy\atoum\fs\path(DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('a', 'b', 'c', 'd', 'e'))))->and($this->calling($testClassPath)->getRealPath = $testClassPath)->and($this->calling($testClassPath)->putContents = $testClassPath)->and($this->calling($pathFactory)->build = function ($path) use($testClassesDirectoryPath, $testClassPath, $testedClassPath) {
         switch ($path) {
             case (string) $testClassesDirectoryPath . DIRECTORY_SEPARATOR:
                 return $testClassesDirectoryPath;
             case (string) $testClassPath:
                 return $testClassPath;
             default:
                 return $testedClassPath;
         }
     })->then->object($generator->generate((string) $testClassPath))->isIdenticalTo($generator)->mock($templateParser)->call('parseFile')->withArguments($generator->getTemplatesDirectory() . DIRECTORY_SEPARATOR . 'testClass.php')->once();
 }