예제 #1
0
 public function test__call()
 {
     $this->if($runner = new \mock\mageekguy\atoum\runner())->and($runner->getMockController()->setBootstrapFile = function () {
     })->and($script = new \mock\mageekguy\atoum\scripts\runner(uniqid()))->and($this->calling($script)->addDefaultReport = $report = new \mock\mageekguy\atoum\report())->and($script->setRunner($runner))->and($configurator = new atoum\configurator($script))->then->object($configurator->scoreFile($scoreFile = uniqid()))->isIdenticalTo($configurator)->mock($script)->call('setScoreFile')->withArguments($scoreFile)->once()->object($configurator->bf($bootstrapFile = uniqid()))->isIdenticalTo($configurator)->mock($runner)->call('setBootstrapFile')->withArguments($bootstrapFile)->once()->object($configurator->bootstrapFile($bootstrapFile = uniqid()))->isIdenticalTo($configurator)->mock($runner)->call('setBootstrapFile')->withArguments($bootstrapFile)->once()->object($configurator->setScoreFile($scoreFile = uniqid()))->isIdenticalTo($configurator)->mock($script)->call('setScoreFile')->withArguments($scoreFile)->once()->object($configurator->addDefaultReport())->isIdenticalTo($report)->mock($script)->call('addDefaultReport')->once()->object($configurator->noCodeCoverageForNamespaces($namespaces = array('foo', 'bar')))->isIdenticalTo($configurator)->mock($script)->call('excludeNamespacesFromCoverage')->withArguments($namespaces)->once()->object($configurator->noCodeCoverageForNamespaces('foo', 'bar'))->isIdenticalTo($configurator)->mock($script)->call('excludeNamespacesFromCoverage')->withArguments($namespaces)->twice()->exception(function () use($configurator, &$method) {
         $configurator->{$method = uniqid()}();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime\\unexpectedValue')->hasMessage('Method \'' . $method . '\' is unavailable');
 }
예제 #2
0
파일: logo.php 프로젝트: xihewang/atoum
 public function test__toString()
 {
     $score = new \mock\mageekguy\atoum\score();
     $scoreController = $score->getMockController();
     $scoreController->getAssertionNumber = 1;
     $scoreController->getFailNumber = 0;
     $scoreController->getErrorNumber = 0;
     $scoreController->getExceptionNumber = 0;
     $runner = new \mock\mageekguy\atoum\runner();
     $runnerController = $runner->getMockController();
     $runnerController->getScore = $score;
     $runnerController->getTestNumber = 1;
     $runnerController->getTestMethodNumber = 1;
     $this->startCase('Success with one test, one method and one assertion, no fail, no error, no exception');
     $this->if($field = new testedClass())->and($field->handleEvent(atoum\runner::runStop, $runner))->then->castToString($field)->isEqualTo("\n                                                   \n                                                    \n                                                    \n                                                    \n                                                    \n\t                                            \n                                                   \n                                          \n                                           \n                                             \n                                             \n                                          \n                                        \n                                        \n                                        \n                                      \n                                    \n            " . PHP_EOL);
     $this->startCase('Failure with several tests, several methods and several assertions, one fail, one error, one exception');
     $scoreController->getFailNumber = 1;
     $scoreController->getErrorNumber = 1;
     $scoreController->getExceptionNumber = 1;
     $scoreController->getUncompletedMethodNumber = 1;
     $this->if($field = new testedClass())->and($field->handleEvent(atoum\runner::runStop, $runner))->then->castToString($field)->isEqualTo("\n                                                   \n                                                    \n                                                    \n                                                    \n                                                    \n                                                    \n                                                    \n                                          \n                                           \n                                             \n                                             \n                                          \n                                        \n                                        \n                                        \n                                      \n                                    \n            " . PHP_EOL);
 }
예제 #3
0
파일: notifier.php 프로젝트: xihewang/atoum
 public function testHandleEvent()
 {
     $this->if($score = new \mock\mageekguy\atoum\runner\score())->and($this->calling($score)->getAssertionNumber = $assertionNumber = rand(1, PHP_INT_MAX))->and($this->calling($score)->getFailNumber = $failNumber = rand(1, PHP_INT_MAX))->and($this->calling($score)->getErrorNumber = $errorNumber = rand(1, PHP_INT_MAX))->and($this->calling($score)->getExceptionNumber = $exceptionNumber = rand(1, PHP_INT_MAX))->and($runner = new \mock\mageekguy\atoum\runner())->and($runner->setScore($score))->and($this->calling($runner)->getTestNumber = $testNumber = rand(1, PHP_INT_MAX))->and($this->calling($runner)->getTestMethodNumber = $testMethodNumber = rand(1, PHP_INT_MAX))->and($field = new \mock\mageekguy\atoum\report\fields\runner\result\notifier())->then->boolean($field->handleEvent(atoum\runner::runStart, $runner))->isFalse()->variable($field->getTestNumber())->isNull()->variable($field->getTestMethodNumber())->isNull()->variable($field->getAssertionNumber())->isNull()->variable($field->getFailNumber())->isNull()->variable($field->getErrorNumber())->isNull()->variable($field->getExceptionNumber())->isNull()->boolean($field->handleEvent(atoum\runner::runStop, $runner))->isTrue()->integer($field->getTestNumber())->isEqualTo($testNumber)->integer($field->getTestMethodNumber())->isEqualTo($testMethodNumber)->integer($field->getAssertionNumber())->isEqualTo($assertionNumber)->integer($field->getFailNumber())->isEqualTo($failNumber)->integer($field->getErrorNumber())->isEqualTo($errorNumber)->integer($field->getExceptionNumber())->isEqualTo($exceptionNumber);
 }
예제 #4
0
파일: phing.php 프로젝트: xihewang/atoum
 public function test__toString()
 {
     $this->if($runner = new \mock\mageekguy\atoum\runner())->and($runner->getMockController()->getRunningDuration = 1)->and($prompt = new \mock\mageekguy\atoum\cli\prompt())->and($prompt->getMockController()->__toString = $promptString = uniqid())->and($titleColorizer = new \mock\mageekguy\atoum\cli\colorizer())->and($titleColorizer->getMockController()->colorize = $colorizedTitle = uniqid())->and($durationColorizer = new \mock\mageekguy\atoum\cli\colorizer())->and($durationColorizer->getMockController()->colorize = $colorizedDuration = uniqid())->and($locale = new \mock\mageekguy\atoum\locale())->and($locale->getMockController()->_ = function ($string) {
         return $string;
     })->and($field = new testedClass())->and($field->setPrompt($prompt))->and($field->setTitleColorizer($titleColorizer))->and($field->setDurationColorizer($durationColorizer))->and($field->setLocale($locale))->then->castToString($field)->isEqualTo($promptString . $colorizedTitle . ': ' . $colorizedDuration . '.')->mock($locale)->call('_')->withArguments('Running duration')->once()->call('_')->withArguments('unknown')->once()->call('_')->withArguments('%1$s: %2$s.')->once()->mock($titleColorizer)->call('colorize')->withArguments('Running duration')->once()->mock($durationColorizer)->call('colorize')->withArguments('unknown')->once()->assert->if($field->handleEvent(runner::runStart, $runner))->then->castToString($field)->isEqualTo($promptString . $colorizedTitle . ': ' . $colorizedDuration . '.')->mock($locale)->call('_')->withArguments('Running duration')->once()->call('_')->withArguments('unknown')->once()->call('_')->withArguments('%1$s: %2$s.')->once()->mock($titleColorizer)->call('colorize')->withArguments('Running duration')->once()->mock($durationColorizer)->call('colorize')->withArguments('unknown')->once()->assert->if($field->handleEvent(runner::runStop, $runner))->then->castToString($field)->isEqualTo($promptString . $colorizedTitle . ': ' . $colorizedDuration . '.')->mock($locale)->call('_')->withArguments('Running duration')->once()->call('__')->withArguments('%4.2f second', '%4.2f seconds', 1)->once()->call('_')->withArguments('%1$s: %2$s.')->once()->mock($titleColorizer)->call('colorize')->withArguments('Running duration')->once()->mock($durationColorizer)->call('colorize')->withArguments('1.00 second')->once()->assert->if($runner->getMockController()->getRunningDuration = $runningDuration = rand(2, PHP_INT_MAX))->and($field = new testedClass())->and($field->setPrompt($prompt))->and($field->setTitleColorizer($titleColorizer))->and($field->setDurationColorizer($durationColorizer))->and($field->setLocale($locale))->and($field->handleEvent(runner::runStart, $runner))->then->castToString($field)->isEqualTo($promptString . $colorizedTitle . ': ' . $colorizedDuration . '.')->mock($locale)->call('_')->withArguments('Running duration')->once()->call('_')->withArguments('unknown')->once()->call('_')->withArguments('%1$s: %2$s.')->once()->mock($titleColorizer)->call('colorize')->withArguments('Running duration')->once()->mock($durationColorizer)->call('colorize')->withArguments('unknown')->once()->assert->if($field->handleEvent(runner::runStop, $runner))->then->castToString($field)->isEqualTo($promptString . $colorizedTitle . ': ' . $colorizedDuration . '.')->mock($locale)->call('_')->withArguments('Running duration')->once()->call('__')->withArguments('%4.2f second', '%4.2f seconds', $runningDuration)->once()->call('_')->withArguments('%1$s: %2$s.')->once()->mock($titleColorizer)->call('colorize')->withArguments('Running duration')->once()->mock($durationColorizer)->call('colorize')->withArguments(sprintf('%4.2f', $runningDuration) . ' seconds')->once();
 }
예제 #5
0
파일: cli.php 프로젝트: xihewang/atoum
 public function test__toString()
 {
     $this->if($score = new \mock\mageekguy\atoum\runner\score())->and($score->getMockController()->getTotalDuration = $totalDuration = rand(1, 100) / 1000)->and($runner = new \mock\mageekguy\atoum\runner())->and($runner->setScore($score))->and($runner->getMockController()->getTestNumber = $testNumber = 1)->and($defaultField = new tests\duration\cli())->and($customField = new tests\duration\cli())->and($customField->setPrompt($prompt = new prompt(uniqid())))->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setDurationColorizer($durationColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setLocale($locale = new locale()))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getLocale()->_('Total test duration: unknown.') . PHP_EOL)->castToString($customField)->isEqualTo($prompt . sprintf('%s: %s.', $titleColorizer->colorize($locale->_('Total test duration')), $durationColorizer->colorize($locale->_('unknown'))) . PHP_EOL)->if($defaultField->handleEvent(atoum\runner::runStart, new atoum\runner()))->and($customField->handleEvent(atoum\runner::runStart, new atoum\runner()))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getLocale()->_('Total test duration: unknown.') . PHP_EOL)->castToString($customField)->isEqualTo($prompt . sprintf('%s: %s.', $titleColorizer->colorize($locale->_('Total test duration')), $durationColorizer->colorize($locale->_('unknown'))) . PHP_EOL)->if($defaultField->handleEvent(atoum\runner::runStop, $runner))->and($customField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . sprintf($defaultField->getLocale()->__('Total test duration: %s.', 'Total tests duration: %s.', $testNumber), sprintf($defaultField->getLocale()->__('%4.2f second', '%4.2f seconds', $totalDuration), $totalDuration)) . PHP_EOL)->castToString($customField)->isEqualTo($prompt . sprintf('%s: %s.', $titleColorizer->colorize($locale->__('Total test duration', 'Total tests duration', $testNumber)), $durationColorizer->colorize(sprintf($locale->__('%4.2f second', '%4.2f seconds', $totalDuration), $totalDuration))) . PHP_EOL)->if($runner->getMockController()->getTestNumber = $testNumber = rand(2, PHP_INT_MAX))->and($defaultField = new tests\duration\cli())->and($customField = new tests\duration\cli())->and($customField->setPrompt($prompt = new prompt(uniqid())))->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setDurationColorizer($durationColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setLocale($locale = new locale()))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getLocale()->_('Total test duration: unknown.') . PHP_EOL)->castToString($customField)->isEqualTo($prompt . sprintf('%s: %s.', $titleColorizer->colorize($locale->_('Total test duration')), $durationColorizer->colorize($locale->_('unknown'))) . PHP_EOL)->if($defaultField->handleEvent(atoum\runner::runStart, new atoum\runner()))->and($customField->handleEvent(atoum\runner::runStart, new atoum\runner()))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getLocale()->_('Total test duration: unknown.') . PHP_EOL)->castToString($customField)->isEqualTo($prompt . sprintf('%s: %s.', $titleColorizer->colorize($locale->_('Total test duration')), $durationColorizer->colorize($locale->_('unknown'))) . PHP_EOL)->if($defaultField->handleEvent(atoum\runner::runStop, $runner))->and($customField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . sprintf($defaultField->getLocale()->__('Total test duration: %s.', 'Total tests duration: %s.', $testNumber), sprintf($defaultField->getLocale()->__('%4.2f second', '%4.2f seconds', $totalDuration), $totalDuration)) . PHP_EOL)->castToString($customField)->isEqualTo($prompt . sprintf('%s: %s.', $titleColorizer->colorize($locale->__('Total test duration', 'Total tests duration', $testNumber)), $durationColorizer->colorize(sprintf($locale->__('%4.2f second', '%4.2f seconds', $totalDuration), $totalDuration))) . PHP_EOL);
 }
예제 #6
0
파일: cli.php 프로젝트: ronan-gloo/atoum
 public function test__toString()
 {
     $score = new \mock\mageekguy\atoum\score();
     $scoreController = $score->getMockController();
     $scoreController->getAssertionNumber = 1;
     $scoreController->getFailNumber = 0;
     $scoreController->getErrorNumber = 0;
     $scoreController->getExceptionNumber = 0;
     $runner = new \mock\mageekguy\atoum\runner();
     $runnerController = $runner->getMockController();
     $runnerController->getScore = $score;
     $runnerController->getTestNumber = 1;
     $runnerController->getTestMethodNumber = 1;
     $locale = new \mock\mageekguy\atoum\locale();
     $localeController = $locale->getMockController();
     $localeController->_ = function ($string) use(&$noTestRunningString, &$successString, &$failureString) {
         switch ($string) {
             case 'No test running.':
                 return $noTestRunningString = uniqid();
             case 'Success (%s, %s, %s, %s, %s) !':
                 return $successString = uniqid();
             case 'Failure (%s, %s, %s, %s, %s, %s, %s, %s) !':
                 return $failureString = uniqid();
             default:
                 return uniqid();
         }
     };
     $localeController->__ = function ($singularString, $pluralString, $number) use(&$testString, &$testMethodString, &$assertionString, &$errorString, &$exceptionString) {
         switch ($singularString) {
             case '%s test':
                 return $testString = uniqid();
             case '%s method':
                 return $testMethodString = uniqid();
             case '%s assertion':
                 return $assertionString = uniqid();
             case '%s error':
                 return $errorString = uniqid();
             case '%s exception':
                 return $exceptionString = uniqid();
             default:
                 return uniqid();
         }
     };
     $prompt = new \mock\mageekguy\atoum\cli\prompt();
     $promptController = $prompt->getMockController();
     $promptController->__toString = $promptString = uniqid();
     $successColorizer = new \mock\mageekguy\atoum\cli\colorizer();
     $successColorizerController = $successColorizer->getMockController();
     $successColorizerController->colorize = $colorizedSuccessString = uniqid();
     $failureColorizer = new \mock\mageekguy\atoum\cli\colorizer();
     $failureColorizerController = $failureColorizer->getMockController();
     $failureColorizerController->colorize = $colorizedFailureString = uniqid();
     $this->startCase('Success with one test, one method and one assertion, no fail, no error, no exception');
     $this->if($field = new runner\result\cli())->and($field->setPrompt($prompt))->and($field->setSuccessColorizer($successColorizer))->and($field->setFailureColorizer($failureColorizer))->and($field->setLocale($locale))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStart, $runner))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStop, $runner))->then->castToString($field)->isEqualTo($promptString . $colorizedSuccessString . PHP_EOL)->mock($locale)->call('__')->withArguments('%s test', '%s tests', 1)->once()->call('__')->withArguments('%s/%s method', '%s/%s methods', 1)->once()->call('__')->withArguments('%s skipped method', '%s skipped methods', 0)->once()->call('__')->withArguments('%s assertion', '%s assertions', 1)->once()->call('_')->withArguments('Success (%s, %s, %s, %s, %s) !')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->call('colorize')->withArguments($successString)->once()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once();
     $this->startCase('Success with several tests, several methods and several assertions,  no fail, no error, no exception');
     $runnerController->getTestNumber = $testNumber = rand(2, PHP_INT_MAX);
     $runnerController->getTestMethodNumber = $testMethodNumber = rand(2, PHP_INT_MAX);
     $scoreController->getAssertionNumber = $assertionNumber = rand(2, PHP_INT_MAX);
     $this->if($field = new runner\result\cli())->and($field->setPrompt($prompt))->and($field->setSuccessColorizer($successColorizer))->and($field->setFailureColorizer($failureColorizer))->and($field->setLocale($locale))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStart, $runner))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStop, $runner))->castToString($field)->isEqualTo($promptString . $colorizedSuccessString . PHP_EOL)->mock($locale)->call('__')->withArguments('%s test', '%s tests', $testNumber)->once()->call('__')->withArguments('%s/%s method', '%s/%s methods', $testMethodNumber)->once()->call('__')->withArguments('%s skipped method', '%s skipped methods', 0)->once()->call('__')->withArguments('%s assertion', '%s assertions', $assertionNumber)->once()->call('_')->withArguments('Success (%s, %s, %s, %s, %s) !')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->call('colorize')->withArguments($successString)->once()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once();
     $this->startCase('Failure with several tests, several methods and several assertions, one fail, one error, one exception');
     $scoreController->getFailNumber = 1;
     $scoreController->getErrorNumber = 1;
     $scoreController->getExceptionNumber = 1;
     $scoreController->getUncompletedMethodNumber = 1;
     $this->if($field = new runner\result\cli())->and($field->setPrompt($prompt))->and($field->setSuccessColorizer($successColorizer))->and($field->setFailureColorizer($failureColorizer))->and($field->setLocale($locale))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStart, $runner))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStop, $runner))->then->castToString($field)->isEqualTo($promptString . $colorizedFailureString . PHP_EOL)->mock($locale)->call('__')->withArguments('%s test', '%s tests', $testNumber)->once()->call('__')->withArguments('%s/%s method', '%s/%s methods', $testMethodNumber)->once()->call('__')->withArguments('%s skipped method', '%s skipped methods', 0)->once()->call('__')->withArguments('%s uncompleted method', '%s uncompleted methods', 1)->once()->call('__')->withArguments('%s failure', '%s failures', 1)->once()->call('__')->withArguments('%s error', '%s errors', 1)->once()->call('__')->withArguments('%s exception', '%s exceptions', 1)->once()->call('_')->withArguments('Failure (%s, %s, %s, %s, %s, %s, %s, %s) !')->once()->mock($failureColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->call('colorize')->withArguments($failureString)->once()->mock($successColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once();
     $this->startCase('Failure with several tests, several methods and several assertions, several fails, several errors, several exceptions');
     $scoreController->getFailNumber = $failNumber = rand(2, PHP_INT_MAX);
     $scoreController->getErrorNumber = $errorNumber = rand(2, PHP_INT_MAX);
     $scoreController->getExceptionNumber = $exceptionNumber = rand(2, PHP_INT_MAX);
     $scoreController->getUncompletedMethodNumber = $uncompletedTestNumber = rand(2, PHP_INT_MAX);
     $this->if($field = new runner\result\cli())->and($field->setPrompt($prompt))->and($field->setSuccessColorizer($successColorizer))->and($field->setFailureColorizer($failureColorizer))->and($field->setLocale($locale))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStart, $runner))->then->castToString($field)->isEqualTo($promptString . $noTestRunningString . PHP_EOL)->mock($locale)->call('_')->withArguments('No test running.')->once()->mock($successColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->mock($failureColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once()->if($locale->getMockController()->resetCalls())->and($prompt->getMockController()->resetCalls())->and($field->handleEvent(atoum\runner::runStop, $runner))->then->castToString($field)->isEqualTo($promptString . $colorizedFailureString . PHP_EOL)->mock($locale)->call('__')->withArguments('%s test', '%s tests', $testNumber)->once()->call('__')->withArguments('%s/%s method', '%s/%s methods', $testMethodNumber)->once()->call('__')->withArguments('%s failure', '%s failures', $failNumber)->once()->call('__')->withArguments('%s error', '%s errors', $errorNumber)->once()->call('__')->withArguments('%s exception', '%s exceptions', $exceptionNumber)->once()->call('_')->withArguments('Failure (%s, %s, %s, %s, %s, %s, %s, %s) !')->once()->mock($failureColorizer)->call('colorize')->withArguments($noTestRunningString)->never()->call('colorize')->withArguments($failureString)->once()->mock($successColorizer)->call('colorize')->never()->mock($prompt)->call('__toString')->once();
 }
예제 #7
0
파일: cli.php 프로젝트: xihewang/atoum
 public function test__toString()
 {
     $this->if($score = new \mock\mageekguy\atoum\runner\score())->and($score->getMockController()->getTotalMemoryUsage = function () use(&$totalMemoryUsage) {
         return $totalMemoryUsage = rand(1, PHP_INT_MAX);
     })->and($runner = new \mock\mageekguy\atoum\runner())->and($runner->setScore($score))->and($runner->getMockController()->getTestNumber = $testNumber = rand(1, PHP_INT_MAX))->and($defaultField = new memory\cli())->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getTitleColorizer()->colorize($defaultField->getLocale()->__('Total test memory usage', 'Total tests memory usage', 0)) . ': ' . $defaultField->getMemoryColorizer()->colorize($defaultField->getLocale()->_('unknown')) . '.' . PHP_EOL)->if($customField = new memory\cli())->and($customField->setPrompt($prompt = new prompt(uniqid())))->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setMemoryColorizer($memoryColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setLocale($locale = new locale()))->then->castToString($customField)->isEqualTo($prompt . $titleColorizer->colorize($locale->__('Total test memory usage', 'Total tests memory usage', 0)) . ': ' . $memoryColorizer->colorize($locale->_('unknown')) . '.' . PHP_EOL)->if($defaultField->handleEvent(atoum\runner::runStart, $runner))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getTitleColorizer()->colorize($defaultField->getLocale()->__('Total test memory usage', 'Total tests memory usage', 0)) . ': ' . $defaultField->getMemoryColorizer()->colorize($defaultField->getLocale()->_('unknown')) . '.' . PHP_EOL)->if($customField->handleEvent(atoum\runner::runStart, $runner))->then->castToString($customField)->isEqualTo($prompt . $titleColorizer->colorize($locale->__('Total test memory usage', 'Total tests memory usage', 0)) . ': ' . $memoryColorizer->colorize($locale->_('unknown')) . '.' . PHP_EOL)->if($defaultField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getTitleColorizer()->colorize($defaultField->getLocale()->__('Total test memory usage', 'Total tests memory usage', $testNumber)) . ': ' . $defaultField->getMemoryColorizer()->colorize(sprintf($defaultField->getLocale()->_('%4.2f Mb'), $totalMemoryUsage / 1048576)) . '.' . PHP_EOL)->if($customField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($customField)->isEqualTo($prompt . $titleColorizer->colorize($locale->__('Total test memory usage', 'Total tests memory usage', $testNumber)) . ': ' . $memoryColorizer->colorize(sprintf($locale->_('%4.2f Mb'), $totalMemoryUsage / 1048576)) . '.' . PHP_EOL);
 }