コード例 #1
0
ファイル: cli.php プロジェクト: xihewang/atoum
 public function test__toString()
 {
     $this->if($scoreCoverage = new score\coverage())->and($score = new \mock\mageekguy\atoum\runner\score())->and($score->getMockController()->getCoverage = function () use($scoreCoverage) {
         return $scoreCoverage;
     })->and($runner = new atoum\runner())->and($runner->setScore($score))->and($defaultField = new tests\coverage\cli())->and($customField = new tests\coverage\cli())->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setClassPrompt($classPrompt = new prompt(uniqid())))->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))->and($customField->setCoverageColorizer($coverageColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setLocale($locale = new locale()))->then->castToString($defaultField)->isEmpty()->castToString($customField)->isEmpty()->if($defaultField->handleEvent(atoum\runner::runStart, $runner))->and($customField->handleEvent(atoum\runner::runStart, $runner))->then->castToString($defaultField)->isEmpty()->castToString($customField)->isEmpty()->if($defaultField->handleEvent(atoum\runner::runStop, $runner))->and($customField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($defaultField)->isEmpty()->castToString($customField)->isEmpty()->if($classController = new mock\controller())->and($classController->disableMethodChecking())->and($classController->__construct = function () {
     })->and($classController->getName = function () use(&$className) {
         return $className;
     })->and($classController->getFileName = function () use(&$classFile) {
         return $classFile;
     })->and($classController->getTraits = array())->and($classController->getStartLine = 1)->and($classController->getEndLine = 12)->and($class = new \mock\reflectionClass(uniqid(), $classController))->and($methodController = new mock\controller())->and($methodController->__construct = function () {
     })->and($methodController->isAbstract = false)->and($methodController->getFileName = function () use(&$classFile) {
         return $classFile;
     })->and($methodController->getDeclaringClass = $class)->and($methodController->getName = function () use(&$methodName) {
         return $methodName;
     })->and($methodController->getStartLine = 6)->and($methodController->getEndLine = 8)->and($classController->getMethods = array(new \mock\reflectionMethod(uniqid(), uniqid(), $methodController)))->and($className = uniqid())->and($methodName = uniqid())->and($scoreCoverage->setReflectionClassFactory(function () use($class) {
         return $class;
     }))->and($scoreCoverage->addXdebugDataForTest($this, $xdebugData = array($classFile = uniqid() => array(5 => 1, 6 => 2, 7 => 3, 8 => 2, 9 => 1), uniqid() => array(5 => 2, 6 => 3, 7 => 4, 8 => 3, 9 => 2))))->and($defaultField = new tests\coverage\cli())->and($customField = new tests\coverage\cli())->and($customField->setTitlePrompt($titlePrompt = new prompt(uniqid())))->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setClassPrompt($classPrompt = new prompt(uniqid())))->and($customField->setMethodPrompt($methodPrompt = new prompt(uniqid())))->and($customField->setCoverageColorizer($coverageColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setLocale($locale = new locale()))->then->castToString($defaultField)->isEmpty()->castToString($customField)->isEmpty()->if($defaultField->handleEvent(atoum\runner::runStart, $runner))->and($customField->handleEvent(atoum\runner::runStart, $runner))->then->castToString($defaultField)->isEmpty()->castToString($customField)->isEmpty()->if($defaultField->handleEvent(atoum\runner::runStop, $runner))->and($customField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($defaultField)->isEqualTo($defaultField->getTitlePrompt() . sprintf($defaultField->getLocale()->_('Code coverage value: %3.2f%%'), $scoreCoverage->getValue() * 100) . PHP_EOL . $defaultField->getClassPrompt() . sprintf($defaultField->getLocale()->_('Class %s: %3.2f%%'), $className, $scoreCoverage->getValueForClass($className) * 100.0) . PHP_EOL . $defaultField->getMethodPrompt() . sprintf($defaultField->getLocale()->_('%s::%s(): %3.2f%%'), $className, $methodName, $scoreCoverage->getValueForMethod($className, $methodName) * 100.0) . PHP_EOL)->castToString($customField)->isEqualTo($titlePrompt . sprintf($locale->_('%s: %s'), $titleColorizer->colorize($locale->_('Code coverage value')), $coverageColorizer->colorize(sprintf('%3.2f%%', $scoreCoverage->getValue() * 100.0))) . PHP_EOL . $classPrompt . sprintf($locale->_('%s: %s'), $titleColorizer->colorize(sprintf($locale->_('Class %s'), $className)), $coverageColorizer->colorize(sprintf('%3.2f%%', $scoreCoverage->getValueForClass($className) * 100.0))) . PHP_EOL . $methodPrompt . sprintf($locale->_('%s: %s'), $titleColorizer->colorize(sprintf($locale->_('%s::%s()'), $className, $methodName)), $coverageColorizer->colorize(sprintf('%3.2f%%', $scoreCoverage->getValueForClass($className, $methodName) * 100.0))) . PHP_EOL)->if($defaultField->hideMethodsCoverageDetails())->and($defaultField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($defaultField)->isEqualTo($defaultField->getTitlePrompt() . sprintf($defaultField->getLocale()->_('Code coverage value: %3.2f%%'), $scoreCoverage->getValue() * 100) . PHP_EOL . $defaultField->getClassPrompt() . sprintf($defaultField->getLocale()->_('Class %s: %3.2f%%'), $className, $scoreCoverage->getValueForClass($className) * 100.0) . PHP_EOL)->if($defaultField->hideClassesCoverageDetails())->and($defaultField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($defaultField)->isEqualTo($defaultField->getTitlePrompt() . sprintf($defaultField->getLocale()->_('Code coverage value: %3.2f%%'), $scoreCoverage->getValue() * 100) . PHP_EOL)->if($customField->hideClassesCoverageDetails())->and($customField->handleEvent(atoum\runner::runStop, $runner))->then->castToString($customField)->isEqualTo($customField->getTitlePrompt() . sprintf($customField->getLocale()->_('Code coverage value: %3.2f%%'), $scoreCoverage->getValue() * 100) . PHP_EOL);
 }
コード例 #2
0
ファイル: builder.php プロジェクト: xihewang/atoum
 public function __construct()
 {
     parent::__construct();
     $secondLevelPrompt = new prompt('   ');
     $thirdLevelPrompt = new prompt('      ');
     $this->addField(new runner\php\path\cli());
     $phpVersionField = new runner\php\version\cli();
     $phpVersionField->setVersionPrompt($secondLevelPrompt);
     $this->addField($phpVersionField);
     $this->addField(new runner\duration\cli())->addField(new runner\result\cli());
     $failuresField = new runner\failures\cli();
     $failuresField->setMethodPrompt($secondLevelPrompt);
     $this->addField($failuresField);
     $outputsField = new runner\outputs\cli();
     $outputsField->setMethodPrompt($secondLevelPrompt);
     $this->addField($outputsField);
     $errorsField = new runner\errors\cli();
     $errorsField->setMethodPrompt($secondLevelPrompt)->setErrorPrompt($thirdLevelPrompt);
     $this->addField($errorsField);
     $exceptionsField = new runner\exceptions\cli();
     $exceptionsField->setMethodPrompt($secondLevelPrompt)->setExceptionPrompt($thirdLevelPrompt);
     $this->addField($exceptionsField);
     $uncompletedField = new runner\tests\uncompleted\cli();
     $uncompletedField->setMethodPrompt($secondLevelPrompt)->setOutputPrompt($thirdLevelPrompt);
     $this->addField($uncompletedField);
     $this->addField(new runner\tests\duration\cli())->addField(new runner\tests\memory\cli());
     $coverageField = new runner\tests\coverage\cli();
     $coverageField->setClassPrompt($secondLevelPrompt)->setMethodPrompt($thirdLevelPrompt);
     $this->addField($coverageField)->addField(new test\run\cli());
     $durationField = new test\duration\cli();
     $durationField->setPrompt($secondLevelPrompt);
     $this->addField($durationField);
     $memoryField = new test\memory\cli();
     $memoryField->setPrompt($secondLevelPrompt);
     $this->addField($memoryField);
 }
コード例 #3
0
ファイル: builder.php プロジェクト: xihewang/atoum
 public function test__construct()
 {
     $this->define($phpVersionField = new runner\php\version\cli())->and($phpVersionField->setVersionPrompt(new prompt('   ')))->define($failuresField = new runner\failures\cli())->and($failuresField->setMethodPrompt(new prompt('   ')))->define($outputsField = new runner\outputs\cli())->and($outputsField->setMethodPrompt(new prompt('   ')))->define($errorsField = new runner\errors\cli())->and($errorsField->setMethodPrompt(new prompt('   '))->setErrorPrompt(new prompt('      ')))->define($exceptionsField = new runner\exceptions\cli())->and($exceptionsField->setMethodPrompt(new prompt('   '))->setExceptionPrompt(new prompt('      ')))->define($uncompletedField = new runner\tests\uncompleted\cli())->and($uncompletedField->setMethodPrompt(new prompt('   '))->setOutputPrompt(new prompt('      ')))->define($coverageField = new runner\tests\coverage\cli())->and($coverageField->setClassPrompt(new prompt('   '))->setMethodPrompt(new prompt('      ')))->define($durationField = new test\duration\cli())->and($durationField->setPrompt(new prompt('   ')))->define($memoryField = new test\memory\cli())->and($memoryField->setPrompt(new prompt('   ')))->if($report = new testedClass())->then->object($report->getLocale())->isEqualTo(new atoum\locale())->object($report->getAdapter())->isEqualTo(new atoum\adapter())->array($report->getFields())->isEqualTo(array(new runner\php\path\cli(), $phpVersionField, new runner\duration\cli(), new runner\result\cli(), $failuresField, $outputsField, $errorsField, $exceptionsField, $uncompletedField, new runner\tests\duration\cli(), new runner\tests\memory\cli(), $coverageField, new test\run\cli(), $durationField, $memoryField));
 }