public function setWithTest(atoum\test $test) { $this->reset(); $this->test = $test; $this->testedClassName = $test->getTestedClassName(); $this->phpClass->setWith($this->testedClassName); return parent::setWithTest($test); }
public function setWithTest(atoum\test $test) { if ($this->callIsSet()->adapter === null) { parent::setWith(clone php\mocker::getAdapter()); } $this->setFunction($test->getTestedClassNamespace() . '\\' . $this->getFunction()); return parent::setWithTest($test); }
public function run(atoum\test $test) { $currentTestMethod = $test->getCurrentMethod(); if ($currentTestMethod !== null) { $testScore = $test->getScore(); $test->setScore($this->score->reset())->runTestMethod($test->getCurrentMethod())->setScore($testScore); } return $this; }
public function setTest(test $test) { $asserter = null; $test->getAssertionManager()->setHandler('blackfireProfile', function ($client, $callback, $configuration) use($test, &$asserter) { if ($asserter === null) { $asserter = new atoum\blackfire\asserters\blackfireProfile($test->getAsserterGenerator()); } return $asserter->setWith($client, $callback, $configuration); }); return $this; }
public function setTest(test $test) { $asserter = null; $test->getAssertionManager()->setHandler('json', function ($json, $depth = null, $options = null) use($test, &$asserter) { if ($asserter === null) { $asserter = new atoum\jsonSchema\asserters\json($test->getAsserterGenerator()); } return $asserter->setWith($json, $depth, $options); }); return $this; }
public function run(atoum\test $test) { $currentTestMethod = $test->getCurrentMethod(); if ($currentTestMethod !== null) { $this->test = $test; $this->method = $currentTestMethod; $phpPath = $this->test->getPhpPath(); $phpCode = '<?php ' . 'ob_start();' . 'require \'' . atoum\directory . '/classes/autoloader.php\';'; $bootstrapFile = $this->test->getBootstrapFile(); if ($bootstrapFile !== null) { $phpCode .= '$includer = new mageekguy\\atoum\\includer();' . 'try { $includer->includePath(\'' . $bootstrapFile . '\'); }' . 'catch (mageekguy\\atoum\\includer\\exception $exception)' . '{ die(\'Unable to include bootstrap file \\\'' . $bootstrapFile . '\\\'\'); }'; } $phpCode .= 'require \'' . $this->test->getPath() . '\';' . '$test = new ' . $this->test->getClass() . '();' . '$test->setLocale(new ' . get_class($this->test->getLocale()) . '(' . $this->test->getLocale()->get() . '));' . '$test->setPhpPath(\'' . $phpPath . '\');'; if ($this->test->debugModeIsEnabled() === true) { $phpCode .= '$test->enableDebugMode();'; } if ($this->test->codeCoverageIsEnabled() === false) { $phpCode .= '$test->disableCodeCoverage();'; } else { if ($this->test->branchesAndPathsCoverageIsEnabled() === true) { $phpCode .= '$test->enableBranchesAndPathsCoverage();'; } $phpCode .= '$coverage = $test->getCoverage();'; foreach ($this->test->getCoverage()->getExcludedMethods() as $excludedMethod) { $phpCode .= '$coverage->excludeMethod(\'' . $excludedMethod . '\');'; } foreach ($this->test->getCoverage()->getExcludedClasses() as $excludedClass) { $phpCode .= '$coverage->excludeClass(\'' . $excludedClass . '\');'; } foreach ($this->test->getCoverage()->getExcludedNamespaces() as $excludedNamespace) { $phpCode .= '$coverage->excludeNamespace(\'' . $excludedNamespace . '\');'; } foreach ($this->test->getCoverage()->getExcludedDirectories() as $excludedDirectory) { $phpCode .= '$coverage->excludeDirectory(\'' . $excludedDirectory . '\');'; } } if ($this->test->getMockGenerator()->undefinedMethodUsageIsAllowed() === false) { $phpCode .= '$test->getMockGenerator()->disallowUndefinedMethodUsage();'; } foreach ($test->getExtensions() as $extension) { $phpCode .= '$test->addExtension(new ' . get_class($extension) . ');'; } $phpCode .= 'ob_end_clean();' . 'mageekguy\\atoum\\scripts\\runner::disableAutorun();' . 'echo serialize($test->runTestMethod(\'' . $this->method . '\')->getScore());'; $xdebugConfig = $test->getXdebugConfig(); if ($xdebugConfig !== null) { if (getenv('XDEBUG_CONFIG') !== false || ini_get('xdebug.remote_autostart') != 0) { throw new exceptions\runtime('XDEBUG_CONFIG variable must not be set or value of xdebug.remote_autostart must be 0 to use xdebug with concurrent engine'); } $this->php->XDEBUG_CONFIG = $xdebugConfig; } $this->php->reset()->setBinaryPath($phpPath)->run($phpCode); } return $this; }
/** * @param test $test * @return $this */ public function setTest(test $test) { if (null === $this->rule) { return $this; } $ruler = new ruler($this->rule); foreach ($test->getTestMethods() as $testMethod) { $isMethodIgnored = $ruler->isMethodIgnored($test, $testMethod); $test->ignoreMethod($testMethod, $isMethodIgnored); } return $this; }
public function setTest(test $test) { $test->getAssertionManager()->setHandler('invoke', function ($target) use($test) { if (is_string($target)) { $invoker = new invokers\klass(); } else { $invoker = new invokers\instance(); } return $invoker->setTarget($target); }); $test->setMockGenerator(new mock\generator($test)); return $this; }
public function setTest(atoum\test $test) { $this->test = $test; $asserter = null; $this->test->getAssertionManager()->setHandler('prophet', function ($classOrInterface = null) use($test, &$asserter) { if ($asserter === null) { $asserter = new asserters\prophet($test->getAsserterGenerator()); } $asserter->setWithTest($test); if ($classOrInterface !== null) { return $asserter->prophesize($classOrInterface); } return $asserter; }); return $this; }
public function beforeTestMethod($method) { parent::beforeTestMethod($method); new IdentityAnnotation(); // Fix Annotation not found error :( $this->reader = new AnnotationReader(); }
public function beforeTestMethod($method) { parent::beforeTestMethod($method); new Identity(); // Fix Annotation not found error :( $this->fqn = "LLS\\Bundle\\AWSBundle\\Tests\\Fixtures\\AnnotatedModel"; $this->instance = new Factory\GenericIdentityFactory($this->fqn, new AnnotationReader()); }
public function run(atoum\test $test) { $currentTestMethod = $test->getCurrentMethod(); if ($currentTestMethod !== null) { $this->test = $test; $this->method = $currentTestMethod; $this->stdOut = ''; $this->stdErr = ''; $phpPath = $this->test->getPhpPath(); $this->php = @call_user_func_array(array($this->adapter, 'proc_open'), array(escapeshellarg($phpPath), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), &$this->pipes)); if ($this->php === false) { throw new exceptions\runtime('Unable to use \'' . $phpPath . '\''); } $phpCode = '<?php ' . 'ob_start();' . 'require \'' . atoum\directory . '/classes/autoloader.php\';'; $bootstrapFile = $this->test->getBootstrapFile(); if ($bootstrapFile !== null) { $phpCode .= '$includer = new mageekguy\\atoum\\includer();' . 'try { $includer->includePath(\'' . $bootstrapFile . '\'); }' . 'catch (mageekguy\\atoum\\includer\\exception $exception)' . '{ die(\'Unable to include bootstrap file \\\'' . $bootstrapFile . '\\\'\'); }'; } $phpCode .= 'require \'' . $this->test->getPath() . '\';' . '$test = new ' . $this->test->getClass() . '();' . '$test->setLocale(new ' . get_class($this->test->getLocale()) . '(' . $this->test->getLocale()->get() . '));' . '$test->setPhpPath(\'' . $phpPath . '\');'; if ($this->test->debugModeIsEnabled() === true) { $phpCode .= '$test->enableDebugMode();'; } if ($this->test->codeCoverageIsEnabled() === false) { $phpCode .= '$test->disableCodeCoverage();'; } else { $phpCode .= '$coverage = $test->getCoverage();'; foreach ($this->test->getCoverage()->getExcludedClasses() as $excludedClass) { $phpCode .= '$coverage->excludeClass(\'' . $excludedClass . '\');'; } foreach ($this->test->getCoverage()->getExcludedNamespaces() as $excludedNamespace) { $phpCode .= '$coverage->excludeNamespace(\'' . $excludedNamespace . '\');'; } foreach ($this->test->getCoverage()->getExcludedDirectories() as $excludedDirectory) { $phpCode .= '$coverage->excludeDirectory(\'' . $excludedDirectory . '\');'; } } $phpCode .= 'ob_end_clean();' . 'mageekguy\\atoum\\scripts\\runner::disableAutorun();' . 'echo serialize($test->runTestMethod(\'' . $this->method . '\')->getScore());'; $this->adapter->fwrite($this->pipes[0], $phpCode); $this->adapter->fclose($this->pipes[0]); unset($this->pipes[0]); $this->adapter->stream_set_blocking($this->pipes[1], 0); $this->adapter->stream_set_blocking($this->pipes[2], 0); } return $this; }
public function setTest(test $test) { $asserter = null; $test->getAssertionManager()->setHandler('containerBuilder', function ($object) use($test, &$asserter) { if ($asserter === null) { $asserter = new atoum\symfonyDependencyInjection\asserters\containerBuilder($test->getAsserterGenerator()); } $asserter->setWithTest($test); return $asserter->setWith($object); })->setHandler('serviceDefinition', function ($object) use($test, &$asserter) { if ($asserter === null) { $asserter = new atoum\symfonyDependencyInjection\asserters\serviceDefinition($test->getAsserterGenerator()); } $asserter->setWithTest($test); return $asserter->setWith($object); }); return $this; }
/** * @param atoum\test\assertion\manager $assertionManager * * @return $this */ public function setAssertionManager(atoum\test\assertion\manager $assertionManager = null) { $self = $this; $returnFaker = function ($locale = 'en_US') use($self) { return $self->getFaker($locale); }; parent::setAssertionManager($assertionManager)->getAssertionManager()->setHandler('faker', $returnFaker); return $this; }
/** * @param atoum\annotations\extractor $extractor * * @return $this|void */ protected function setClassAnnotations(atoum\annotations\extractor $extractor) { parent::setClassAnnotations($extractor); $test = $this; $extractor->setHandler('resetKernel', function ($value) use($test) { $test->enableKernelReset(atoum\annotations\extractor::toBoolean($value)); })->setHandler('noResetKernel', function () use($test) { $test->enableKernelReset(false); }); }
public function setTest(test $test) { $asserter = null; $configuration = $test->getExtensionConfiguration($this); if ($configuration !== null) { $this->configuration = $configuration; } $test->getAssertionManager()->setHandler('blackfire', function (Client $client = null) use($test, &$asserter) { if ($asserter === null) { $asserter = new atoum\blackfire\asserters\blackfire($test->getAsserterGenerator()); } if (null === $client) { $client = new Client($this->configuration->getClientConfiguration()); } $asserter->setClient($client); $asserter->setWithTest($test); return $asserter; }); return $this; }
public function setAssertionManager(assertion\manager $assertionManager = null) { parent::setAssertionManager($assertionManager); $self = $this; $this->getAssertionManager()->sethandler('praspel', function () use($self) { return $self->getPraspel()->reset(); })->sethandler('requires', function ($value) use($self) { return $self->getPraspel()->requires($value); })->sethandler('ensures', function ($value) use($self) { return $self->getPraspel()->ensures($value); })->sethandler('verdict', function () use($self) { return $self->getPraspel()->verdict(); }); return $this; }
/** * @param test $test * @param string $methodNameToCheck * @return bool * @throws \RuntimeException */ public function isMethodIgnored(test $test, $methodNameToCheck) { $contexts = array(); foreach ($test->getTestMethods() as $methodName) { $contexts[$methodName] = new HoaContext(); $contexts[$methodName]['method'] = $methodName; $contexts[$methodName]['class'] = $test->getClass(); $contexts[$methodName]['namespace'] = $test->getClassNamespace(); $contexts[$methodName]['testedclass'] = $test->getTestedClassName(); $contexts[$methodName]['testedclassnamespace'] = $test->getTestedClassNamespace(); } foreach ($test->getMandatoryMethodExtensions() as $methodName => $extensions) { $contexts[$methodName]['extensions'] = $extensions; } foreach ($test->getMethodTags() as $methodName => $tags) { $contexts[$methodName]['tags'] = $tags; } if (!isset($contexts[$methodNameToCheck])) { throw new \RuntimeException(sprintf('Method not found : %s', $methodNameToCheck)); } return false === $this->ruler->assert($this->rule, $contexts[$methodNameToCheck]); }
public function setAssertionManager(test\assertion\manager $assertionManager = null) { $asserter = null; $spec = $this; parent::setAssertionManager($assertionManager)->getAssertionManager()->setHandler('invoking', function ($method = null) use(&$asserter, $spec) { if ($asserter === null) { $asserter = new asserters\invoking($spec->getAsserterGenerator()); $asserter->setWithTest($spec); } $asserter->reset(); if ($method !== null) { $asserter->setMethod($method); } $arguments = func_get_args(); array_shift($arguments); if (sizeof($arguments) > 0) { $asserter->setArguments($arguments); } return $asserter; }); return $this; }
public function __construct(atoum\test $test, atoum\locale $locale = null) { parent::__construct($locale ?: $test->getLocale()); $this->setTest($test); }
public function __construct(factory $factory = null) { $this->setTestNamespace('Tests\\Units'); parent::__construct($factory); }
public function beforeTestMethod($method) { parent::beforeTestMethod($method); $this->fqn = "LLS\\Bundle\\AWSBundle\\Tests\\Fixtures\\FakeService"; $this->instance = new Factory\GenericServiceFactory($this->fqn, array('setSomething', 'test')); }
public function setWithTest(atoum\test $test) { return $this->setScore($test->getScore()); }
function addToTest(atoum\test $test) { $test->setPhpFunctionMocker($this); return $this; }
public function setWithTest(atoum\test $test) { parent::setWith($test->getTestedClassName()); return parent::setWithTest($test); }
public function testGetTestedClassNameFromTestClass() { $this->string(atoum\test::getTestedClassNameFromTestClass(__CLASS__))->isEqualTo('mageekguy\\atoum\\test')->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\tests\\units\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->if(atoum\test::setNamespace('test\\unit'))->then->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\test\\unit\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->if(atoum\test::setNamespace('\\test\\unit\\'))->then->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\test\\unit\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->if(atoum\test::setNamespace('test\\unit\\'))->then->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\test\\unit\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->if(atoum\test::setNamespace('\\test\\unit'))->then->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\test\\unit\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->exception(function () { atoum\test::getTestedClassNameFromTestClass('foo\\bar\\aaa\\bbb\\testedClass'); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Test class \'foo\\bar\\aaa\\bbb\\testedClass\' is not in a namespace which contains \'' . atoum\test::getNamespace() . '\'')->if(atoum\test::setNamespace('#(?:^|\\\\)xxxs?\\\\yyys?\\\\#i'))->then->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\xxx\\yyy\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\xxxs\\yyy\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\xxxs\\yyys\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\xxx\\yyys\\testedClass'))->isEqualTo('foo\\bar\\testedClass')->exception(function () { atoum\test::getTestedClassNameFromTestClass('foo\\bar\\aaa\\bbb\\testedClass'); })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Test class \'foo\\bar\\aaa\\bbb\\testedClass\' is not in a namespace which match pattern \'' . atoum\test::getNamespace() . '\'')->string(atoum\test::getTestedClassNameFromTestClass('foo\\bar\\aaa\\bbb\\testedClass', '#(?:^|\\\\)aaas?\\\\bbbs?\\\\#i'))->isEqualTo('foo\\bar\\testedClass'); }
public function setWithTest(test $test) { $this->setScore($test->getScore()); return parent::setWithTest($test); }
public function setWithTest(test $test) { $this->setManager($test->getAsserterCallManager()); return parent::setWithTest($test); }
public function beforeTestMethod($method) { parent::beforeTestMethod($method); $this->container = new \mock\Symfony\Component\DependencyInjection\ContainerBuilder(); }
public function beforeTestMethod($method) { parent::beforeTestMethod($method); $this->instance = new Manager\ServiceManager(); }