Пример #1
0
 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 . '() does not exist')->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'))->if($test = new dataProviderTest())->then->object($test->setDataProvider('testMethod2'))->isIdenticalTo($test)->array($providers = $test->getDataProviders())->object['testMethod2']->isInstanceOf('mageekguy\\atoum\\test\\data\\provider\\aggregator')->exception(function () use($providers) {
         $providers['testMethod2']();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')->if($test->getMockGenerator()->allIsInterface())->then->exception(function () use($providers) {
         $providers['testMethod2']();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')->if($test->getMockGenerator()->setDefaultNamespace('testMocks'))->then->array($providers['testMethod2']())->isEqualTo(array(array(new \testMocks\splFileInfo())))->if($test = new dataProviderTest())->then->exception(function () use($test, &$dataProvider) {
         $test->setDataProvider('testMethod3');
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic\\invalidArgument')->hasMessage('Could not generate a data provider for ' . get_class($test) . '::testMethod3() because it has at least one argument which is not type-hinted with a class or interface name')->object($test->setDataProvider('testMethod1'))->isIdenticalTo($test)->array($test->getDataProviders())->object['testMethod1']->isInstanceOf('mageekguy\\atoum\\test\\data\\provider\\aggregator')->if($test = new dataProviderTest())->then->exception(function () use($test, &$dataProvider) {
         $test->setDataProvider('testMethod3', function () {
         });
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\logic\\invalidArgument')->hasMessage('Cannot use a closure as a data provider for method ' . get_class($test) . '::testMethod3()');
 }
Пример #2
0
 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 . '() does not exist')->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'));
 }