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(); }
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 */ $sources = './src'; $token = 'ycIQWlEx47Xh3QzvlQ4kxh3jOHHo55m1E'; $coverallsReport = new reports\asynchronous\coveralls($sources, $token);