상속: implements mageekguy\atoum\observable, implements countable
예제 #1
0
 public function setWithTest(atoum\test $test)
 {
     $this->reset();
     $this->test = $test;
     $this->testedClassName = $test->getTestedClassName();
     $this->phpClass->setWith($this->testedClassName);
     return parent::setWithTest($test);
 }
예제 #2
0
 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);
 }
예제 #3
0
파일: inline.php 프로젝트: ronan-gloo/atoum
 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;
 }
예제 #4
0
 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;
 }
예제 #5
0
 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;
 }
예제 #6
0
 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;
 }
예제 #7
0
 /**
  * @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;
 }
예제 #8
0
 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;
 }
예제 #9
0
 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;
 }
예제 #10
0
 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());
 }
예제 #12
0
 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;
 }
예제 #13
0
 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;
 }
예제 #14
0
파일: Test.php 프로젝트: SelviA/AtoumBundle
 /**
  * @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;
 }
예제 #15
0
파일: Test.php 프로젝트: aliel/AtoumBundle
 /**
  * @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);
     });
 }
예제 #16
0
 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;
 }
예제 #17
0
 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;
 }
예제 #18
0
 /**
  * @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]);
 }
예제 #19
0
 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;
 }
예제 #20
0
 public function __construct(atoum\test $test, atoum\locale $locale = null)
 {
     parent::__construct($locale ?: $test->getLocale());
     $this->setTest($test);
 }
예제 #21
0
파일: Unit.php 프로젝트: euskadi31/spore
 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'));
 }
예제 #23
0
 public function setWithTest(atoum\test $test)
 {
     return $this->setScore($test->getScore());
 }
예제 #24
0
파일: funktion.php 프로젝트: xihewang/atoum
 function addToTest(atoum\test $test)
 {
     $test->setPhpFunctionMocker($this);
     return $this;
 }
예제 #25
0
파일: testedClass.php 프로젝트: atoum/atoum
 public function setWithTest(atoum\test $test)
 {
     parent::setWith($test->getTestedClassName());
     return parent::setWithTest($test);
 }
예제 #26
0
파일: test.php 프로젝트: atoum/atoum
 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');
 }
예제 #27
0
파일: error.php 프로젝트: atoum/atoum
 public function setWithTest(test $test)
 {
     $this->setScore($test->getScore());
     return parent::setWithTest($test);
 }
예제 #28
0
파일: call.php 프로젝트: xihewang/atoum
 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();
 }
예제 #30
0
 public function beforeTestMethod($method)
 {
     parent::beforeTestMethod($method);
     $this->instance = new Manager\ServiceManager();
 }