Best Atoum code snippet using notEmptyTest.aDataProvider
test.php
Source:test.php
...34 @ignore off35 @tags test method two36 */37 public function testMethod2() {}38 public function aDataProvider()39 {40 }41 }42 class foo extends atoum\test43 {44 public function __construct()45 {46 $this->setTestedClassName('mageekguy\atoum\test');47 parent::__construct();48 }49 }50 class test extends atoum\test51 {52 public function testClassConstants()53 {54 $this55 ->string(atoum\test::testMethodPrefix)->isEqualTo('test')56 ->string(atoum\test::runStart)->isEqualTo('testRunStart')57 ->string(atoum\test::beforeSetUp)->isEqualTo('beforeTestSetUp')58 ->string(atoum\test::afterSetUp)->isEqualTo('afterTestSetUp')59 ->string(atoum\test::beforeTestMethod)->isEqualTo('beforeTestMethod')60 ->string(atoum\test::fail)->isEqualTo('testAssertionFail')61 ->string(atoum\test::error)->isEqualTo('testError')62 ->string(atoum\test::uncompleted)->isEqualTo('testUncompleted')63 ->string(atoum\test::skipped)->isEqualTo('testSkipped')64 ->string(atoum\test::exception)->isEqualTo('testException')65 ->string(atoum\test::success)->isEqualTo('testAssertionSuccess')66 ->string(atoum\test::afterTestMethod)->isEqualTo('afterTestMethod')67 ->string(atoum\test::beforeTearDown)->isEqualTo('beforeTestTearDown')68 ->string(atoum\test::afterTearDown)->isEqualTo('afterTestTearDown')69 ->string(atoum\test::runStop)->isEqualTo('testRunStop')70 ->string(atoum\test::defaultNamespace)->isEqualTo('#(?:^|\\\\)tests?\\\\units?\\\\#i')71 ;72 }73 public function test__construct()74 {75 $this76 ->if($test = new emptyTest())77 ->then78 ->object($test->getScore())->isInstanceOf('mageekguy\atoum\score')79 ->object($test->getLocale())->isEqualTo(new atoum\locale())80 ->object($test->getAdapter())->isEqualTo(new atoum\adapter())81 ->boolean($test->isIgnored())->isTrue()82 ->boolean($test->debugModeIsEnabled())->isFalse()83 ->array($test->getAllTags())->isEqualTo($tags = array('empty', 'fake', 'dummy'))84 ->array($test->getTags())->isEqualTo($tags)85 ->array($test->getMethodTags())->isEmpty()86 ->array($test->getDataProviders())->isEmpty()87 ->integer($test->getMaxChildrenNumber())->isEqualTo(666)88 ->boolean($test->codeCoverageIsEnabled())->isEqualTo(extension_loaded('xdebug'))89 ->string($test->getTestNamespace())->isEqualTo(atoum\test::defaultNamespace)90 ->integer($test->getMaxChildrenNumber())->isEqualTo(666)91 ->variable($test->getBootstrapFile())->isNull()92 ->array($test->getClassPhpVersions())->isEmpty()93 ->array($test->getMandatoryClassExtensions())->isEmpty()94 ->array($test->getMandatoryMethodExtensions())->isEmpty()95 ;96 }97 public function test__toString()98 {99 $this->castToString($this)->isEqualTo(__CLASS__);100 }101 public function test__get()102 {103 $this104 ->if($test = new emptyTest())105 ->then106 ->object($test->assert)->isInstanceOf('mageekguy\atoum\test')107 ->object($test->define)->isInstanceOf('mageekguy\atoum\test\asserter\generator')108 ->object($test->mockGenerator)->isInstanceOf('mageekguy\atoum\mock\generator')109 ->if($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))110 ->then111 ->object($test->mockGenerator)->isIdenticalTo($mockGenerator)112 ->if($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator(new emptyTest())))113 ->then114 ->object($test->assert)->isIdenticalTo($test)115 ->exception(function() use ($test, & $property) { $test->{$property = uniqid()}; })116 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')117 ->hasMessage('Asserter \'' . $property . '\' does not exist')118 ;119 }120 public function testCreateFunctionFromAssertion()121 {122 $this123 ->if($test = new emptyTest())124 ->then125 ->object($test->createFunctionFromAssertion($assertion = uniqid()))->isIdenticalTo($test)126 ;127 }128 public function testEnableDebugMode()129 {130 $this131 ->if($test = new emptyTest())132 ->then133 ->object($test->enableDebugMode())->isIdenticalTo($test)134 ->boolean($test->debugModeIsEnabled())->isTrue()135 ->object($test->enableDebugMode())->isIdenticalTo($test)136 ->boolean($test->debugModeIsEnabled())->isTrue()137 ;138 }139 public function testDisableDebugMode()140 {141 $this142 ->if($test = new emptyTest())143 ->then144 ->object($test->disableDebugMode())->isIdenticalTo($test)145 ->boolean($test->debugModeIsEnabled())->isFalse()146 ->object($test->disableDebugMode())->isIdenticalTo($test)147 ->boolean($test->debugModeIsEnabled())->isFalse()148 ->if($test->enableDebugMode())149 ->then150 ->object($test->disableDebugMode())->isIdenticalTo($test)151 ->boolean($test->debugModeIsEnabled())->isFalse()152 ;153 }154 public function testEnableCodeCoverage()155 {156 $this157 ->assert('Code coverage must be enabled only if xdebug is available')158 ->if($adapter = new atoum\test\adapter())159 ->and($adapter->extension_loaded = function($extension) { return $extension == 'xdebug'; })160 ->and($test = new emptyTest($adapter))161 ->then162 ->boolean($test->codeCoverageIsEnabled())->isTrue()163 ->object($test->enableCodeCoverage())->isIdenticalTo($test)164 ->boolean($test->codeCoverageIsEnabled())->isTrue()165 ->if($test->disableCodeCoverage())166 ->then167 ->boolean($test->codeCoverageIsEnabled())->isFalse()168 ->object($test->enableCodeCoverage())->isIdenticalTo($test)169 ->boolean($test->codeCoverageIsEnabled())->isTrue()170 ->assert('Code coverage must not be enabled if xdebug is not available')171 ->if($adapter->extension_loaded = function($extension) { return $extension != 'xdebug'; })172 ->and($test = new emptyTest($adapter))173 ->then174 ->boolean($test->codeCoverageIsEnabled())->isFalse()175 ->object($test->enableCodeCoverage())->isIdenticalTo($test)176 ->boolean($test->codeCoverageIsEnabled())->isFalse()177 ;178 }179 public function testDisableCodeCoverage()180 {181 $this182 ->if($adapter = new atoum\test\adapter())183 ->and($adapter->extension_loaded = true)184 ->and($test = new emptyTest($adapter))185 ->then186 ->boolean($test->codeCoverageIsEnabled())->isTrue()187 ->object($test->disableCodeCoverage())->isIdenticalTo($test)188 ->boolean($test->codeCoverageIsEnabled())->isFalse()189 ->if($test->enableCodeCoverage())190 ->then191 ->boolean($test->codeCoverageIsEnabled())->isTrue()192 ->object($test->disableCodeCoverage())->isIdenticalTo($test)193 ->boolean($test->codeCoverageIsEnabled())->isFalse()194 ;195 }196 public function testGetMockGenerator()197 {198 $this199 ->if($test = new emptyTest())200 ->then201 ->object($test->getMockGenerator())->isInstanceOf('mageekguy\atoum\mock\generator')202 ->if($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))203 ->then204 ->object($test->getMockGenerator())->isIdenticalTo($mockGenerator)205 ->object($mockGenerator->getTest())->isIdenticalTo($test)206 ;207 }208 public function testSetMockGenerator()209 {210 $this211 ->if($test = new emptyTest())212 ->then213 ->object($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))->isIdenticalTo($test)214 ->object($test->getMockGenerator())->isIdenticalTo($mockGenerator)215 ->object($mockGenerator->getTest())->isIdenticalTo($test)216 ;217 }218 public function testGetAsserterGenerator()219 {220 $this221 ->if($test = new emptyTest())222 ->then223 ->object($test->getAsserterGenerator())->isInstanceOf('mageekguy\atoum\test\asserter\generator')224 ->if($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator($this)))225 ->then226 ->object($test->getAsserterGenerator())->isIdenticalTo($asserterGenerator)227 ->object($asserterGenerator->getTest())->isIdenticalTo($test)228 ;229 }230 public function testSetAsserterGenerator()231 {232 $this233 ->if($test = new emptyTest())234 ->then235 ->object($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator($test)))->isIdenticalTo($test)236 ->object($test->getAsserterGenerator())->isIdenticalTo($asserterGenerator)237 ->object($asserterGenerator->getTest())->isIdenticalTo($test)238 ->object($asserterGenerator->getLocale())->isIdenticalTo($test->getLocale())239 ;240 }241 public function testGetTestsSubNamespace()242 {243 $this244 ->if($test = new self())245 ->then246 ->string($test->getTestNamespace())->isEqualTo(atoum\test::defaultNamespace)247 ->if($test->setTestNamespace($testsSubNamespace = uniqid()))248 ->then249 ->string($test->getTestNamespace())->isEqualTo($testsSubNamespace)250 ;251 }252 public function testGetTestedClassName()253 {254 $mockClass = '\mock\\' . __CLASS__;255 $this256 ->if($test = new $mockClass())257 ->and($test->getMockController()->getClass = $testClass = 'foo')258 ->then259 ->exception(function() use ($test) { $test->getTestedClassName(); })260 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')261 ->hasMessage('Test class \'' . $testClass . '\' is not in a namespace which match pattern \'' . $test->getTestNamespace() . '\'')262 ->if($test->getMockController()->getClass = 'tests\units\foo')263 ->then264 ->string($test->getTestedClassName())->isEqualTo('foo')265 ;266 }267 public function testSetTestsSubNamespace()268 {269 $this270 ->if($test = new self())271 ->then272 ->object($test->setTestNamespace($testsSubNamespace = uniqid()))->isIdenticalTo($test)273 ->string($test->getTestNamespace())->isEqualTo($testsSubNamespace)274 ->object($test->setTestNamespace('\\' . ($testsSubNamespace = uniqid())))->isIdenticalTo($test)275 ->string($test->getTestNamespace())->isEqualTo($testsSubNamespace)276 ->object($test->setTestNamespace('\\' . ($testsSubNamespace = uniqid()) . '\\'))->isIdenticalTo($test)277 ->string($test->getTestNamespace())->isEqualTo($testsSubNamespace)278 ->object($test->setTestNamespace(($testsSubNamespace = uniqid()) . '\\'))->isIdenticalTo($test)279 ->string($test->getTestNamespace())->isEqualTo($testsSubNamespace)280 ->object($test->setTestNamespace($testsSubNamespace = rand(- PHP_INT_MAX, PHP_INT_MAX)))->isIdenticalTo($test)281 ->string($test->getTestNamespace())->isEqualTo((string) $testsSubNamespace)282 ->exception(function() use ($test) {283 $test->setTestNamespace('');284 }285 )286 ->isInstanceOf('invalidArgumentException')287 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')288 ->hasMessage('Test namespace must not be empty')289 ;290 }291 public function testGetAdapter()292 {293 $this294 ->if($test = new emptyTest())295 ->then296 ->object($test->getAdapter())->isInstanceOf('mageekguy\atoum\adapter')297 ;298 }299 public function testSetAdapter()300 {301 $this302 ->if($test = new emptyTest())303 ->then304 ->object($test->setAdapter($adapter = new atoum\test\adapter()))->isIdenticalTo($test)305 ->object($test->getAdapter())->isIdenticalTo($adapter)306 ;307 }308 public function testSetLocale()309 {310 $this311 ->if($test = new emptyTest())312 ->then313 ->object($test->setLocale($locale = new atoum\locale()))->isIdenticalTo($test)314 ->object($test->getLocale())->isIdenticalTo($locale)315 ;316 }317 public function testSetScore()318 {319 $this320 ->if($test = new emptyTest())321 ->then322 ->object($test->setScore($score = new atoum\test\score()))->isIdenticalTo($test)323 ->object($test->getScore())->isIdenticalTo($score)324 ;325 }326 public function testSetBootstrapFile()327 {328 $this329 ->if($test = new emptyTest())330 ->then331 ->object($test->setBootstrapFile($path = uniqid()))->isIdenticalTo($test)332 ->string($test->getBootstrapFile())->isEqualTo($path)333 ;334 }335 public function testSetMaxChildrenNumber()336 {337 $this338 ->if($test = new emptyTest())339 ->then340 ->exception(function() use ($test) { $test->setMaxChildrenNumber(- rand(1, PHP_INT_MAX)); })341 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')342 ->hasMessage('Maximum number of children must be greater or equal to 1')343 ->exception(function() use ($test) { $test->setMaxChildrenNumber(0); })344 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')345 ->hasMessage('Maximum number of children must be greater or equal to 1')346 ->object($test->setMaxChildrenNumber($maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)347 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)348 ->object($test->setMaxChildrenNumber((string) $maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)349 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)350 ;351 }352 public function testGetClass()353 {354 $this355 ->if($test = new emptyTest())356 ->then357 ->string($test->getClass())->isEqualTo(__NAMESPACE__ . '\emptyTest')358 ;359 }360 public function testGetPath()361 {362 $this363 ->if($test = new emptyTest())364 ->then365 ->string($test->getPath())->isEqualTo(__FILE__)366 ;367 }368 public function testGetCoverage()369 {370 $this371 ->if($test = new emptyTest())372 ->then373 ->object($test->getCoverage())->isIdenticalTo($test->getScore()->getCoverage())374 ;375 }376 public function testIgnore()377 {378 $this379 ->if($test = new emptyTest())380 ->then381 ->boolean($test->isIgnored())->isTrue()382 ->object($test->ignore(false))->isIdenticalTo($test)383 ->boolean($test->isIgnored())->isTrue()384 ->object($test->ignore(true))->isIdenticalTo($test)385 ->boolean($test->isIgnored())->isTrue()386 ->if($test = new notEmptyTest())387 ->then388 ->boolean($test->isIgnored())->isTrue()389 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()390 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()391 ->object($test->ignore(false))->isIdenticalTo($test)392 ->boolean($test->isIgnored())->isFalse()393 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()394 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()395 ->object($test->ignore(true))->isIdenticalTo($test)396 ->boolean($test->isIgnored())->isTrue()397 ->boolean($test->methodIsIgnored('testMethod1'))->istrue()398 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()399 ;400 }401 public function testGetCurrentMethod()402 {403 $this404 ->if($test = new emptyTest())405 ->then406 ->variable($test->getCurrentMethod())->isNull()407 ;408 }409 public function testCount()410 {411 $this412 ->sizeOf(new emptyTest())->isEqualTo(0)413 ->if($test = new notEmptyTest())414 ->then415 ->sizeOf($test)->isEqualTo(0)416 ->if($test->ignore(false))417 ->then418 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()419 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()420 ->sizeOf($test)->isEqualTo(2)421 ->if($test->ignoreMethod('testMethod1', true))422 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()423 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()424 ->sizeOf($test)->isEqualTo(1)425 ->if($test->ignoreMethod('testMethod2', true))426 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()427 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()428 ->sizeOf($test)->isEqualTo(0)429 ;430 }431 public function testGetTestMethods()432 {433 $this434 ->if($test = new emptyTest())435 ->then436 ->boolean($test->ignore(false)->isIgnored())->isTrue()437 ->sizeOf($test)->isZero()438 ->array($test->getTestMethods())->isEmpty()439 ->if($test = new notEmptyTest())440 ->then441 ->boolean($test->isIgnored())->isTrue()442 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()443 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()444 ->sizeOf($test)->isEqualTo(0)445 ->array($test->getTestMethods())->isEmpty()446 ->boolean($test->ignore(false)->isIgnored())->isFalse()447 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()448 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()449 ->sizeOf($test)->isEqualTo(2)450 ->array($test->getTestMethods())->isEqualTo(array('testMethod1', 'testMethod2'))451 ->array($test->getTestMethods(array('method')))->isEqualTo(array('testMethod1', 'testMethod2'))452 ->array($test->getTestMethods(array('test')))->isEqualTo(array('testMethod1', 'testMethod2'))453 ->array($test->getTestMethods(array('two')))->isEqualTo(array('testMethod2'))454 ->array($test->getTestMethods(array(uniqid())))->isEmpty()455 ->array($test->getTestMethods(array('test', 'method')))->isEqualTo(array('testMethod1', 'testMethod2'))456 ->array($test->getTestMethods(array('test', 'method', uniqid())))->isEqualTo(array('testMethod1', 'testMethod2'))457 ->array($test->getTestMethods(array('test', 'method', 'two', uniqid())))->isEqualTo(array('testMethod1', 'testMethod2'))458 ;459 }460 public function testGetPhpPath()461 {462 $this463 ->if($test = new emptyTest())464 ->then465 ->variable($test->getPhpPath())->isNull()466 ->if($test->setPhpPath($phpPath = uniqid()))467 ->then468 ->string($test->getPhpPath())->isEqualTo($phpPath)469 ;470 }471 public function testSetPhpPath()472 {473 $this474 ->if($test = new emptyTest())475 ->then476 ->object($test->setPhpPath($phpPath = uniqid()))->isIdenticalTo($test)477 ->string($test->getPhpPath())->isIdenticalTo($phpPath)478 ->object($test->setPhpPath($phpPath = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)479 ->string($test->getPhpPath())->isIdenticalTo((string) $phpPath)480 ;481 }482 public function testMethodIsIgnored()483 {484 $this485 ->if($test = new emptyTest())486 ->then487 ->exception(function() use ($test, & $method) { $test->methodIsIgnored($method = uniqid()); })488 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')489 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')490 ;491 }492 public function testSetTags()493 {494 $this495 ->if($test = new emptyTest())496 ->then497 ->object($test->setTags($tags = array(uniqid(), uniqid())))->isIdenticalTo($test)498 ->array($test->getTags())->isEqualTo($tags)499 ;500 }501 public function testSetMethodTags()502 {503 $this504 ->if($test = new notEmptyTest())505 ->then506 ->object($test->setMethodTags('testMethod1', $tags = array(uniqid(), uniqid())))->isIdenticalTo($test)507 ->array($test->getMethodTags('testMethod1'))->isEqualTo($tags)508 ->exception(function() use ($test, & $method) { $test->setMethodTags($method = uniqid(), array()); })509 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')510 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')511 ;512 }513 public function testGetMethodTags()514 {515 $this516 ->if($test = new notemptyTest())517 ->then518 ->array($test->getMethodTags('testMethod1'))->isEqualTo(array('test', 'method', 'one'))519 ->exception(function() use ($test, & $method) { $test->getMethodTags($method = uniqid()); })520 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')521 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')522 ;523 }524 public function testAddMandatoryClassExtension()525 {526 $this527 ->if($test = new notEmptyTest())528 ->then529 ->object($test->addMandatoryClassExtension($extension = uniqid()))->isIdenticalTo($test)530 ->array($test->getMandatoryClassExtensions())->isEqualTo(array($extension))531 ->object($test->addMandatoryClassExtension($otherExtension = uniqid()))->isIdenticalTo($test)532 ->array($test->getMandatoryClassExtensions())->isEqualTo(array($extension, $otherExtension))533 ;534 }535 public function testAddMandatoryMethodExtension()536 {537 $this538 ->if($test = new notEmptyTest())539 ->then540 ->exception(function() use ($test, & $method) { $test->addMandatoryMethodExtension($method = uniqid(), uniqid()); })541 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')542 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')543 ->object($test->addMandatoryMethodExtension('testMethod1', $extension = uniqid()))->isIdenticalTo($test)544 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($extension), 'testMethod2' => array()))545 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($extension))546 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEmpty()547 ->object($test->addMandatoryMethodExtension('testMethod1', $otherExtension = uniqid()))->isIdenticalTo($test)548 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($extension, $otherExtension), 'testMethod2' => array()))549 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($extension, $otherExtension))550 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEmpty()551 ->object($test->addMandatoryMethodExtension('testMethod2', $anOtherExtension = uniqid()))->isIdenticalTo($test)552 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($extension, $otherExtension), 'testMethod2' => array($anOtherExtension)))553 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($extension, $otherExtension))554 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(array($anOtherExtension))555 ->if($test->addMandatoryClassExtension($classExtension = uniqid()))556 ->then557 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($classExtension, $extension, $otherExtension), 'testMethod2' => array($classExtension, $anOtherExtension)))558 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($classExtension, $extension, $otherExtension))559 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(array($classExtension, $anOtherExtension))560 ;561 }562 public function testAddClassPhpVersion()563 {564 $this565 ->if($test = new notEmptyTest())566 ->then567 ->object($test->addClassPhpVersion('5.3'))->isIdenticalTo($test)568 ->array($test->getClassPhpVersions())->isEqualTo(array('5.3' => '>='))569 ->object($test->addClassPhpVersion('5.4', '<='))->isIdenticalTo($test)570 ->array($test->getClassPhpVersions())->isEqualTo(array('5.3' => '>=', '5.4' => '<='))571 ;572 }573 public function testAddMethodPhpVersion()574 {575 $this576 ->if($test = new notEmptyTest())577 ->then578 ->exception(function() use ($test, & $method) { $test->addMethodPhpVersion($method, '6.0'); })579 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')580 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')581 ->object($test->addMethodPhpVersion('testMethod1', '5.3'))->isIdenticalTo($test)582 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.3' => '>='), 'testMethod2' => array()))583 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.3' => '>='))584 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()585 ->object($test->addMethodPhpVersion('testMethod1', '5.4', '<='))->isIdenticalTo($test)586 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.3' => '>=', '5.4' => '<='), 'testMethod2' => array()))587 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.3' => '>=', '5.4' => '<='))588 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()589 ->object($test->addMethodPhpVersion('testMethod2', '5.4', '>='))->isIdenticalTo($test)590 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.3' => '>=', '5.4' => '<='), 'testMethod2' => array('5.4' => '>=')))591 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.3' => '>=', '5.4' => '<='))592 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(array('5.4' => '>='))593 ->if($test->addClassPhpVersion('5.5'))594 ->then595 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.5' => '>=', '5.3' => '>=', '5.4' => '<='), 'testMethod2' => array('5.5' => '>=', '5.4' => '>=')))596 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.5' => '>=', '5.3' => '>=', '5.4' => '<='))597 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(array('5.5' => '>=', '5.4' => '>='))598 ;599 }600 public function testRun()601 {602 $this603 ->mockTestedClass('mock\tests\units')604 ->if($test = new \mock\tests\units\test())605 ->then606 ->object($test->run())->isIdenticalTo($test)607 ->boolean(function_exists(__NAMESPACE__ . '\given'))->isTrue('Function ' . __NAMESPACE__ . '\given() does not exist')608 ->boolean(function_exists(__NAMESPACE__ . '\calling'))->isTrue('Function ' . __NAMESPACE__ . '\calling() does not exist')609 ->boolean(function_exists(__NAMESPACE__ . '\resetMock'))->isTrue('Function ' . __NAMESPACE__ . '\resetMock() does not exist')610 ->boolean(function_exists(__NAMESPACE__ . '\resetAdapter'))->isTrue('Function ' . __NAMESPACE__ . '\resetAdapter() does not exist')611 ->mock($test)612 ->call('callObservers')613 ->withArguments(\mageekguy\atoum\test::runStart)->never()614 ->withArguments(\mageekguy\atoum\test::runStop)->never()615 ->withArguments(\mageekguy\atoum\test::beforeSetUp)->never()616 ->withArguments(\mageekguy\atoum\test::afterSetUp)->never()617 ->withArguments(\mageekguy\atoum\test::beforeTestMethod)->never()618 ->withArguments(\mageekguy\atoum\test::afterTestMethod)->never()619 ;620 }621 public function testSetTestedClassName()622 {623 $this624 ->if($test = new foo())625 ->then626 ->string($test->getTestedClassName())->isEqualTo('mageekguy\atoum\test')627 ->exception(function() use ($test) { $test->setTestedClassName(uniqid()); })628 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')629 ->hasMessage('Tested class name is already defined')630 ->if($test = new self())631 ->then632 ->object($test->setTestedClassName($class = uniqid()))->isIdenticalTo($test)633 ->string($test->getTestedClassName())->isEqualTo($class)634 ->exception(function() use ($test) { $test->setTestedClassName(uniqid()); })635 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')636 ->hasMessage('Tested class name is already defined')637 ;638 }639 public function testMockClass()640 {641 $this642 ->if($test = new emptyTest())643 ->then644 ->object($test->mockClass(__CLASS__))->isIdenticalTo($test)645 ->class('mock\\' . __CLASS__)->isSubClassOf(__CLASS__)646 ->object($test->mockClass(__CLASS__, 'foo'))->isIdenticalTo($test)647 ->class('foo\test')->isSubClassOf(__CLASS__)648 ->object($test->mockClass(__CLASS__, 'foo\bar'))->isIdenticalTo($test)649 ->class('foo\bar\test')->isSubClassOf(__CLASS__)650 ->object($test->mockClass(__CLASS__, 'foo', 'bar'))->isIdenticalTo($test)651 ->class('foo\bar')->isSubClassOf(__CLASS__)652 ;653 }654 public function testMockTestedClass()655 {656 $this657 ->if($test = new emptyTest())658 ->and($testedClassName = $test->getTestedClassName())659 ->then660 ->object($test->mockTestedClass())->isIdenticalTo($test)661 ->class('mock\\' . $testedClassName)->isSubClassOf($testedClassName)662 ->object($test->mockTestedClass('foo'))->isIdenticalTo($test)663 ->class('foo\emptyTest')->isSubClassOf($testedClassName)664 ->object($test->mockTestedClass('foo\bar'))->isIdenticalTo($test)665 ->class('foo\bar\emptyTest')->isSubClassOf($testedClassName)666 ->object($test->mockTestedClass('foo', 'bar'))->isIdenticalTo($test)667 ->class('foo\bar')->isSubClassOf($testedClassName)668 ;669 }670 public function testGetTaggedTestMethods()671 {672 $this673 ->if($test = new emptyTest())674 ->then675 ->array($test->getTaggedTestMethods(array()))->isEmpty()676 ->array($test->getTaggedTestMethods(array(uniqid())))->isEmpty()677 ->array($test->getTaggedTestMethods(array(uniqid(), uniqid())))->isEmpty()678 ->if($test = new notEmptyTest())679 ->then680 ->array($test->getTaggedTestMethods(array()))->isEmpty()681 ->array($test->getTaggedTestMethods(array(uniqid())))->isEmpty()682 ->array($test->getTaggedTestMethods(array(uniqid(), uniqid())))->isEmpty()683 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid())))->isEmpty()684 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid(), 'testMethod2')))->isEmpty()685 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2')))->isEmpty()686 ->if($test->ignore(false))687 ->then688 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid())))->isEqualTo(array('testMethod1'))689 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod2', uniqid())))->isEqualTo(array('testMethod2'))690 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2')))->isEqualTo(array('Testmethod1', 'Testmethod2'))691 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'), array('one')))->isEqualTo(array('Testmethod1'))692 ->if($test->ignoreMethod('testMethod1', true))693 ->then694 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid())))->isEmpty()695 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod2', uniqid())))->isEqualTo(array('testMethod2'))696 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2')))->isEqualTo(array('Testmethod2'))697 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'), array('one')))->isEmpty()698 ;699 }700 public function testSetDataProvider()701 {702 $this703 ->if($test = new emptyTest())704 ->then705 ->exception(function() use ($test, & $method) { $test->setDataProvider($method = uniqid(), uniqid()); })706 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')707 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')708 ->if($test = new notEmptyTest())709 ->then710 ->exception(function() use ($test, & $dataProvider) { $test->setDataProvider('testMethod1', $dataProvider = uniqid()); })711 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')712 ->hasMessage('Data provider ' . get_class($test) . '::' . $dataProvider . '() is unknown')713 ->object($test->setDataProvider('testMethod1', 'aDataProvider'))->isIdenticalTo($test)714 ->array($test->getDataProviders())->isEqualTo(array('testMethod1' => 'aDataProvider'))715 ;716 }717 public function testCalling()718 {719 $this720 ->if($test = new emptyTest())721 ->and($mock = new \mock\foo())722 ->and($test->calling($mock)->bar = $value = uniqid())723 ->then724 ->string($mock->bar())->isEqualTo($value)725 ->and($test->Æ($mock)->bar = $otherValue = uniqid())726 ->then727 ->string($mock->bar())->isEqualTo($otherValue)728 ;...
aDataProvider
Using AI Code Generation
1$test = new notEmptyTest();2$test->aDataProvider();3$test = new notEmptyTest();4$test->aDataProvider();5$test = new notEmptyTest();6$test->aDataProvider();7$test = new notEmptyTest();8$test->aDataProvider();9$test = new notEmptyTest();10$test->aDataProvider();11$test = new notEmptyTest();12$test->aDataProvider();13$test = new notEmptyTest();14$test->aDataProvider();15$test = new notEmptyTest();16$test->aDataProvider();17$test = new notEmptyTest();18$test->aDataProvider();19$test = new notEmptyTest();20$test->aDataProvider();21$test = new notEmptyTest();22$test->aDataProvider();23$test = new notEmptyTest();24$test->aDataProvider();25$test = new notEmptyTest();26$test->aDataProvider();27$test = new notEmptyTest();28$test->aDataProvider();29$test = new notEmptyTest();30$test->aDataProvider();
aDataProvider
Using AI Code Generation
1$test = new notEmptyTest();2$test->aDataProvider();3$test->bDataProvider();4$test->cDataProvider();5$test->dDataProvider();6$test = new notEmptyTest();7$test->aDataProvider();8$test->bDataProvider();9$test->cDataProvider();10$test->dDataProvider();11$test = new notEmptyTest();12$test->aDataProvider();13$test->bDataProvider();14$test->cDataProvider();15$test->dDataProvider();16$test = new notEmptyTest();17$test->aDataProvider();18$test->bDataProvider();19$test->cDataProvider();20$test->dDataProvider();21$test = new notEmptyTest();22$test->aDataProvider();23$test->bDataProvider();24$test->cDataProvider();25$test->dDataProvider();26$test = new notEmptyTest();27$test->aDataProvider();28$test->bDataProvider();
aDataProvider
Using AI Code Generation
1$test = new notEmptyTest();2print $test->aDataProvider();3$test = new notEmptyTest();4print $test->aDataProvider();5$test = new notEmptyTest();6print $test->aDataProvider();7$test = new notEmptyTest();8print $test->aDataProvider();9$test = new notEmptyTest();10print $test->aDataProvider();11$test = new notEmptyTest();12print $test->aDataProvider();13$test = new notEmptyTest();14print $test->aDataProvider();15$test = new notEmptyTest();16print $test->aDataProvider();17$test = new notEmptyTest();18print $test->aDataProvider();19$test = new notEmptyTest();20print $test->aDataProvider();21$test = new notEmptyTest();22print $test->aDataProvider();23$test = new notEmptyTest();24print $test->aDataProvider();25$test = new notEmptyTest();26print $test->aDataProvider();27$test = new notEmptyTest();28print $test->aDataProvider();29$test = new notEmptyTest();
aDataProvider
Using AI Code Generation
1$notemptytest = new notEmptyTest();2$notemptytest->aDataProvider();3$notemptytest = new notEmptyTest();4$notemptytest->bDataProvider();5$notemptytest = new notEmptyTest();6$notemptytest->aDataProvider();7$notemptytest = new notEmptyTest();8$notemptytest->bDataProvider();9$notemptytest = new notEmptyTest();10$notemptytest->aDataProvider();11$notemptytest = new notEmptyTest();12$notemptytest->bDataProvider();13class notEmptyTest {14 public static function aDataProvider() {15";16 }17 public static function bDataProvider() {18";19 }20}21notEmptyTest::aDataProvider();22notEmptyTest::bDataProvider();23notEmptyTest::aDataProvider();24notEmptyTest::bDataProvider();25notEmptyTest::aDataProvider();26notEmptyTest::bDataProvider();
aDataProvider
Using AI Code Generation
1$testObj = new notEmptyTest();2$testObj->aDataProvider();3$testObj = new notEmptyTest();4$testObj->aDataProvider();5$testObj = new notEmptyTest();6$testObj->aDataProvider();7$testObj = new notEmptyTest();8$testObj->aDataProvider();9$testObj = new notEmptyTest();10$testObj->aDataProvider();11$testObj = new notEmptyTest();12$testObj->aDataProvider();13$testObj = new notEmptyTest();14$testObj->aDataProvider();15$testObj = new notEmptyTest();16$testObj->aDataProvider();17$testObj = new notEmptyTest();18$testObj->aDataProvider();19$testObj = new notEmptyTest();20$testObj->aDataProvider();21$testObj = new notEmptyTest();22$testObj->aDataProvider();23$testObj = new notEmptyTest();24$testObj->aDataProvider();25$testObj = new notEmptyTest();26$testObj->aDataProvider();
aDataProvider
Using AI Code Generation
1require_once 'notEmptyTest.php';2$test = new notEmptyTest();3$test->aDataProvider();4 (5 (6 (7 (8 (9 (10 (11 (12 (13 (14 (15 (16 (17 (18 (19 (20 (21 (
aDataProvider
Using AI Code Generation
1$testObj = new notEmptyTest();2$testObj->aDataProvider();3 (4 (5 (6 (7 (8 (9 (10 (11 (12 (13 (14 (15 (16 (17 (18 (19 (20 (21 (22 (
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with aDataProvider on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!