Example #1
0
 public function test__toString()
 {
     $this->if($adapter = new adapter())->and($adapter->class_exists = true)->and($score = new \mock\mageekguy\atoum\score())->and($score->getMockController()->getTotalDuration = $runningDuration = rand(1, 1000) / 1000)->and($testController = new mock\controller())->and($testController->getTestedClassName = uniqid())->and($testController->getScore = $score)->and($test = new \mock\mageekguy\atoum\test($adapter))->and($defaultField = new test\duration\phing())->and($customField = new test\duration\phing())->and($customField->setPrompt($prompt = new prompt()))->and($customField->setTitleColorizer($titleColorizer = new colorizer()))->and($customField->setDurationColorizer($durationColorizer = new colorizer()))->and($customField->setLocale($locale = new locale()))->then->castToString($defaultField)->isEqualTo('unknown')->castToString($customField)->isEqualTo($prompt . sprintf('%s', $locale->_('unknown')))->if($defaultField->handleEvent(atoum\runner::runStop, $test))->then->castToString($defaultField)->isEqualTo('unknown')->if($customField->handleEvent(atoum\runner::runStop, $test))->then->castToString($customField)->isEqualTo($prompt . sprintf('%s', $locale->_('unknown')))->if($defaultField->handleEvent(atoum\test::runStop, $test))->then->castToString($defaultField)->isEqualTo(sprintf('%4.2f s', $runningDuration))->if($customField->handleEvent(atoum\test::runStop, $test))->then->castToString($customField)->isEqualTo($prompt . sprintf('%s', $durationColorizer->colorize(sprintf($locale->__('%4.2f s', '%4.2f s', $runningDuration), $runningDuration))))->if($score->getMockController()->getTotalDuration = $runningDuration = rand(2, PHP_INT_MAX))->and($defaultField = new test\duration\phing())->and($customField = new test\duration\phing())->and($customField->setPrompt($prompt = new prompt()))->and($customField->setTitleColorizer($titleColorizer = new colorizer()))->and($customField->setDurationColorizer($durationColorizer = new colorizer()))->and($customField->setLocale($locale = new locale()))->then->castToString($defaultField)->isEqualTo('unknown')->castToString($customField)->isEqualTo($prompt . sprintf('%s', $locale->_('unknown')))->if($defaultField->handleEvent(atoum\runner::runStop, $test))->then->castToString($defaultField)->isEqualTo('unknown')->if($customField->handleEvent(atoum\runner::runStop, $test))->then->castToString($customField)->isEqualTo($prompt . sprintf('%s', $locale->_('unknown')))->if($defaultField->handleEvent(atoum\test::runStop, $test))->then->castToString($defaultField)->isEqualTo(sprintf('%4.2f s', $runningDuration))->if($customField->handleEvent(atoum\test::runStop, $test))->then->castToString($customField)->isEqualTo($prompt . sprintf('%s', $durationColorizer->colorize(sprintf($locale->__('%4.2f s', '%4.2f s', $runningDuration), $runningDuration))));
 }
Example #2
0
 protected function build()
 {
     $this->resetFields();
     $firstLevelPrompt = new prompt(PHP_EOL);
     $firstLevelColorizer = new colorizer('1;36');
     $secondLevelPrompt = new prompt(' ', $firstLevelColorizer);
     $failureColorizer = new colorizer('0;31');
     $failurePrompt = clone $secondLevelPrompt;
     $failurePrompt->setColorizer($failureColorizer);
     $errorColorizer = new colorizer('0;33');
     $errorPrompt = clone $secondLevelPrompt;
     $errorPrompt->setColorizer($errorColorizer);
     $exceptionColorizer = new colorizer('0;35');
     $exceptionPrompt = clone $secondLevelPrompt;
     $exceptionPrompt->setColorizer($exceptionColorizer);
     $uncompletedTestColorizer = new colorizer('0;37');
     $uncompletedTestMethodPrompt = clone $secondLevelPrompt;
     $uncompletedTestMethodPrompt->setColorizer($uncompletedTestColorizer);
     $uncompletedTestOutputPrompt = new prompt('  ', $uncompletedTestColorizer);
     $voidTestColorizer = new colorizer('0;34');
     $voidTestMethodPrompt = clone $secondLevelPrompt;
     $voidTestMethodPrompt->setColorizer($voidTestColorizer);
     $skippedTestColorizer = new colorizer('0;90');
     $skippedTestMethodPrompt = clone $secondLevelPrompt;
     $skippedTestMethodPrompt->setColorizer($skippedTestColorizer);
     $phpPathField = new runner\php\path\cli();
     $phpPathField->setPrompt($firstLevelPrompt)->setTitleColorizer($firstLevelColorizer);
     $this->addField($phpPathField);
     $phpVersionField = new runner\php\version\cli();
     $phpVersionField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($firstLevelColorizer)->setVersionPrompt($secondLevelPrompt);
     $this->addField($phpVersionField);
     if ($this->showDuration === true) {
         $runnerDurationField = new runner\duration\cli();
         $runnerDurationField->setPrompt($firstLevelPrompt)->setTitleColorizer($firstLevelColorizer);
         $this->addField($runnerDurationField);
     }
     if ($this->showMemory === true) {
         $runnerTestsMemoryField = new runner\tests\memory\phing();
         $runnerTestsMemoryField->setPrompt($firstLevelPrompt)->setTitleColorizer($firstLevelColorizer);
         $this->addField($runnerTestsMemoryField);
     }
     if ($this->showCodeCoverage === true) {
         $runnerTestsCoverageField = new runner\tests\coverage\phing();
         $runnerTestsCoverageField->setTitlePrompt($firstLevelPrompt)->setClassPrompt($secondLevelPrompt)->setMethodPrompt(new prompt('  ', $firstLevelColorizer))->setTitleColorizer($firstLevelColorizer);
         if ($this->showMissingCodeCoverage === false) {
             $runnerTestsCoverageField->hideMissingCodeCoverage();
         }
         $this->addField($runnerTestsCoverageField);
     }
     $resultField = new runner\result\cli();
     $resultField->setPrompt($firstLevelPrompt)->setSuccessColorizer(new colorizer('0;37', '42'))->setFailureColorizer(new colorizer('0;37', '41'));
     $this->addField($resultField);
     $failuresField = new runner\failures\cli();
     $failuresField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($failureColorizer)->setMethodPrompt($failurePrompt);
     $this->addField($failuresField);
     $outputsField = new runner\outputs\cli();
     $outputsField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($firstLevelColorizer)->setMethodPrompt($secondLevelPrompt);
     $this->addField($outputsField);
     $errorsField = new runner\errors\cli();
     $errorsField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($errorColorizer)->setMethodPrompt($errorPrompt);
     $this->addField($errorsField);
     $exceptionsField = new runner\exceptions\cli();
     $exceptionsField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($exceptionColorizer)->setMethodPrompt($exceptionPrompt);
     $this->addField($exceptionsField);
     $runnerUncompletedField = new runner\tests\uncompleted\cli();
     $runnerUncompletedField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($uncompletedTestColorizer)->setMethodPrompt($uncompletedTestMethodPrompt)->setOutputPrompt($uncompletedTestOutputPrompt);
     $this->addField($runnerUncompletedField);
     $runnerVoidField = new runner\tests\void\cli();
     $runnerVoidField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($voidTestColorizer)->setMethodPrompt($voidTestMethodPrompt);
     $this->addField($runnerVoidField);
     $runnerSkippedField = new runner\tests\skipped\cli();
     $runnerSkippedField->setTitlePrompt($firstLevelPrompt)->setTitleColorizer($skippedTestColorizer)->setMethodPrompt($skippedTestMethodPrompt);
     $this->addField($runnerSkippedField);
     if ($this->showProgress === true) {
         $runField = new test\run\phing();
         $runField->setPrompt($firstLevelPrompt)->setColorizer($firstLevelColorizer);
         $this->addField($runField)->addField(new test\event\phing());
     }
     if ($this->showDuration === true) {
         $durationField = new test\duration\phing();
         $durationField->setPrompt($secondLevelPrompt);
         $this->addField($durationField);
     }
     if ($this->showMemory === true) {
         $memoryField = new test\memory\phing();
         $memoryField->setPrompt($secondLevelPrompt);
         $this->addField($memoryField);
     }
     if ($this->codeCoverageReportPath !== null) {
         $coverageField = new atoum\report\fields\runner\coverage\html($this->codeCoverageReportProjectName ?: '', $this->codeCoverageReportPath);
         $coverageField->setRootUrl($this->codeCoverageReportUrl ?: 'file:////' . realpath($this->codeCoverageReportPath));
         $this->addField($coverageField);
     }
     return $this;
 }
Example #3
0
 public function test__construct()
 {
     $this->define($phpPathField = new fields\runner\php\path\cli())->and($phpPathField->setPrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('1;36')))->define($phpVersionField = new fields\runner\php\version\cli())->and($phpVersionField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('1;36'))->setVersionPrompt(new prompt(' ', new colorizer('1;36'))))->define($runnerTestsDurationField = new fields\runner\duration\cli())->and($runnerTestsDurationField->setPrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('1;36')))->define($runnerTestsMemoryField = new fields\runner\tests\memory\phing())->and($runnerTestsMemoryField->setPrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('1;36')))->define($runnerTestsCoverageField = new fields\runner\tests\coverage\phing())->and($runnerTestsCoverageField->setTitlePrompt(new prompt(PHP_EOL))->setClassPrompt(new prompt(' ', new colorizer('1;36')))->setMethodPrompt(new prompt('  ', new colorizer('1;36')))->setTitleColorizer(new colorizer('1;36')))->define($runnerResultField = new fields\runner\result\cli())->and($runnerResultField->setPrompt(new prompt(PHP_EOL))->setSuccessColorizer(new colorizer('0;37', '42'))->setFailureColorizer(new colorizer('0;37', '41')))->define($runnerFailuresField = new fields\runner\failures\cli())->and($runnerFailuresField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('0;31'))->setMethodPrompt(new prompt(' ', new colorizer('0;31'))))->define($runnerOutputsField = new fields\runner\outputs\cli())->and($runnerOutputsField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('1;36'))->setMethodPrompt(new prompt(' ', new colorizer('1;36'))))->define($runnerErrorsField = new fields\runner\errors\cli())->and($runnerErrorsField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('0;33'))->setMethodPrompt(new prompt(' ', new colorizer('0;33'))))->define($runnerExceptionsField = new fields\runner\exceptions\cli())->and($runnerExceptionsField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('0;35'))->setMethodPrompt(new prompt(' ', new colorizer('0;35'))))->define($runnerUncompletedField = new fields\runner\tests\uncompleted\cli())->and($runnerUncompletedField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('0;37'))->setMethodPrompt(new prompt(' ', new colorizer('0;37')))->setOutputPrompt(new prompt('  ', new colorizer('0;37'))))->define($runnerVoidField = new fields\runner\tests\void\cli())->and($runnerVoidField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('0;34'))->setMethodPrompt(new prompt(' ', new colorizer('0;34'))))->define($runnerSkippedField = new fields\runner\tests\skipped\cli())->and($runnerSkippedField->setTitlePrompt(new prompt(PHP_EOL))->setTitleColorizer(new colorizer('0;90'))->setMethodPrompt(new prompt(' ', new colorizer('0;90'))))->define($testRunField = new fields\test\run\phing())->and($testRunField->setPrompt(new prompt(PHP_EOL))->setColorizer(new colorizer('1;36')))->define($testDurationField = new fields\test\duration\phing())->and($testDurationField->setPrompt(new prompt(' ', new colorizer('1;36'))))->define($testMemoryField = new fields\test\memory\phing())->and($testMemoryField->setPrompt(new prompt(' ', new colorizer('1;36'))))->if($report = new testedClass())->then->boolean($report->progressIsShowed())->isTrue()->boolean($report->codeCoverageIsShowed())->isTrue()->boolean($report->missingCodeCoverageIsShowed())->isTrue()->boolean($report->durationIsShowed())->isTrue()->boolean($report->memoryIsShowed())->isTrue()->variable($report->getCodeCoverageReportPath())->isNull()->variable($report->getCodeCoverageReportUrl())->isNull()->array($report->getFields())->isEqualTo(array($phpPathField, $phpVersionField, $runnerTestsDurationField, $runnerTestsMemoryField, $runnerTestsCoverageField, $runnerResultField, $runnerFailuresField, $runnerOutputsField, $runnerErrorsField, $runnerExceptionsField, $runnerUncompletedField, $runnerVoidField, $runnerSkippedField, $testRunField, new fields\test\event\phing(), $testDurationField, $testMemoryField));
 }