예제 #1
0
파일: test.php 프로젝트: atoum/atoum
 public function testNewMockInstance()
 {
     $this->if($test = new emptyTest())->then->object($mock = $test->newMockInstance('stdClass'))->isInstanceOf('mock\\stdClass')->isInstanceOf('stdClass')->object($test->newMockInstance('stdClass'))->isInstanceOf('mock\\stdClass')->isInstanceOf('stdClass')->isNotIdenticalTo($mock)->object($test->newMockInstance('stdClass', 'foobar'))->isInstanceOf('foobar\\stdClass')->isInstanceOf('stdClass')->object($test->newMockInstance('stdClass', 'foo', 'bar'))->isInstanceOf('foo\\bar')->isInstanceOf('stdClass')->given($arguments = array($firstArgument = uniqid(), $secondArgument = rand(0, PHP_INT_MAX)))->then->object($mock = $test->newMockInstance('mageekguy\\atoum\\dummy', null, null, $arguments))->isInstanceOf('mock\\mageekguy\\atoum\\dummy')->isInstanceOf('mageekguy\\atoum\\dummy')->mock($mock)->call('__construct')->withArguments($firstArgument, $secondArgument)->once->given($arguments = array(uniqid(), rand(0, PHP_INT_MAX), $controller = new mock\controller()))->then->object($mock = $test->newMockInstance('mageekguy\\atoum\\dummy', null, null, $arguments))->isInstanceOf('mock\\mageekguy\\atoum\\dummy')->isInstanceOf('mageekguy\\atoum\\dummy')->object($mock->getMockController())->isIdenticalTo($controller)->given($arguments = array(uniqid(), rand(0, PHP_INT_MAX)), $controller = new mock\controller())->then->object($mock = $test->newMockInstance('mageekguy\\atoum\\dummy', null, null, $arguments))->isInstanceOf('mock\\mageekguy\\atoum\\dummy')->isInstanceOf('mageekguy\\atoum\\dummy')->object($mock->getMockController())->isIdenticalTo($controller);
 }
예제 #2
0
파일: test.php 프로젝트: xihewang/atoum
 public function testRemoveExtensions()
 {
     $this->if($test = new emptyTest())->then->array($test->getExtensions())->isEmpty()->array($test->getObservers())->isEmpty()->object($test->removeExtensions())->isIdenticalTo($test)->array($test->getExtensions())->isEmpty()->array($test->getObservers())->isEmpty()->if($extension = new \mock\mageekguy\atoum\extension())->and($otherExtension = new \mock\mageekguy\atoum\extension())->and($test->addExtension($extension)->addExtension($otherExtension))->then->array($test->getExtensions())->isEqualTo(array($extension, $otherExtension))->array($test->getObservers())->isEqualTo(array($extension, $otherExtension))->object($test->removeExtensions())->isIdenticalTo($test)->array($test->getExtensions())->isEmpty()->array($test->getObservers())->isEmpty();
 }
예제 #3
0
 public function testErrorHandler()
 {
     $this->if($test = new emptyTest())->and($adapter = new atoum\test\adapter())->and($adapter->error_reporting = 0)->and($test->setAdapter($adapter))->then->boolean($test->errorHandler(rand(1, PHP_INT_MAX), uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->array($test->getScore()->getErrors())->isEmpty()->if($adapter->error_reporting = E_ALL)->then->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNotNull()->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isFalse()->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNotNull()->if($adapter->error_reporting = E_ALL & ~E_DEPRECATED)->then->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNull()->if($adapter->error_reporting = E_ALL & ~E_RECOVERABLE_ERROR)->then->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNull()->if($adapter->error_reporting = 32767)->and($factory = function ($class) use(&$reflection, &$filename, &$classname) {
         $reflection = new \mock\ReflectionClass($class);
         $reflection->getMockController()->getFilename = $filename = 'filename';
         $reflection->getMockController()->getName = $classname = 'classname';
         return $reflection;
     })->and($score = new \mock\mageekguy\atoum\test\score())->and($test = new emptyTest(null, null, null, null, $factory))->and($test->setAdapter($adapter))->and($test->setScore($score))->then->boolean($test->errorHandler($errno = E_NOTICE, $errstr = 'errstr', $errfile = 'errfile', $errline = rand(1, PHP_INT_MAX)))->isTrue()->mock($score)->call('addError')->withArguments($errfile, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, $errfile, $errline, null, null, null)->once()->boolean($test->errorHandler($errno, $errstr, null, $errline = rand(1, PHP_INT_MAX)))->isTrue()->mock($score)->call('addError')->withArguments($filename, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, null, $errline, null, null, null)->once();
 }
예제 #4
0
파일: test.php 프로젝트: eroluysal/atoum
 public function testGetExtensionConfiguration()
 {
     $this->if($test = new emptyTest(), $extension = new \mock\mageekguy\atoum\extension())->then->variable($test->getExtensionConfiguration($extension))->isNull->if($test->addExtension($extension))->then->variable($test->getExtensionConfiguration($extension))->isNull->given($configuration = new \mock\mageekguy\atoum\extension\configuration())->if($test->addExtension($extension, $configuration))->then->object($test->getExtensionConfiguration($extension))->isIdenticalTo($configuration);
 }
예제 #5
0
파일: test.php 프로젝트: ronan-gloo/atoum
 public function testSetDataProvider()
 {
     $this->if($test = new emptyTest())->then->exception(function () use($test, &$method) {
         $test->setDataProvider($method = uniqid(), uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic\\invalidArgument')->hasMessage('Test method ' . get_class($test) . '::' . $method . '() is unknown')->if($test = new notEmptyTest())->then->exception(function () use($test, &$dataProvider) {
         $test->setDataProvider('testMethod1', $dataProvider = uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic\\invalidArgument')->hasMessage('Data provider ' . get_class($test) . '::' . $dataProvider . '() is unknown')->object($test->setDataProvider('testMethod1', 'aDataProvider'))->isIdenticalTo($test)->array($test->getDataProviders())->isEqualTo(array('testMethod1' => 'aDataProvider'));
 }