Example #1
0
 public function testHandleEvent()
 {
     $this->if($score = new score())->and($score->setAtoumPath($atoumPath = uniqid())->setAtoumVersion($atoumVersion = uniqid()))->and($runner = new runner())->and($runner->setScore($score))->and($field = new testedClass())->then->variable($field->getAuthor())->isNull()->variable($field->getPath())->isNull()->variable($field->getVersion())->isNull()->boolean($field->handleEvent(runner::runStart, $runner))->isTrue()->string($field->getAuthor())->isEqualTo(\mageekguy\atoum\author)->string($field->getPath())->isEqualTo($atoumPath)->string($field->getVersion())->isEqualTo($atoumVersion);
 }
Example #2
0
 public function test__toString()
 {
     $this->if($score = new score())->and($score->setAtoumPath($atoumPath = uniqid())->setAtoumVersion($atoumVersion = uniqid()))->and($runner = new runner())->and($runner->setScore($score))->and($field = new atoum\phing())->and($field->handleEvent(runner::runStop, $runner))->then->castToString($field)->isEmpty()->if($field->handleEvent(runner::runStart, $runner))->then->castToString($field)->isEqualTo($field->getPrompt() . $field->getColorizer()->colorize(sprintf($field->getLocale()->_("Atoum version: %s \nAtoum path: %s \nAtoum author: %s"), $atoumVersion, $atoumPath, \mageekguy\atoum\author)));
 }
Example #3
0
 public function testSetPhpVersion()
 {
     $this->if($score = new testedClass())->then->object($score->setPhpVersion(\PHP_VERSION_ID))->isIdenticalTo($score)->string($score->getPhpVersion())->isEqualTo((string) \PHP_VERSION_ID)->exception(function () use($score) {
         $score->setPhpVersion(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('PHP version is already set');
 }
Example #4
0
 public function testHandleEvent()
 {
     $this->given($http = new \mock\mageekguy\atoum\writers\http(), $this->calling($http)->write->doesNothing, $runner = new \mock\mageekguy\atoum\runner(), $telemetry = $this->newTestedInstance($http), $this->function->getenv = false)->if($this->function->uniqid = 'anon/' . ($project = uniqid()))->when($this->testedInstance->handleEvent(atoum\test::runStart, $runner), $this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->mock($http)->call('write')->withArguments(json_encode(['php' => null, 'framework' => 'atoum', 'version' => null, 'os' => php_uname('s') . ' ' . php_uname('r'), 'arch' => php_uname('m'), 'environment' => 'unknown', 'vendor' => 'anon', 'project' => $project, 'metrics' => ['classes' => 1, 'methods' => ['total' => 0, 'void' => 0, 'uncomplete' => 0, 'skipped' => 0, 'failed' => 0, 'errored' => 0, 'exception' => 0], 'assertions' => ['total' => 0, 'passed' => 0, 'failed' => 0], 'exceptions' => 0, 'errors' => 0, 'duration' => 0, 'memory' => 0]]))->once->when($this->testedInstance->handleEvent(atoum\test::beforeTestMethod, $runner), $this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->mock($http)->call('write')->withArguments(json_encode(['php' => null, 'framework' => 'atoum', 'version' => null, 'os' => php_uname('s') . ' ' . php_uname('r'), 'arch' => php_uname('m'), 'environment' => 'unknown', 'vendor' => 'anon', 'project' => $project, 'metrics' => ['classes' => 1, 'methods' => ['total' => 1, 'void' => 0, 'uncomplete' => 0, 'skipped' => 0, 'failed' => 0, 'errored' => 0, 'exception' => 0], 'assertions' => ['total' => 0, 'passed' => 0, 'failed' => 0], 'exceptions' => 0, 'errors' => 0, 'duration' => 0, 'memory' => 0]]))->once->when($this->testedInstance->handleEvent(atoum\test::beforeTestMethod, $runner), $this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->mock($http)->call('write')->withArguments(json_encode(['php' => null, 'framework' => 'atoum', 'version' => null, 'os' => php_uname('s') . ' ' . php_uname('r'), 'arch' => php_uname('m'), 'environment' => 'unknown', 'vendor' => 'anon', 'project' => $project, 'metrics' => ['classes' => 1, 'methods' => ['total' => 2, 'void' => 0, 'uncomplete' => 0, 'skipped' => 0, 'failed' => 0, 'errored' => 0, 'exception' => 0], 'assertions' => ['total' => 0, 'passed' => 0, 'failed' => 0], 'exceptions' => 0, 'errors' => 0, 'duration' => 0, 'memory' => 0]]))->once->when($this->testedInstance->handleEvent(atoum\test::runStart, $runner), $this->testedInstance->handleEvent(atoum\test::beforeTestMethod, $runner), $this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->mock($http)->call('write')->withArguments(json_encode(['php' => null, 'framework' => 'atoum', 'version' => null, 'os' => php_uname('s') . ' ' . php_uname('r'), 'arch' => php_uname('m'), 'environment' => 'unknown', 'vendor' => 'anon', 'project' => $project, 'metrics' => ['classes' => 2, 'methods' => ['total' => 3, 'void' => 0, 'uncomplete' => 0, 'skipped' => 0, 'failed' => 0, 'errored' => 0, 'exception' => 0], 'assertions' => ['total' => 0, 'passed' => 0, 'failed' => 0], 'exceptions' => 0, 'errors' => 0, 'duration' => 0, 'memory' => 0]]))->once->given($score = new atoum\runner\score(), $coverage = new \mock\mageekguy\atoum\score\coverage(), $this->calling($coverage)->getValue = $coverageValue = rand(0, 100), $score->setCoverage($coverage))->if($runner->setScore($score))->when($this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->mock($http)->call('write')->withArguments(json_encode(['php' => null, 'framework' => 'atoum', 'version' => null, 'os' => php_uname('s') . ' ' . php_uname('r'), 'arch' => php_uname('m'), 'environment' => 'unknown', 'vendor' => 'anon', 'project' => $project, 'metrics' => ['classes' => 2, 'methods' => ['total' => 3, 'void' => 0, 'uncomplete' => 0, 'skipped' => 0, 'failed' => 0, 'errored' => 0, 'exception' => 0], 'assertions' => ['total' => 0, 'passed' => 0, 'failed' => 0], 'exceptions' => 0, 'errors' => 0, 'duration' => 0, 'memory' => 0, 'coverage' => ['lines' => $coverageValue]]]))->once->given($this->calling($coverage)->getBranchesCoverageValue = $branchesCoverageValue = rand(0, 100), $this->calling($coverage)->getPathsCoverageValue = $pathsCoverageValue = rand(0, 100))->when($this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->mock($http)->call('write')->withArguments(json_encode(['php' => null, 'framework' => 'atoum', 'version' => null, 'os' => php_uname('s') . ' ' . php_uname('r'), 'arch' => php_uname('m'), 'environment' => 'unknown', 'vendor' => 'anon', 'project' => $project, 'metrics' => ['classes' => 2, 'methods' => ['total' => 3, 'void' => 0, 'uncomplete' => 0, 'skipped' => 0, 'failed' => 0, 'errored' => 0, 'exception' => 0], 'assertions' => ['total' => 0, 'passed' => 0, 'failed' => 0], 'exceptions' => 0, 'errors' => 0, 'duration' => 0, 'memory' => 0, 'coverage' => ['lines' => $coverageValue, 'branches' => $branchesCoverageValue, 'paths' => $pathsCoverageValue]]]))->once->given($exception = new \mageekguy\atoum\writers\http\exception())->if($this->calling($http)->write->throw = $exception)->when($this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->castToString($this->testedInstance)->isEqualTo('Unable to send your report to the telemetry.' . PHP_EOL)->if($this->calling($http)->write->doesNothing)->when($this->testedInstance->handleEvent(atoum\runner::runStop, $runner))->then->castToString($this->testedInstance)->isEqualTo('Your report has been sent to the telemetry. Thanks for sharing it with us!' . PHP_EOL);
 }
Example #5
0
 public function test__toString()
 {
     $this->if($score = new score())->and($score->setAtoumPath($atoumPath = uniqid())->setAtoumVersion($atoumVersion = uniqid()))->and($runner = new runner())->and($runner->setScore($score))->and($field = new testedClass())->and($field->handleEvent(runner::runStop, $runner))->then->castToString($field)->isEmpty()->if($field->handleEvent(runner::runStart, $runner))->then->castToString($field)->isEqualTo($field->getPrompt() . $field->getColorizer()->colorize(sprintf($field->getLocale()->_('atoum version %s by %s (%s)'), $atoumVersion, \mageekguy\atoum\author, $atoumPath)) . PHP_EOL);
 }