Best Atoum code snippet using inheritedTagsTest.testMethod2
test.php
Source:test.php
...59 * @extensions mbstring socket60 * @ignore off61 * @tags test method two62 */63 public function testMethod2()64 {65 }66 public function aDataProvider()67 {68 }69 }70 /**71 * @ignore on72 * @tags first73 */74 class inheritedTagsTest extends atoum\test75 {76 /**77 * @tags second third78 */79 public function testMethod1()80 {81 }82 /**83 * @tags first second third84 */85 public function testMethod2()86 {87 }88 }89 /**90 * @ignore on91 */92 class dataProviderTest extends atoum\test93 {94 public function testMethod1(\stdClass $a)95 {96 }97 public function testMethod2(\splFileInfo $a)98 {99 }100 public function testMethod3($a)101 {102 }103 }104 class foo extends atoum\test105 {106 public function __construct()107 {108 $this->setTestedClassName('mageekguy\atoum\test');109 parent::__construct();110 }111 }112 /**113 * @ignore on114 */115 class withStatic extends atoum\test116 {117 public function __construct()118 {119 $this->setTestedClassName('mageekguy\atoum\withStatic');120 parent::__construct();121 }122 }123 class test extends atoum\test124 {125 public function testClassConstants()126 {127 $this128 ->string(atoum\test::testMethodPrefix)->isEqualTo('test')129 ->string(atoum\test::runStart)->isEqualTo('testRunStart')130 ->string(atoum\test::beforeSetUp)->isEqualTo('beforeTestSetUp')131 ->string(atoum\test::afterSetUp)->isEqualTo('afterTestSetUp')132 ->string(atoum\test::beforeTestMethod)->isEqualTo('beforeTestMethod')133 ->string(atoum\test::fail)->isEqualTo('testAssertionFail')134 ->string(atoum\test::error)->isEqualTo('testError')135 ->string(atoum\test::uncompleted)->isEqualTo('testUncompleted')136 ->string(atoum\test::skipped)->isEqualTo('testSkipped')137 ->string(atoum\test::exception)->isEqualTo('testException')138 ->string(atoum\test::success)->isEqualTo('testAssertionSuccess')139 ->string(atoum\test::afterTestMethod)->isEqualTo('afterTestMethod')140 ->string(atoum\test::beforeTearDown)->isEqualTo('beforeTestTearDown')141 ->string(atoum\test::afterTearDown)->isEqualTo('afterTestTearDown')142 ->string(atoum\test::runStop)->isEqualTo('testRunStop')143 ->string(atoum\test::defaultNamespace)->isEqualTo('#(?:^|\\\\)tests?\\\\units?\\\\#i')144 ->string(atoum\test::defaultMethodPrefix)->isEqualTo('#^(?:test|_*[^_]+_should_)#i')145 ;146 }147 public function test__construct()148 {149 $this150 ->if($test = new emptyTest())151 ->then152 ->object($test->getScore())->isInstanceOf('mageekguy\atoum\score')153 ->object($test->getLocale())->isEqualTo(new atoum\locale())154 ->object($test->getAdapter())->isEqualTo(new atoum\adapter())155 ->object($test->getPhpFunctionMocker())->isInstanceOf('mageekguy\atoum\php\mocker\funktion')156 ->object($test->getPhpConstantMocker())->isInstanceOf('mageekguy\atoum\php\mocker\constant')157 ->object($test->getFactoryBuilder())->isInstanceOf('mageekguy\atoum\factory\builder\closure')158 ->boolean($test->isIgnored())->isTrue()159 ->boolean($test->debugModeIsEnabled())->isFalse()160 ->array($test->getAllTags())->isEqualTo($tags = ['empty', 'fake', 'dummy'])161 ->array($test->getTags())->isEqualTo($tags)162 ->array($test->getMethodTags())->isEmpty()163 ->array($test->getDataProviders())->isEmpty()164 ->integer($test->getMaxChildrenNumber())->isEqualTo(666)165 ->boolean($test->codeCoverageIsEnabled())->isEqualTo(extension_loaded('xdebug'))166 ->string($test->getTestNamespace())->isEqualTo(atoum\test::defaultNamespace)167 ->integer($test->getMaxChildrenNumber())->isEqualTo(666)168 ->variable($test->getBootstrapFile())->isNull()169 ->array($test->getClassPhpVersions())->isEmpty()170 ->array($test->getMandatoryClassExtensions())->isEmpty()171 ->array($test->getMandatoryMethodExtensions())->isEmpty()172 ->variable($test->getXdebugConfig())->isNull()173 ;174 }175 public function test__toString()176 {177 $this->castToString($this)->isEqualTo(__CLASS__);178 }179 public function test__get()180 {181 $this182 ->if($test = new emptyTest())183 ->then184 ->object($test->assert)->isInstanceOf('mageekguy\atoum\test')185 ->object($test->define)->isInstanceOf('mageekguy\atoum\test\assertion\aliaser')186 ->object($test->mockGenerator)->isInstanceOf('mageekguy\atoum\mock\generator')187 ->if($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))188 ->then189 ->object($test->mockGenerator)->isIdenticalTo($mockGenerator)190 ->if($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator(new emptyTest())))191 ->then192 ->object($test->assert)->isIdenticalTo($test)193 ->variable($test->exception)->isNull()194 ->exception(function () use ($test, & $property) {195 $test->{$property = uniqid()};196 })197 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')198 ->hasMessage('Asserter \'' . $property . '\' does not exist')199 ->exception($test->exception)200 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')201 ->hasMessage('Asserter \'' . $property . '\' does not exist')202 ;203 }204 public function test__set()205 {206 $this207 ->given(208 $test = new emptyTest(),209 $test->setAssertionManager($assertionManager = new \mock\mageekguy\atoum\test\assertion\manager())210 )211 ->if($test->{$event = uniqid()} = $handler = function () {212 })213 ->then214 ->mock($assertionManager)->call('setHandler')->withArguments($event, $handler)->once()215 ;216 }217 public function testEnableDebugMode()218 {219 $this220 ->if($test = new emptyTest())221 ->then222 ->object($test->enableDebugMode())->isIdenticalTo($test)223 ->boolean($test->debugModeIsEnabled())->isTrue()224 ->object($test->enableDebugMode())->isIdenticalTo($test)225 ->boolean($test->debugModeIsEnabled())->isTrue()226 ;227 }228 public function testDisableDebugMode()229 {230 $this231 ->if($test = new emptyTest())232 ->then233 ->object($test->disableDebugMode())->isIdenticalTo($test)234 ->boolean($test->debugModeIsEnabled())->isFalse()235 ->object($test->disableDebugMode())->isIdenticalTo($test)236 ->boolean($test->debugModeIsEnabled())->isFalse()237 ->if($test->enableDebugMode())238 ->then239 ->object($test->disableDebugMode())->isIdenticalTo($test)240 ->boolean($test->debugModeIsEnabled())->isFalse()241 ;242 }243 public function testEnableCodeCoverage()244 {245 $this246 ->assert('Code coverage must be enabled only if xdebug is available')247 ->if($adapter = new atoum\test\adapter())248 ->and($adapter->extension_loaded = function ($extension) {249 return $extension == 'xdebug';250 })251 ->and($test = new emptyTest($adapter))252 ->then253 ->boolean($test->codeCoverageIsEnabled())->isTrue()254 ->object($test->enableCodeCoverage())->isIdenticalTo($test)255 ->boolean($test->codeCoverageIsEnabled())->isTrue()256 ->if($test->disableCodeCoverage())257 ->then258 ->boolean($test->codeCoverageIsEnabled())->isFalse()259 ->object($test->enableCodeCoverage())->isIdenticalTo($test)260 ->boolean($test->codeCoverageIsEnabled())->isTrue()261 ->assert('Code coverage must not be enabled if xdebug is not available')262 ->if($adapter->extension_loaded = function ($extension) {263 return $extension != 'xdebug';264 })265 ->and($test = new emptyTest($adapter))266 ->then267 ->boolean($test->codeCoverageIsEnabled())->isFalse()268 ->object($test->enableCodeCoverage())->isIdenticalTo($test)269 ->boolean($test->codeCoverageIsEnabled())->isFalse()270 ;271 }272 public function testDisableCodeCoverage()273 {274 $this275 ->if($adapter = new atoum\test\adapter())276 ->and($adapter->extension_loaded = true)277 ->and($test = new emptyTest($adapter))278 ->then279 ->boolean($test->codeCoverageIsEnabled())->isTrue()280 ->object($test->disableCodeCoverage())->isIdenticalTo($test)281 ->boolean($test->codeCoverageIsEnabled())->isFalse()282 ->if($test->enableCodeCoverage())283 ->then284 ->boolean($test->codeCoverageIsEnabled())->isTrue()285 ->object($test->disableCodeCoverage())->isIdenticalTo($test)286 ->boolean($test->codeCoverageIsEnabled())->isFalse()287 ;288 }289 public function testGetMockGenerator()290 {291 $this292 ->if($test = new emptyTest())293 ->then294 ->object($test->getMockGenerator())->isInstanceOf('mageekguy\atoum\mock\generator')295 ->if($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))296 ->then297 ->object($test->getMockGenerator())->isIdenticalTo($mockGenerator)298 ->object($mockGenerator->getTest())->isIdenticalTo($test)299 ;300 }301 public function testSetMockGenerator()302 {303 $this304 ->if($test = new emptyTest())305 ->then306 ->object($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))->isIdenticalTo($test)307 ->object($test->getMockGenerator())->isIdenticalTo($mockGenerator)308 ->object($mockGenerator->getTest())->isIdenticalTo($test)309 ;310 }311 public function testSetMockAutoloader()312 {313 $this314 ->if($test = new emptyTest())315 ->then316 ->object($test->setMockAutoloader($mockAutoloader = new atoum\autoloader\mock()))->isIdenticalTo($test)317 ->object($test->getMockAutoloader())->isIdenticalTo($mockAutoloader)318 ;319 }320 public function testGetAsserterGenerator()321 {322 $this323 ->if($test = new emptyTest())324 ->then325 ->object($test->getAsserterGenerator())->isInstanceOf('mageekguy\atoum\test\asserter\generator')326 ->if($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator($this)))327 ->then328 ->object($test->getAsserterGenerator())->isIdenticalTo($asserterGenerator)329 ->object($asserterGenerator->getTest())->isIdenticalTo($test)330 ;331 }332 public function testSetAsserterGenerator()333 {334 $this335 ->if($test = new emptyTest())336 ->then337 ->object($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator($test)))->isIdenticalTo($test)338 ->object($test->getAsserterGenerator())->isIdenticalTo($asserterGenerator)339 ->object($asserterGenerator->getTest())->isIdenticalTo($test)340 ->object($asserterGenerator->getLocale())->isIdenticalTo($test->getLocale())341 ;342 }343 public function testGetFactoryBuilder()344 {345 $this346 ->if($test = new emptyTest())347 ->then348 ->object($test->getFactoryBuilder())->isInstanceOf('mageekguy\atoum\factory\builder\closure')349 ->if($test->setFactoryBuilder($factoryBuilder = new \mock\atoum\factory\builder()))350 ->then351 ->object($test->getFactoryBuilder())->isIdenticalTo($factoryBuilder)352 ;353 }354 public function testSetFactoryBuilder()355 {356 $this357 ->if($test = new emptyTest())358 ->then359 ->object($test->setFactoryBuilder($factoryBuilder = new \mock\atoum\factory\builder()))->isIdenticalTo($test)360 ->object($test->getFactoryBuilder())->isIdenticalTo($factoryBuilder)361 ->object($test->setFactoryBuilder())->isIdenticalTo($test)362 ->object($test->getFactoryBuilder())363 ->isEqualTo(new atoum\Factory\builder\closure())364 ->isNotIdenticalTo($factoryBuilder)365 ;366 }367 public function testSetPhpFunktionMocker()368 {369 $this370 ->if($test = new emptyTest())371 ->then372 ->object($test->setPhpFunctionMocker($phpFunctionMocker = new atoum\php\mocker\funktion()))->isIdenticalTo($test)373 ->object($test->getPhpFunctionMocker())->isIdenticalTo($phpFunctionMocker)374 ->object($test->setPhpFunctionMocker())->isIdenticalTo($test)375 ->object($test->getPhpFunctionMocker())376 ->isNotIdenticalTo($phpFunctionMocker)377 ->isInstanceOf('mageekguy\atoum\php\mocker\funktion')378 ;379 }380 public function testSetTestNamespace()381 {382 $this383 ->if($test = new self())384 ->then385 ->object($test->setTestNamespace($testNamespace = uniqid('_')))->isIdenticalTo($test)386 ->string($test->getTestNamespace())->isEqualTo($testNamespace)387 ->object($test->setTestNamespace('\\' . $testNamespace))->isIdenticalTo($test)388 ->string($test->getTestNamespace())->isEqualTo($testNamespace)389 ->object($test->setTestNamespace($testNamespace . '\\'))->isIdenticalTo($test)390 ->string($test->getTestNamespace())->isEqualTo($testNamespace)391 ->object($test->setTestNamespace('\\' . $testNamespace . '\\'))->isIdenticalTo($test)392 ->string($test->getTestNamespace())->isEqualTo($testNamespace)393 ->object($test->setTestNamespace($testNamespace = uniqid('_') . '\\' . $testNamespace))->isIdenticalTo($test)394 ->string($test->getTestNamespace())->isEqualTo($testNamespace)395 ->object($test->setTestNamespace('\\' . $testNamespace))->isIdenticalTo($test)396 ->string($test->getTestNamespace())->isEqualTo($testNamespace)397 ->object($test->setTestNamespace($testNamespace . '\\'))->isIdenticalTo($test)398 ->string($test->getTestNamespace())->isEqualTo($testNamespace)399 ->object($test->setTestNamespace('\\' . $testNamespace . '\\'))->isIdenticalTo($test)400 ->string($test->getTestNamespace())->isEqualTo($testNamespace)401 ->object($test->setTestNamespace($testNamespace = '_' . rand(0, PHP_INT_MAX)))->isIdenticalTo($test)402 ->string($test->getTestNamespace())->isEqualTo((string) $testNamespace)403 ->object($test->setTestNamespace('\\' . $testNamespace))->isIdenticalTo($test)404 ->string($test->getTestNamespace())->isEqualTo($testNamespace)405 ->object($test->setTestNamespace($testNamespace . '\\'))->isIdenticalTo($test)406 ->string($test->getTestNamespace())->isEqualTo($testNamespace)407 ->object($test->setTestNamespace('\\' . $testNamespace . '\\'))->isIdenticalTo($test)408 ->string($test->getTestNamespace())->isEqualTo($testNamespace)409 ->exception(function () use ($test) {410 $test->setTestNamespace('');411 }412 )413 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')414 ->hasMessage('Test namespace must not be empty')415 ->exception(function () use ($test) {416 $test->setTestNamespace('0');417 }418 )419 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')420 ->hasMessage('Test namespace must be a valid regex or identifier')421 ->exception(function () use ($test) {422 $test->setTestNamespace(uniqid('_') . '\\\\' . uniqid('_'));423 }424 )425 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')426 ->hasMessage('Test namespace must be a valid regex or identifier')427 ;428 }429 public function testGetTestNamespace()430 {431 $this432 ->if($test = new self())433 ->then434 ->string($test->getTestNamespace())->isEqualTo(atoum\test::defaultNamespace)435 ->if($test->setTestNamespace($testNamespace = uniqid('_')))436 ->then437 ->string($test->getTestNamespace())->isEqualTo($testNamespace)438 ;439 }440 public function testSetTestMethodPrefix()441 {442 $this443 ->if($test = new self())444 ->then445 ->object($test->setTestMethodPrefix($testMethodPrefix = uniqid('_')))->isIdenticalTo($test)446 ->string($test->getTestMethodPrefix())->isEqualTo($testMethodPrefix)447 ->object($test->setTestMethodPrefix($testMethodPrefix = '/^test/i'))->isIdenticalTo($test)448 ->string($test->getTestMethodPrefix())->isEqualTo($testMethodPrefix)449 ->object($test->setTestMethodPrefix($testMethodPrefix = ('_' . rand(0, PHP_INT_MAX))))->isIdenticalTo($test)450 ->string($test->getTestMethodPrefix())->isEqualTo((string) $testMethodPrefix)451 ->object($test->setTestMethodPrefix($testMethodPrefix = "_0"))->isIdenticalTo($test)452 ->string($test->getTestMethodPrefix())->isEqualTo((string) $testMethodPrefix)453 ->exception(function () use ($test) {454 $test->setTestMethodPrefix('');455 }456 )457 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')458 ->hasMessage('Test method prefix must not be empty')459 ->exception(function () use ($test) {460 $test->setTestMethodPrefix('0');461 }462 )463 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')464 ->hasMessage('Test method prefix must a valid regex or identifier')465 ->exception(function () use ($test) {466 $test->setTestMethodPrefix('/:(/');467 }468 )469 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')470 ->hasMessage('Test method prefix must a valid regex or identifier')471 ;472 }473 public function testGetTestMethodPrefix()474 {475 $this476 ->if($test = new self())477 ->then478 ->string($test->getTestMethodPrefix())->isEqualTo(atoum\test::defaultMethodPrefix)479 ->if($test->setTestMethodPrefix($testMethodPrefix = uniqid('_')))480 ->then481 ->string($test->getTestMethodPrefix())->isEqualTo($testMethodPrefix)482 ;483 }484 public function testGetTestedClassName()485 {486 $mockClass = '\mock\\' . __CLASS__;487 $this488 ->if($test = new $mockClass())489 ->and($test->getMockController()->getClass = $testClass = 'foo')490 ->then491 ->exception(function () use ($test) {492 $test->getTestedClassName();493 })494 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')495 ->hasMessage('Test class \'' . $testClass . '\' is not in a namespace which match pattern \'' . $test->getTestNamespace() . '\'')496 ->if($test->getMockController()->getClass = 'tests\units\foo')497 ->then498 ->string($test->getTestedClassName())->isEqualTo('foo')499 ;500 }501 public function testGetTestedClassPath()502 {503 $this504 ->if($testedClass = new \reflectionClass($this->getTestedClassName()))505 ->then506 ->string($this->getTestedClassPath())->isEqualTo($testedClass->getFilename())507 ;508 }509 public function testGetAdapter()510 {511 $this512 ->if($test = new emptyTest())513 ->then514 ->object($test->getAdapter())->isInstanceOf('mageekguy\atoum\adapter')515 ;516 }517 public function testSetAdapter()518 {519 $this520 ->if($test = new emptyTest())521 ->then522 ->object($test->setAdapter($adapter = new atoum\test\adapter()))->isIdenticalTo($test)523 ->object($test->getAdapter())->isIdenticalTo($adapter)524 ;525 }526 public function testSetLocale()527 {528 $this529 ->if($test = new emptyTest())530 ->then531 ->object($test->setLocale($locale = new atoum\locale()))->isIdenticalTo($test)532 ->object($test->getLocale())->isIdenticalTo($locale)533 ;534 }535 public function testSetScore()536 {537 $this538 ->if($test = new emptyTest())539 ->then540 ->object($test->setScore($score = new atoum\test\score()))->isIdenticalTo($test)541 ->object($test->getScore())->isIdenticalTo($score)542 ;543 }544 public function testSetBootstrapFile()545 {546 $this547 ->if($test = new emptyTest())548 ->then549 ->object($test->setBootstrapFile($path = uniqid()))->isIdenticalTo($test)550 ->string($test->getBootstrapFile())->isEqualTo($path)551 ;552 }553 public function testSetMaxChildrenNumber()554 {555 $this556 ->if($test = new emptyTest())557 ->then558 ->exception(function () use ($test) {559 $test->setMaxChildrenNumber(- rand(1, PHP_INT_MAX));560 })561 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')562 ->hasMessage('Maximum number of children must be greater or equal to 1')563 ->exception(function () use ($test) {564 $test->setMaxChildrenNumber(0);565 })566 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')567 ->hasMessage('Maximum number of children must be greater or equal to 1')568 ->object($test->setMaxChildrenNumber($maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)569 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)570 ->object($test->setMaxChildrenNumber((string) $maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)571 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)572 ;573 }574 public function testGetClass()575 {576 $this577 ->if($test = new emptyTest())578 ->then579 ->string($test->getClass())->isEqualTo(__NAMESPACE__ . '\emptyTest')580 ;581 }582 public function testGetPath()583 {584 $this585 ->if($test = new emptyTest())586 ->then587 ->string($test->getPath())->isEqualTo(__FILE__)588 ;589 }590 public function testGetCoverage()591 {592 $this593 ->if($test = new emptyTest())594 ->then595 ->object($test->getCoverage())->isIdenticalTo($test->getScore()->getCoverage())596 ;597 }598 public function testIsIgnored()599 {600 $this601 ->if($test = new emptyTest())602 ->then603 ->boolean($test->isIgnored())->isTrue()604 ->object($test->ignore(false))->isIdenticalTo($test)605 ->boolean($test->isIgnored())->isTrue()606 ->object($test->ignore(true))->isIdenticalTo($test)607 ->boolean($test->isIgnored())->isTrue()608 ->if($test = new notEmptyTest())609 ->then610 ->boolean($test->isIgnored())->isTrue()611 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()612 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()613 ->object($test->ignore(false))->isIdenticalTo($test)614 ->boolean($test->isIgnored())->isFalse()615 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()616 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()617 ->object($test->ignore(true))->isIdenticalTo($test)618 ->boolean($test->isIgnored())->isTrue()619 ->boolean($test->methodIsIgnored('testMethod1'))->istrue()620 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()621 ;622 }623 public function testGetCurrentMethod()624 {625 $this626 ->if($test = new emptyTest())627 ->then628 ->variable($test->getCurrentMethod())->isNull()629 ;630 }631 public function testCount()632 {633 $this634 ->sizeOf(new emptyTest())->isEqualTo(0)635 ->if($test = new notEmptyTest())636 ->then637 ->sizeOf($test)->isEqualTo(0)638 ->if($test->ignore(false))639 ->then640 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()641 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()642 ->sizeOf($test)->isEqualTo(2)643 ->if($test->ignoreMethod('testMethod1', true))644 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()645 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()646 ->sizeOf($test)->isEqualTo(1)647 ->if($test->ignoreMethod('testMethod2', true))648 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()649 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()650 ->sizeOf($test)->isEqualTo(0)651 ;652 }653 public function testGetTestMethods()654 {655 $this656 ->if($test = new emptyTest())657 ->then658 ->boolean($test->ignore(false)->isIgnored())->isTrue()659 ->sizeOf($test)->isZero()660 ->array($test->getTestMethods())->isEmpty()661 ->if($test = new notEmptyTest())662 ->then663 ->boolean($test->isIgnored())->isTrue()664 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()665 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()666 ->sizeOf($test)->isEqualTo(0)667 ->array($test->getTestMethods())->isEmpty()668 ->boolean($test->ignore(false)->isIgnored())->isFalse()669 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()670 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()671 ->sizeOf($test)->isEqualTo(2)672 ->array($test->getTestMethods())->isEqualTo(['testMethod1', 'testMethod2'])673 ->array($test->getTestMethods(['method']))->isEqualTo(['testMethod1', 'testMethod2'])674 ->array($test->getTestMethods(['test']))->isEqualTo(['testMethod1', 'testMethod2'])675 ->array($test->getTestMethods(['two']))->isEqualTo(['testMethod2'])676 ->array($test->getTestMethods([uniqid()]))->isEmpty()677 ->array($test->getTestMethods(['test', 'method']))->isEqualTo(['testMethod1', 'testMethod2'])678 ->array($test->getTestMethods(['test', 'method', uniqid()]))->isEqualTo(['testMethod1', 'testMethod2'])679 ->array($test->getTestMethods(['test', 'method', 'two', uniqid()]))->isEqualTo(['testMethod1', 'testMethod2'])680 ;681 }682 public function testGetPhpPath()683 {684 $this685 ->if($test = new emptyTest())686 ->then687 ->variable($test->getPhpPath())->isNull()688 ->if($test->setPhpPath($phpPath = uniqid()))689 ->then690 ->string($test->getPhpPath())->isEqualTo($phpPath)691 ;692 }693 public function testSetPhpPath()694 {695 $this696 ->if($test = new emptyTest())697 ->then698 ->object($test->setPhpPath($phpPath = uniqid()))->isIdenticalTo($test)699 ->string($test->getPhpPath())->isIdenticalTo($phpPath)700 ->object($test->setPhpPath($phpPath = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)701 ->string($test->getPhpPath())->isIdenticalTo((string) $phpPath)702 ;703 }704 public function testMethodIsIgnored()705 {706 $this707 ->if($test = new emptyTest())708 ->then709 ->exception(function () use ($test, & $method) {710 $test->methodIsIgnored($method = uniqid());711 })712 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')713 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')714 ;715 }716 public function testSetTags()717 {718 $this719 ->if($test = new emptyTest())720 ->then721 ->object($test->setTags($tags = [uniqid(), uniqid()]))->isIdenticalTo($test)722 ->array($test->getTags())->isEqualTo($tags)723 ;724 }725 public function testSetMethodTags()726 {727 $this728 ->if($test = new notEmptyTest())729 ->then730 ->object($test->setMethodTags('testMethod1', $tags = [uniqid(), uniqid()]))->isIdenticalTo($test)731 ->array($test->getMethodTags('testMethod1'))->isEqualTo($tags)732 ->exception(function () use ($test, & $method) {733 $test->setMethodTags($method = uniqid(), []);734 })735 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')736 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')737 ;738 }739 public function testGetMethodTags()740 {741 $this742 ->if($test = new notEmptyTest())743 ->then744 ->array($test->getMethodTags('testMethod1'))->isEqualTo(['test', 'method', 'one'])745 ->exception(function () use ($test, & $method) {746 $test->getMethodTags($method = uniqid());747 })748 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')749 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')750 ->if($test = new inheritedTagsTest())751 ->then752 ->array($test->getMethodTags())->isEqualTo(['testMethod1' => ['first', 'second', 'third'], 'testMethod2' => ['first', 'second', 'third']])753 ->array($test->getMethodTags('testMethod1'))->isEqualTo(['first', 'second', 'third'])754 ->array($test->getMethodTags('testMethod2'))->isEqualTo(['first', 'second', 'third'])755 ->if($test = new dataProviderTest())756 ->then757 ->array($test->getMethodTags())->isEqualTo(['testMethod1' => [], 'testMethod2' => [], 'testMethod3' => []])758 ->array($test->getMethodTags('testMethod1'))->isEqualTo([])759 ->array($test->getMethodTags('testMethod2'))->isEqualTo([])760 ->array($test->getMethodTags('testMethod3'))->isEqualTo([])761 ;762 }763 public function testAddMandatoryClassExtension()764 {765 $this766 ->if($test = new notEmptyTest())767 ->then768 ->object($test->addMandatoryClassExtension($extension = uniqid()))->isIdenticalTo($test)769 ->array($test->getMandatoryClassExtensions())->isEqualTo([$extension])770 ->object($test->addMandatoryClassExtension($otherExtension = uniqid()))->isIdenticalTo($test)771 ->array($test->getMandatoryClassExtensions())->isEqualTo([$extension, $otherExtension])772 ;773 }774 public function testGetMandatoryMethodExtensions()775 {776 $this777 ->if($test = new notEmptyTest())778 ->then779 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEmpty()780 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket'])781 ;782 }783 public function testAddMandatoryMethodExtension()784 {785 $this786 ->if($test = new notEmptyTest())787 ->then788 ->exception(function () use ($test, & $method) {789 $test->addMandatoryMethodExtension($method = uniqid(), uniqid());790 })791 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')792 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')793 ->object($test->addMandatoryMethodExtension('testMethod1', $extension = uniqid()))->isIdenticalTo($test)794 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$extension], 'testMethod2' => ['mbstring', 'socket']])795 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$extension])796 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket'])797 ->object($test->addMandatoryMethodExtension('testMethod1', $otherExtension = uniqid()))->isIdenticalTo($test)798 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$extension, $otherExtension], 'testMethod2' => ['mbstring', 'socket']])799 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$extension, $otherExtension])800 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket'])801 ->object($test->addMandatoryMethodExtension('testMethod2', $anOtherExtension = uniqid()))->isIdenticalTo($test)802 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$extension, $otherExtension], 'testMethod2' => ['mbstring', 'socket', $anOtherExtension]])803 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$extension, $otherExtension])804 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket', $anOtherExtension])805 ->if($test->addMandatoryClassExtension($classExtension = uniqid()))806 ->then807 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$classExtension, $extension, $otherExtension], 'testMethod2' => [$classExtension, 'mbstring', 'socket', $anOtherExtension]])808 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$classExtension, $extension, $otherExtension])809 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo([$classExtension, 'mbstring', 'socket', $anOtherExtension])810 ;811 }812 public function testAddClassPhpVersion()813 {814 $this815 ->if($test = new notEmptyTest())816 ->then817 ->object($test->addClassPhpVersion('5.3'))->isIdenticalTo($test)818 ->array($test->getClassPhpVersions())->isEqualTo(['5.3' => '>='])819 ->object($test->addClassPhpVersion('5.4', '<='))->isIdenticalTo($test)820 ->array($test->getClassPhpVersions())->isEqualTo(['5.3' => '>=', '5.4' => '<='])821 ;822 }823 public function testAddMethodPhpVersion()824 {825 $this826 ->if($test = new notEmptyTest())827 ->then828 ->exception(function () use ($test, & $method) {829 $test->addMethodPhpVersion($method, '6.0');830 })831 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')832 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')833 ->object($test->addMethodPhpVersion('testMethod1', '5.3'))->isIdenticalTo($test)834 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.3' => '>='], 'testMethod2' => []])835 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.3' => '>='])836 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()837 ->object($test->addMethodPhpVersion('testMethod1', '5.4', '<='))->isIdenticalTo($test)838 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.3' => '>=', '5.4' => '<='], 'testMethod2' => []])839 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.3' => '>=', '5.4' => '<='])840 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()841 ->object($test->addMethodPhpVersion('testMethod2', '5.4', '>='))->isIdenticalTo($test)842 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.3' => '>=', '5.4' => '<='], 'testMethod2' => ['5.4' => '>=']])843 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.3' => '>=', '5.4' => '<='])844 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(['5.4' => '>='])845 ->if($test->addClassPhpVersion('5.5'))846 ->then847 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.5' => '>=', '5.3' => '>=', '5.4' => '<='], 'testMethod2' => ['5.5' => '>=', '5.4' => '>=']])848 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.5' => '>=', '5.3' => '>=', '5.4' => '<='])849 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(['5.5' => '>=', '5.4' => '>='])850 ;851 }852 public function testRun()853 {854 $this855 ->mockTestedClass('mock\tests\units')856 ->if($test = new \mock\tests\units\test())857 ->then858 ->object($test->run())->isIdenticalTo($test)859 ->mock($test)860 ->call('callObservers')861 ->withArguments(\mageekguy\atoum\test::runStart)->never()862 ->withArguments(\mageekguy\atoum\test::runStop)->never()863 ->withArguments(\mageekguy\atoum\test::beforeSetUp)->never()864 ->withArguments(\mageekguy\atoum\test::afterSetUp)->never()865 ->withArguments(\mageekguy\atoum\test::beforeTestMethod)->never()866 ->withArguments(\mageekguy\atoum\test::afterTestMethod)->never()867 ;868 }869 public function testSetTestedClassName()870 {871 $this872 ->if($test = new foo())873 ->then874 ->string($test->getTestedClassName())->isEqualTo('mageekguy\atoum\test')875 ->exception(function () use ($test) {876 $test->setTestedClassName(uniqid());877 })878 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')879 ->hasMessage('Tested class name is already defined')880 ->if($test = new self())881 ->then882 ->object($test->setTestedClassName($class = uniqid()))->isIdenticalTo($test)883 ->string($test->getTestedClassName())->isEqualTo($class)884 ->exception(function () use ($test) {885 $test->setTestedClassName(uniqid());886 })887 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')888 ->hasMessage('Tested class name is already defined')889 ;890 }891 public function testMockClass()892 {893 $this894 ->if($test = new emptyTest())895 ->then896 ->object($test->mockClass(__CLASS__))->isIdenticalTo($test)897 ->class('mock\\' . __CLASS__)->isSubClassOf(__CLASS__)898 ->object($test->mockClass(__CLASS__, 'foo'))->isIdenticalTo($test)899 ->class('foo\test')->isSubClassOf(__CLASS__)900 ->object($test->mockClass(__CLASS__, 'foo\bar'))->isIdenticalTo($test)901 ->class('foo\bar\test')->isSubClassOf(__CLASS__)902 ->object($test->mockClass(__CLASS__, 'foo', 'bar'))->isIdenticalTo($test)903 ->class('foo\bar')->isSubClassOf(__CLASS__)904 ;905 }906 public function testMockTestedClass()907 {908 $this909 ->if($test = new emptyTest())910 ->and($testedClassName = $test->getTestedClassName())911 ->then912 ->object($test->mockTestedClass())->isIdenticalTo($test)913 ->class('mock\\' . $testedClassName)->isSubClassOf($testedClassName)914 ->object($test->mockTestedClass('foo'))->isIdenticalTo($test)915 ->class('foo\emptyTest')->isSubClassOf($testedClassName)916 ->object($test->mockTestedClass('foo\bar'))->isIdenticalTo($test)917 ->class('foo\bar\emptyTest')->isSubClassOf($testedClassName)918 ->object($test->mockTestedClass('foo', 'bar'))->isIdenticalTo($test)919 ->class('foo\bar')->isSubClassOf($testedClassName)920 ;921 }922 public function testGetTaggedTestMethods()923 {924 $this925 ->if($test = new emptyTest())926 ->then927 ->array($test->getTaggedTestMethods([]))->isEmpty()928 ->array($test->getTaggedTestMethods([uniqid()]))->isEmpty()929 ->array($test->getTaggedTestMethods([uniqid(), uniqid()]))->isEmpty()930 ->if($test = new notEmptyTest())931 ->then932 ->array($test->getTaggedTestMethods([]))->isEmpty()933 ->array($test->getTaggedTestMethods([uniqid()]))->isEmpty()934 ->array($test->getTaggedTestMethods([uniqid(), uniqid()]))->isEmpty()935 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid()]))->isEmpty()936 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid(), 'testMethod2']))->isEmpty()937 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2']))->isEmpty()938 ->if($test->ignore(false))939 ->then940 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid()]))->isEqualTo(['testMethod1'])941 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod2', uniqid()]))->isEqualTo(['testMethod2'])942 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2']))->isEqualTo(['Testmethod1', 'Testmethod2'])943 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'], ['one']))->isEqualTo(['Testmethod1'])944 ->if($test->ignoreMethod('testMethod1', true))945 ->then946 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid()]))->isEmpty()947 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod2', uniqid()]))->isEqualTo(['testMethod2'])948 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2']))->isEqualTo(['Testmethod2'])949 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'], ['one']))->isEmpty()950 ;951 }952 public function testSetDataProvider()953 {954 $this955 ->if($test = new emptyTest())956 ->then957 ->exception(function () use ($test, & $method) {958 $test->setDataProvider($method = uniqid(), uniqid());959 })960 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')961 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')962 ->if($test = new notEmptyTest())963 ->then964 ->exception(function () use ($test, & $dataProvider) {965 $test->setDataProvider('testMethod1', $dataProvider = uniqid());966 })967 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')968 ->hasMessage('Data provider ' . get_class($test) . '::' . $dataProvider . '() is unknown')969 ->object($test->setDataProvider('testMethod1', 'aDataProvider'))->isIdenticalTo($test)970 ->array($test->getDataProviders())->isEqualTo(['testMethod1' => 'aDataProvider'])971 ->if($test = new dataProviderTest())972 ->then973 ->object($test->setDataProvider('testMethod2'))->isIdenticalTo($test)974 ->array($providers = $test->getDataProviders())975 ->object['testMethod2']->isInstanceOf('mageekguy\atoum\test\data\provider\aggregator')976 ->exception(function () use ($providers) {977 $providers['testMethod2']();978 })979 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')980 ->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')981 ->if($test->getMockGenerator()->allIsInterface())982 ->then983 ->exception(function () use ($providers) {984 $providers['testMethod2']();985 })986 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')987 ->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')988 ->if($test->getMockGenerator()->setDefaultNamespace('testMocks'))989 ->then990 ->array($providers['testMethod2']())->isEqualTo([[new \testMocks\splFileInfo()]])991 ->if($test = new dataProviderTest())992 ->then993 ->exception(function () use ($test, & $dataProvider) {994 $test->setDataProvider('testMethod3');995 })996 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')997 ->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')998 ->object($test->setDataProvider('testMethod1'))->isIdenticalTo($test)999 ->array($test->getDataProviders())1000 ->object['testMethod1']->isInstanceOf('mageekguy\atoum\test\data\provider\aggregator')1001 ->if($test = new dataProviderTest())1002 ->then1003 ->exception(function () use ($test, & $dataProvider) {1004 $test->setDataProvider('testMethod3', function () {...
testMethod2
Using AI Code Generation
1$test = new inheritedTagsTest();2$test->testMethod2();3$test = new inheritedTagsTest();4$test->testMethod1();5Your name to display (optional):6Your name to display (optional):7class inheritedTagsTest{8 public function testMethod1(){9 }10}11Your name to display (optional):
testMethod2
Using AI Code Generation
1$test = new inheritedTagsTest();2$test->testMethod2();3$test = new inheritedTagsTest();4$test->testMethod1();5$test = new inheritedTagsTest();6$test->testMethod1();7$test = new inheritedTagsTest();8$test->testMethod2();
testMethod2
Using AI Code Generation
1$test = new inheritedTagsTest();2$test->testMethod2();3$test = new inheritedTagsTest();4$test->testMethod3();5$test = new inheritedTagsTest();6$test->testMethod4();7$test = new inheritedTagsTest();8$test->testMethod5();9$test = new inheritedTagsTest();10$test->testMethod6();11$test = new inheritedTagsTest();12$test->testMethod7();13$test = new inheritedTagsTest();14$test->testMethod8();15$test = new inheritedTagsTest();16$test->testMethod9();17$test = new inheritedTagsTest();18$test->testMethod10();19$test = new inheritedTagsTest();20$test->testMethod11();21$test = new inheritedTagsTest();22$test->testMethod12();23$test = new inheritedTagsTest();24$test->testMethod13();25$test = new inheritedTagsTest();26$test->testMethod14();27$test = new inheritedTagsTest();28$test->testMethod15();
testMethod2
Using AI Code Generation
1$obj = new inheritedTagsTest();2$obj->testMethod2();3$obj = new inheritedTagsTest();4$obj->testMethod3();5$obj = new inheritedTagsTest();6$obj->testMethod4();7$obj = new inheritedTagsTest();8$obj->testMethod5();9$obj = new inheritedTagsTest();10$obj->testMethod6();11$obj = new inheritedTagsTest();12$obj->testMethod7();13$obj = new inheritedTagsTest();14$obj->testMethod8();15$obj = new inheritedTagsTest();16$obj->testMethod9();17$obj = new inheritedTagsTest();18$obj->testMethod10();19$obj = new inheritedTagsTest();20$obj->testMethod11();21$obj = new inheritedTagsTest();22$obj->testMethod12();23$obj = new inheritedTagsTest();24$obj->testMethod13();25$obj = new inheritedTagsTest();26$obj->testMethod14();27$obj = new inheritedTagsTest();28$obj->testMethod15();29$obj = new inheritedTagsTest();30$obj->testMethod16();
testMethod2
Using AI Code Generation
1$obj = new inheritedTagsTest();2$obj->testMethod2();3$obj = new inheritedTagsTest();4$obj->testMethod1();5$obj = new inheritedTagsTest();6$obj->testMethod2();7$obj = new inheritedTagsTest();8$obj->testMethod1();9$obj = new newClass();10$obj->testMethod1();11$obj = new newClass();12$obj->testMethod2();13$obj = new inheritedTagsTest();14$obj->testMethod2();15$obj = new inheritedTagsTest();16$obj->testMethod1();17$obj = new newClass();18$obj->testMethod1();19$obj = new newClass();20$obj->testMethod2();21$obj = new newClass();22$obj->testMethod3();
testMethod2
Using AI Code Generation
1$obj = new inheritedTagsTest();2$obj->testMethod2();3$obj = new inheritedTagsTest();4$obj->testMethod();5function testMethod ( $name )6{7}8function testMethod2 ( $name )9{10}11function testMethod ( $name )12{13}14function testMethod2 ( $name )15{16}17function testMethod ( $name )18{19}20function testMethod2 ( $name )21{22}23function testMethod ( $name )24{25}26function testMethod2 ( $name )27{28}29function testMethod ( $name )30{31}32function testMethod2 ( $name )33{34}35function testMethod ( $name )36{37}38function testMethod2 ( $name )39{40}41function testMethod ( $name )42{43}44function testMethod2 ( $name )45{46}47function testMethod ( $name )48{49}50function testMethod2 ( $name )51{
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 testMethod2 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!!