Example #1
0
 public function testExecute()
 {
     $this->mockGenerator->shuntParentClassCalls()->if($runner = new \mock\mageekguy\atoum\runner())->and($this->calling($runner)->run = new atoum\score())->and($task = new testedClass($runner))->then->object($task->execute())->isIdenticalTo($task)->mock($runner)->call('addReport')->once()->call('disableCodeCoverage')->once()->call('run')->once()->if($runner->getMockController()->resetCalls())->and($task->setPhpPath($phpPath = uniqid()))->then->object($task->execute())->isIdenticalTo($task)->mock($runner)->call('setPhpPath')->withArguments($phpPath)->once()->if($runner->getMockController()->resetCalls())->and($task->setBootstrap($bootstrapFile = uniqid()))->then->object($task->execute())->isIdenticalTo($task)->mock($runner)->call('setBootstrapFile')->withArguments($bootstrapFile)->once()->if($runner->getMockController()->resetCalls())->and($task->setMaxChildren($maxChildren = rand(1, PHP_INT_MAX)))->then->object($task->execute())->isIdenticalTo($task)->mock($runner)->call('setMaxChildrenNumber')->withArguments($maxChildren)->once()->if($runner->getMockController()->resetCalls())->and($task->setCodeCoverage(true))->then->object($task->execute())->isIdenticalTo($task)->mock($runner)->call('enableCodeCoverage')->once()->if($runner->getMockController()->resetCalls())->and($task->setCodeCoverage(false))->and($task->setCodeCoverageReportPath(uniqid()))->then->object($task->execute())->isIdenticalTo($task)->mock($runner)->call('enableCodeCoverage')->once()->if($runner->getMockController()->resetCalls())->and($task->setCodeCoverageXunitPath(uniqid()))->then->object($task->execute())->isIdenticalTo($task)->mock($runner)->call('addReport')->twice()->if($score = new \mock\mageekguy\atoum\score())->and($this->calling($runner)->run = $score)->and($this->calling($score)->getUncompletedMethodNumber = rand(1, PHP_INT_MAX))->then->exception(function () use($task) {
         $task->execute();
     })->isInstanceOf('buildException')->hasMessage('Tests did not pass')->if($this->calling($score)->getUncompletedMethodNumber = 0)->and($this->calling($score)->getFailNumber = rand(1, PHP_INT_MAX))->then->exception(function () use($task) {
         $task->execute();
     })->isInstanceOf('buildException')->hasMessage('Tests did not pass')->if($this->calling($score)->getFailNumber = 0)->and($this->calling($score)->getErrorNumber = rand(1, PHP_INT_MAX))->then->exception(function () use($task) {
         $task->execute();
     })->isInstanceOf('buildException')->hasMessage('Tests did not pass')->if($this->calling($score)->getErrorNumber = 0)->and($this->calling($score)->getExceptionNumber = rand(1, PHP_INT_MAX))->then->exception(function () use($task) {
         $task->execute();
     })->isInstanceOf('buildException')->hasMessage('Tests did not pass')->if($this->calling($score)->getExceptionNumber = 0)->and($this->calling($score)->getRuntimeExceptionNumber = rand(1, PHP_INT_MAX))->then->exception(function () use($task) {
         $task->execute();
     })->isInstanceOf('buildException')->hasMessage('Tests did not pass');
 }