How to use __construct method of emptyTest class

Best Atoum code snippet using emptyTest.__construct

test.php

Source:test.php Github

copy

Full Screen

...15 }16 }17 class dummy18 {19 public function __construct($firstArgument, $secondArgument) {}20 }21}22namespace mageekguy\atoum\mock\mageekguy\atoum23{24 class test {}25}26namespace mageekguy\atoum\tests\units27{28 use29 mageekguy\atoum,30 mageekguy\atoum\mock31 ;32 require_once __DIR__ . '/../runner.php';33 /**34 * @ignore on35 * @tags empty fake dummy36 * @maxChildrenNumber 66637 */38 class emptyTest extends atoum\test {}39 /**40 * @ignore on41 */42 class notEmptyTest extends atoum\test43 {44 /**45 @tags test method one method46 */47 public function testMethod1() {}48 /**49 * @extensions mbstring socket50 * @ignore off51 * @tags test method two52 */53 public function testMethod2() {}54 public function aDataProvider()55 {56 }57 }58 /**59 * @ignore on60 * @tags first61 */62 class inheritedTagsTest extends atoum\test63 {64 /**65 * @tags second third66 */67 public function testMethod1() {}68 /**69 * @tags first second third70 */71 public function testMethod2() {}72 }73 /**74 * @ignore on75 */76 class dataProviderTest extends atoum\test77 {78 public function testMethod1(\stdClass $a) {}79 public function testMethod2(\splFileInfo $a) {}80 public function testMethod3($a) {}81 }82 class foo extends atoum\test83 {84 public function __construct()85 {86 $this->setTestedClassName('mageekguy\atoum\test');87 parent::__construct();88 }89 }90 /**91 * @ignore on92 */93 class withStatic extends atoum\test94 {95 public function __construct()96 {97 $this->setTestedClassName('mageekguy\atoum\withStatic');98 parent::__construct();99 }100 }101 class test extends atoum\test102 {103 public function testClassConstants()104 {105 $this106 ->string(atoum\test::testMethodPrefix)->isEqualTo('test')107 ->string(atoum\test::runStart)->isEqualTo('testRunStart')108 ->string(atoum\test::beforeSetUp)->isEqualTo('beforeTestSetUp')109 ->string(atoum\test::afterSetUp)->isEqualTo('afterTestSetUp')110 ->string(atoum\test::beforeTestMethod)->isEqualTo('beforeTestMethod')111 ->string(atoum\test::fail)->isEqualTo('testAssertionFail')112 ->string(atoum\test::error)->isEqualTo('testError')113 ->string(atoum\test::uncompleted)->isEqualTo('testUncompleted')114 ->string(atoum\test::skipped)->isEqualTo('testSkipped')115 ->string(atoum\test::exception)->isEqualTo('testException')116 ->string(atoum\test::success)->isEqualTo('testAssertionSuccess')117 ->string(atoum\test::afterTestMethod)->isEqualTo('afterTestMethod')118 ->string(atoum\test::beforeTearDown)->isEqualTo('beforeTestTearDown')119 ->string(atoum\test::afterTearDown)->isEqualTo('afterTestTearDown')120 ->string(atoum\test::runStop)->isEqualTo('testRunStop')121 ->string(atoum\test::defaultNamespace)->isEqualTo('#(?:^|\\\\)tests?\\\\units?\\\\#i')122 ->string(atoum\test::defaultMethodPrefix)->isEqualTo('#^(?:test|_*[^_]+_should_)#i')123 ;124 }125 public function test__construct()126 {127 $this128 ->if($test = new emptyTest())129 ->then130 ->object($test->getScore())->isInstanceOf('mageekguy\atoum\score')131 ->object($test->getLocale())->isEqualTo(new atoum\locale())132 ->object($test->getAdapter())->isEqualTo(new atoum\adapter())133 ->object($test->getPhpFunctionMocker())->isInstanceOf('mageekguy\atoum\php\mocker\funktion')134 ->object($test->getPhpConstantMocker())->isInstanceOf('mageekguy\atoum\php\mocker\constant')135 ->object($test->getFactoryBuilder())->isInstanceOf('mageekguy\atoum\factory\builder\closure')136 ->boolean($test->isIgnored())->isTrue()137 ->boolean($test->debugModeIsEnabled())->isFalse()138 ->array($test->getAllTags())->isEqualTo($tags = array('empty', 'fake', 'dummy'))139 ->array($test->getTags())->isEqualTo($tags)140 ->array($test->getMethodTags())->isEmpty()141 ->array($test->getDataProviders())->isEmpty()142 ->integer($test->getMaxChildrenNumber())->isEqualTo(666)143 ->boolean($test->codeCoverageIsEnabled())->isEqualTo(extension_loaded('xdebug'))144 ->string($test->getTestNamespace())->isEqualTo(atoum\test::defaultNamespace)145 ->integer($test->getMaxChildrenNumber())->isEqualTo(666)146 ->variable($test->getBootstrapFile())->isNull()147 ->array($test->getClassPhpVersions())->isEmpty()148 ->array($test->getMandatoryClassExtensions())->isEmpty()149 ->array($test->getMandatoryMethodExtensions())->isEmpty()150 ->variable($test->getXdebugConfig())->isNull()151 ;152 }153 public function test__toString()154 {155 $this->castToString($this)->isEqualTo(__CLASS__);156 }157 public function test__get()158 {159 $this160 ->if($test = new emptyTest())161 ->then162 ->object($test->assert)->isInstanceOf('mageekguy\atoum\test')163 ->object($test->define)->isInstanceOf('mageekguy\atoum\test\assertion\aliaser')164 ->object($test->mockGenerator)->isInstanceOf('mageekguy\atoum\mock\generator')165 ->if($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))166 ->then167 ->object($test->mockGenerator)->isIdenticalTo($mockGenerator)168 ->if($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator(new emptyTest())))169 ->then170 ->object($test->assert)->isIdenticalTo($test)171 ->variable($test->exception)->isNull()172 ->exception(function() use ($test, & $property) { $test->{$property = uniqid()}; })173 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')174 ->hasMessage('Asserter \'' . $property . '\' does not exist')175 ->exception($test->exception)176 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')177 ->hasMessage('Asserter \'' . $property . '\' does not exist')178 ;179 }180 public function test__set()181 {182 $this183 ->given(184 $test = new emptyTest(),185 $test->setAssertionManager($assertionManager = new \mock\mageekguy\atoum\test\assertion\manager())186 )187 ->if($test->{$event = uniqid()} = $handler = function() {})188 ->then189 ->mock($assertionManager)->call('setHandler')->withArguments($event, $handler)->once()190 ;191 }192 public function testEnableDebugMode()193 {194 $this195 ->if($test = new emptyTest())196 ->then197 ->object($test->enableDebugMode())->isIdenticalTo($test)198 ->boolean($test->debugModeIsEnabled())->isTrue()199 ->object($test->enableDebugMode())->isIdenticalTo($test)200 ->boolean($test->debugModeIsEnabled())->isTrue()201 ;202 }203 public function testDisableDebugMode()204 {205 $this206 ->if($test = new emptyTest())207 ->then208 ->object($test->disableDebugMode())->isIdenticalTo($test)209 ->boolean($test->debugModeIsEnabled())->isFalse()210 ->object($test->disableDebugMode())->isIdenticalTo($test)211 ->boolean($test->debugModeIsEnabled())->isFalse()212 ->if($test->enableDebugMode())213 ->then214 ->object($test->disableDebugMode())->isIdenticalTo($test)215 ->boolean($test->debugModeIsEnabled())->isFalse()216 ;217 }218 public function testEnableCodeCoverage()219 {220 $this221 ->assert('Code coverage must be enabled only if xdebug is available')222 ->if($adapter = new atoum\test\adapter())223 ->and($adapter->extension_loaded = function($extension) { return $extension == 'xdebug'; })224 ->and($test = new emptyTest($adapter))225 ->then226 ->boolean($test->codeCoverageIsEnabled())->isTrue()227 ->object($test->enableCodeCoverage())->isIdenticalTo($test)228 ->boolean($test->codeCoverageIsEnabled())->isTrue()229 ->if($test->disableCodeCoverage())230 ->then231 ->boolean($test->codeCoverageIsEnabled())->isFalse()232 ->object($test->enableCodeCoverage())->isIdenticalTo($test)233 ->boolean($test->codeCoverageIsEnabled())->isTrue()234 ->assert('Code coverage must not be enabled if xdebug is not available')235 ->if($adapter->extension_loaded = function($extension) { return $extension != 'xdebug'; })236 ->and($test = new emptyTest($adapter))237 ->then238 ->boolean($test->codeCoverageIsEnabled())->isFalse()239 ->object($test->enableCodeCoverage())->isIdenticalTo($test)240 ->boolean($test->codeCoverageIsEnabled())->isFalse()241 ;242 }243 public function testDisableCodeCoverage()244 {245 $this246 ->if($adapter = new atoum\test\adapter())247 ->and($adapter->extension_loaded = true)248 ->and($test = new emptyTest($adapter))249 ->then250 ->boolean($test->codeCoverageIsEnabled())->isTrue()251 ->object($test->disableCodeCoverage())->isIdenticalTo($test)252 ->boolean($test->codeCoverageIsEnabled())->isFalse()253 ->if($test->enableCodeCoverage())254 ->then255 ->boolean($test->codeCoverageIsEnabled())->isTrue()256 ->object($test->disableCodeCoverage())->isIdenticalTo($test)257 ->boolean($test->codeCoverageIsEnabled())->isFalse()258 ;259 }260 public function testGetMockGenerator()261 {262 $this263 ->if($test = new emptyTest())264 ->then265 ->object($test->getMockGenerator())->isInstanceOf('mageekguy\atoum\mock\generator')266 ->if($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))267 ->then268 ->object($test->getMockGenerator())->isIdenticalTo($mockGenerator)269 ->object($mockGenerator->getTest())->isIdenticalTo($test)270 ;271 }272 public function testSetMockGenerator()273 {274 $this275 ->if($test = new emptyTest())276 ->then277 ->object($test->setMockGenerator($mockGenerator = new atoum\test\mock\generator($this)))->isIdenticalTo($test)278 ->object($test->getMockGenerator())->isIdenticalTo($mockGenerator)279 ->object($mockGenerator->getTest())->isIdenticalTo($test)280 ;281 }282 public function testSetMockAutoloader()283 {284 $this285 ->if($test = new emptyTest())286 ->then287 ->object($test->setMockAutoloader($mockAutoloader = new atoum\autoloader\mock()))->isIdenticalTo($test)288 ->object($test->getMockAutoloader())->isIdenticalTo($mockAutoloader)289 ;290 }291 public function testGetAsserterGenerator()292 {293 $this294 ->if($test = new emptyTest())295 ->then296 ->object($test->getAsserterGenerator())->isInstanceOf('mageekguy\atoum\test\asserter\generator')297 ->if($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator($this)))298 ->then299 ->object($test->getAsserterGenerator())->isIdenticalTo($asserterGenerator)300 ->object($asserterGenerator->getTest())->isIdenticalTo($test)301 ;302 }303 public function testSetAsserterGenerator()304 {305 $this306 ->if($test = new emptyTest())307 ->then308 ->object($test->setAsserterGenerator($asserterGenerator = new atoum\test\asserter\generator($test)))->isIdenticalTo($test)309 ->object($test->getAsserterGenerator())->isIdenticalTo($asserterGenerator)310 ->object($asserterGenerator->getTest())->isIdenticalTo($test)311 ->object($asserterGenerator->getLocale())->isIdenticalTo($test->getLocale())312 ;313 }314 public function testGetFactoryBuilder()315 {316 $this317 ->if($test = new emptyTest())318 ->then319 ->object($test->getFactoryBuilder())->isInstanceOf('mageekguy\atoum\factory\builder\closure')320 ->if($test->setFactoryBuilder($factoryBuilder = new \mock\atoum\factory\builder()))321 ->then322 ->object($test->getFactoryBuilder())->isIdenticalTo($factoryBuilder)323 ;324 }325 public function testSetFactoryBuilder()326 {327 $this328 ->if($test = new emptyTest())329 ->then330 ->object($test->setFactoryBuilder($factoryBuilder = new \mock\atoum\factory\builder()))->isIdenticalTo($test)331 ->object($test->getFactoryBuilder())->isIdenticalTo($factoryBuilder)332 ->object($test->setFactoryBuilder())->isIdenticalTo($test)333 ->object($test->getFactoryBuilder())334 ->isEqualTo(new atoum\Factory\builder\closure())335 ->isNotIdenticalTo($factoryBuilder)336 ;337 }338 public function testSetPhpFunktionMocker()339 {340 $this341 ->if($test = new emptyTest())342 ->then343 ->object($test->setPhpFunctionMocker($phpFunctionMocker = new atoum\php\mocker\funktion()))->isIdenticalTo($test)344 ->object($test->getPhpFunctionMocker())->isIdenticalTo($phpFunctionMocker)345 ->object($test->setPhpFunctionMocker())->isIdenticalTo($test)346 ->object($test->getPhpFunctionMocker())347 ->isNotIdenticalTo($phpFunctionMocker)348 ->isInstanceOf('mageekguy\atoum\php\mocker\funktion')349 ;350 }351 public function testSetTestNamespace()352 {353 $this354 ->if($test = new self())355 ->then356 ->object($test->setTestNamespace($testNamespace = uniqid('_')))->isIdenticalTo($test)357 ->string($test->getTestNamespace())->isEqualTo($testNamespace)358 ->object($test->setTestNamespace('\\' . $testNamespace))->isIdenticalTo($test)359 ->string($test->getTestNamespace())->isEqualTo($testNamespace)360 ->object($test->setTestNamespace($testNamespace . '\\'))->isIdenticalTo($test)361 ->string($test->getTestNamespace())->isEqualTo($testNamespace)362 ->object($test->setTestNamespace('\\' . $testNamespace . '\\'))->isIdenticalTo($test)363 ->string($test->getTestNamespace())->isEqualTo($testNamespace)364 ->object($test->setTestNamespace($testNamespace = uniqid('_') . '\\' . $testNamespace))->isIdenticalTo($test)365 ->string($test->getTestNamespace())->isEqualTo($testNamespace)366 ->object($test->setTestNamespace('\\' . $testNamespace))->isIdenticalTo($test)367 ->string($test->getTestNamespace())->isEqualTo($testNamespace)368 ->object($test->setTestNamespace($testNamespace . '\\'))->isIdenticalTo($test)369 ->string($test->getTestNamespace())->isEqualTo($testNamespace)370 ->object($test->setTestNamespace('\\' . $testNamespace . '\\'))->isIdenticalTo($test)371 ->string($test->getTestNamespace())->isEqualTo($testNamespace)372 ->object($test->setTestNamespace($testNamespace = '_' . rand(0, PHP_INT_MAX)))->isIdenticalTo($test)373 ->string($test->getTestNamespace())->isEqualTo((string) $testNamespace)374 ->object($test->setTestNamespace('\\' . $testNamespace))->isIdenticalTo($test)375 ->string($test->getTestNamespace())->isEqualTo($testNamespace)376 ->object($test->setTestNamespace($testNamespace . '\\'))->isIdenticalTo($test)377 ->string($test->getTestNamespace())->isEqualTo($testNamespace)378 ->object($test->setTestNamespace('\\' . $testNamespace . '\\'))->isIdenticalTo($test)379 ->string($test->getTestNamespace())->isEqualTo($testNamespace)380 ->exception(function() use ($test) {381 $test->setTestNamespace('');382 }383 )384 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')385 ->hasMessage('Test namespace must not be empty')386 ->exception(function() use ($test) {387 $test->setTestNamespace('0');388 }389 )390 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')391 ->hasMessage('Test namespace must be a valid regex or identifier')392 ->exception(function() use ($test) {393 $test->setTestNamespace(uniqid('_') . '\\\\' . uniqid('_'));394 }395 )396 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')397 ->hasMessage('Test namespace must be a valid regex or identifier')398 ;399 }400 public function testGetTestNamespace()401 {402 $this403 ->if($test = new self())404 ->then405 ->string($test->getTestNamespace())->isEqualTo(atoum\test::defaultNamespace)406 ->if($test->setTestNamespace($testNamespace = uniqid('_')))407 ->then408 ->string($test->getTestNamespace())->isEqualTo($testNamespace)409 ;410 }411 public function testSetTestMethodPrefix()412 {413 $this414 ->if($test = new self())415 ->then416 ->object($test->setTestMethodPrefix($testMethodPrefix = uniqid('_')))->isIdenticalTo($test)417 ->string($test->getTestMethodPrefix())->isEqualTo($testMethodPrefix)418 ->object($test->setTestMethodPrefix($testMethodPrefix = '/^test/i'))->isIdenticalTo($test)419 ->string($test->getTestMethodPrefix())->isEqualTo($testMethodPrefix)420 ->object($test->setTestMethodPrefix($testMethodPrefix = ('_'.rand(0, PHP_INT_MAX))))->isIdenticalTo($test)421 ->string($test->getTestMethodPrefix())->isEqualTo((string) $testMethodPrefix)422 ->object($test->setTestMethodPrefix($testMethodPrefix = "_0"))->isIdenticalTo($test)423 ->string($test->getTestMethodPrefix())->isEqualTo((string) $testMethodPrefix)424 ->exception(function() use ($test) {425 $test->setTestMethodPrefix('');426 }427 )428 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')429 ->hasMessage('Test method prefix must not be empty')430 ->exception(function() use ($test) {431 $test->setTestMethodPrefix('0');432 }433 )434 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')435 ->hasMessage('Test method prefix must a valid regex or identifier')436 ->exception(function() use ($test) {437 $test->setTestMethodPrefix('/:(/');438 }439 )440 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')441 ->hasMessage('Test method prefix must a valid regex or identifier')442 ;443 }444 public function testGetTestMethodPrefix()445 {446 $this447 ->if($test = new self())448 ->then449 ->string($test->getTestMethodPrefix())->isEqualTo(atoum\test::defaultMethodPrefix)450 ->if($test->setTestMethodPrefix($testMethodPrefix = uniqid('_')))451 ->then452 ->string($test->getTestMethodPrefix())->isEqualTo($testMethodPrefix)453 ;454 }455 public function testGetTestedClassName()456 {457 $mockClass = '\mock\\' . __CLASS__;458 $this459 ->if($test = new $mockClass())460 ->and($test->getMockController()->getClass = $testClass = 'foo')461 ->then462 ->exception(function() use ($test) { $test->getTestedClassName(); })463 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')464 ->hasMessage('Test class \'' . $testClass . '\' is not in a namespace which match pattern \'' . $test->getTestNamespace() . '\'')465 ->if($test->getMockController()->getClass = 'tests\units\foo')466 ->then467 ->string($test->getTestedClassName())->isEqualTo('foo')468 ;469 }470 public function testGetTestedClassPath()471 {472 $this473 ->if($testedClass = new \reflectionClass($this->getTestedClassName()))474 ->then475 ->string($this->getTestedClassPath())->isEqualTo($testedClass->getFilename())476 ;477 }478 public function testGetAdapter()479 {480 $this481 ->if($test = new emptyTest())482 ->then483 ->object($test->getAdapter())->isInstanceOf('mageekguy\atoum\adapter')484 ;485 }486 public function testSetAdapter()487 {488 $this489 ->if($test = new emptyTest())490 ->then491 ->object($test->setAdapter($adapter = new atoum\test\adapter()))->isIdenticalTo($test)492 ->object($test->getAdapter())->isIdenticalTo($adapter)493 ;494 }495 public function testSetLocale()496 {497 $this498 ->if($test = new emptyTest())499 ->then500 ->object($test->setLocale($locale = new atoum\locale()))->isIdenticalTo($test)501 ->object($test->getLocale())->isIdenticalTo($locale)502 ;503 }504 public function testSetScore()505 {506 $this507 ->if($test = new emptyTest())508 ->then509 ->object($test->setScore($score = new atoum\test\score()))->isIdenticalTo($test)510 ->object($test->getScore())->isIdenticalTo($score)511 ;512 }513 public function testSetBootstrapFile()514 {515 $this516 ->if($test = new emptyTest())517 ->then518 ->object($test->setBootstrapFile($path = uniqid()))->isIdenticalTo($test)519 ->string($test->getBootstrapFile())->isEqualTo($path)520 ;521 }522 public function testSetMaxChildrenNumber()523 {524 $this525 ->if($test = new emptyTest())526 ->then527 ->exception(function() use ($test) { $test->setMaxChildrenNumber(- rand(1, PHP_INT_MAX)); })528 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')529 ->hasMessage('Maximum number of children must be greater or equal to 1')530 ->exception(function() use ($test) { $test->setMaxChildrenNumber(0); })531 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')532 ->hasMessage('Maximum number of children must be greater or equal to 1')533 ->object($test->setMaxChildrenNumber($maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)534 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)535 ->object($test->setMaxChildrenNumber((string) $maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)536 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)537 ;538 }539 public function testGetClass()540 {541 $this542 ->if($test = new emptyTest())543 ->then544 ->string($test->getClass())->isEqualTo(__NAMESPACE__ . '\emptyTest')545 ;546 }547 public function testGetPath()548 {549 $this550 ->if($test = new emptyTest())551 ->then552 ->string($test->getPath())->isEqualTo(__FILE__)553 ;554 }555 public function testGetCoverage()556 {557 $this558 ->if($test = new emptyTest())559 ->then560 ->object($test->getCoverage())->isIdenticalTo($test->getScore()->getCoverage())561 ;562 }563 public function testIsIgnored()564 {565 $this566 ->if($test = new emptyTest())567 ->then568 ->boolean($test->isIgnored())->isTrue()569 ->object($test->ignore(false))->isIdenticalTo($test)570 ->boolean($test->isIgnored())->isTrue()571 ->object($test->ignore(true))->isIdenticalTo($test)572 ->boolean($test->isIgnored())->isTrue()573 ->if($test = new notEmptyTest())574 ->then575 ->boolean($test->isIgnored())->isTrue()576 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()577 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()578 ->object($test->ignore(false))->isIdenticalTo($test)579 ->boolean($test->isIgnored())->isFalse()580 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()581 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()582 ->object($test->ignore(true))->isIdenticalTo($test)583 ->boolean($test->isIgnored())->isTrue()584 ->boolean($test->methodIsIgnored('testMethod1'))->istrue()585 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()586 ;587 }588 public function testGetCurrentMethod()589 {590 $this591 ->if($test = new emptyTest())592 ->then593 ->variable($test->getCurrentMethod())->isNull()594 ;595 }596 public function testCount()597 {598 $this599 ->sizeOf(new emptyTest())->isEqualTo(0)600 ->if($test = new notEmptyTest())601 ->then602 ->sizeOf($test)->isEqualTo(0)603 ->if($test->ignore(false))604 ->then605 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()606 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()607 ->sizeOf($test)->isEqualTo(2)608 ->if($test->ignoreMethod('testMethod1', true))609 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()610 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()611 ->sizeOf($test)->isEqualTo(1)612 ->if($test->ignoreMethod('testMethod2', true))613 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()614 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()615 ->sizeOf($test)->isEqualTo(0)616 ;617 }618 public function testGetTestMethods()619 {620 $this621 ->if($test = new emptyTest())622 ->then623 ->boolean($test->ignore(false)->isIgnored())->isTrue()624 ->sizeOf($test)->isZero()625 ->array($test->getTestMethods())->isEmpty()626 ->if($test = new notEmptyTest())627 ->then628 ->boolean($test->isIgnored())->isTrue()629 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()630 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()631 ->sizeOf($test)->isEqualTo(0)632 ->array($test->getTestMethods())->isEmpty()633 ->boolean($test->ignore(false)->isIgnored())->isFalse()634 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()635 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()636 ->sizeOf($test)->isEqualTo(2)637 ->array($test->getTestMethods())->isEqualTo(array('testMethod1', 'testMethod2'))638 ->array($test->getTestMethods(array('method')))->isEqualTo(array('testMethod1', 'testMethod2'))639 ->array($test->getTestMethods(array('test')))->isEqualTo(array('testMethod1', 'testMethod2'))640 ->array($test->getTestMethods(array('two')))->isEqualTo(array('testMethod2'))641 ->array($test->getTestMethods(array(uniqid())))->isEmpty()642 ->array($test->getTestMethods(array('test', 'method')))->isEqualTo(array('testMethod1', 'testMethod2'))643 ->array($test->getTestMethods(array('test', 'method', uniqid())))->isEqualTo(array('testMethod1', 'testMethod2'))644 ->array($test->getTestMethods(array('test', 'method', 'two', uniqid())))->isEqualTo(array('testMethod1', 'testMethod2'))645 ;646 }647 public function testGetPhpPath()648 {649 $this650 ->if($test = new emptyTest())651 ->then652 ->variable($test->getPhpPath())->isNull()653 ->if($test->setPhpPath($phpPath = uniqid()))654 ->then655 ->string($test->getPhpPath())->isEqualTo($phpPath)656 ;657 }658 public function testSetPhpPath()659 {660 $this661 ->if($test = new emptyTest())662 ->then663 ->object($test->setPhpPath($phpPath = uniqid()))->isIdenticalTo($test)664 ->string($test->getPhpPath())->isIdenticalTo($phpPath)665 ->object($test->setPhpPath($phpPath = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)666 ->string($test->getPhpPath())->isIdenticalTo((string) $phpPath)667 ;668 }669 public function testMethodIsIgnored()670 {671 $this672 ->if($test = new emptyTest())673 ->then674 ->exception(function() use ($test, & $method) { $test->methodIsIgnored($method = uniqid()); })675 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')676 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')677 ;678 }679 public function testSetTags()680 {681 $this682 ->if($test = new emptyTest())683 ->then684 ->object($test->setTags($tags = array(uniqid(), uniqid())))->isIdenticalTo($test)685 ->array($test->getTags())->isEqualTo($tags)686 ;687 }688 public function testSetMethodTags()689 {690 $this691 ->if($test = new notEmptyTest())692 ->then693 ->object($test->setMethodTags('testMethod1', $tags = array(uniqid(), uniqid())))->isIdenticalTo($test)694 ->array($test->getMethodTags('testMethod1'))->isEqualTo($tags)695 ->exception(function() use ($test, & $method) { $test->setMethodTags($method = uniqid(), array()); })696 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')697 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')698 ;699 }700 public function testGetMethodTags()701 {702 $this703 ->if($test = new notEmptyTest())704 ->then705 ->array($test->getMethodTags('testMethod1'))->isEqualTo(array('test', 'method', 'one'))706 ->exception(function() use ($test, & $method) { $test->getMethodTags($method = uniqid()); })707 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')708 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')709 ->if($test = new inheritedTagsTest())710 ->then711 ->array($test->getMethodTags())->isEqualTo(array('testMethod1' => array('first', 'second', 'third'), 'testMethod2' => array('first', 'second', 'third')))712 ->array($test->getMethodTags('testMethod1'))->isEqualTo(array('first', 'second', 'third'))713 ->array($test->getMethodTags('testMethod2'))->isEqualTo(array('first', 'second', 'third'))714 ->if($test = new dataProviderTest())715 ->then716 ->array($test->getMethodTags())->isEqualTo(array('testMethod1' => array(), 'testMethod2' => array(), 'testMethod3' => array()))717 ->array($test->getMethodTags('testMethod1'))->isEqualTo(array())718 ->array($test->getMethodTags('testMethod2'))->isEqualTo(array())719 ->array($test->getMethodTags('testMethod3'))->isEqualTo(array())720 ;721 }722 public function testAddMandatoryClassExtension()723 {724 $this725 ->if($test = new notEmptyTest())726 ->then727 ->object($test->addMandatoryClassExtension($extension = uniqid()))->isIdenticalTo($test)728 ->array($test->getMandatoryClassExtensions())->isEqualTo(array($extension))729 ->object($test->addMandatoryClassExtension($otherExtension = uniqid()))->isIdenticalTo($test)730 ->array($test->getMandatoryClassExtensions())->isEqualTo(array($extension, $otherExtension))731 ;732 }733 public function testGetMandatoryMethodExtensions()734 {735 $this736 ->if($test = new notEmptyTest())737 ->then738 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEmpty()739 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(array('mbstring', 'socket'))740 ;741 }742 public function testAddMandatoryMethodExtension()743 {744 $this745 ->if($test = new notEmptyTest())746 ->then747 ->exception(function() use ($test, & $method) { $test->addMandatoryMethodExtension($method = uniqid(), uniqid()); })748 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')749 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')750 ->object($test->addMandatoryMethodExtension('testMethod1', $extension = uniqid()))->isIdenticalTo($test)751 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($extension), 'testMethod2' => array('mbstring', 'socket')))752 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($extension))753 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(array('mbstring', 'socket'))754 ->object($test->addMandatoryMethodExtension('testMethod1', $otherExtension = uniqid()))->isIdenticalTo($test)755 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($extension, $otherExtension), 'testMethod2' => array('mbstring', 'socket')))756 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($extension, $otherExtension))757 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(array('mbstring', 'socket'))758 ->object($test->addMandatoryMethodExtension('testMethod2', $anOtherExtension = uniqid()))->isIdenticalTo($test)759 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($extension, $otherExtension), 'testMethod2' => array('mbstring', 'socket', $anOtherExtension)))760 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($extension, $otherExtension))761 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(array('mbstring', 'socket', $anOtherExtension))762 ->if($test->addMandatoryClassExtension($classExtension = uniqid()))763 ->then764 ->array($test->getMandatoryMethodExtensions())->isEqualTo(array('testMethod1' => array($classExtension, $extension, $otherExtension), 'testMethod2' => array($classExtension, 'mbstring', 'socket', $anOtherExtension)))765 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo(array($classExtension, $extension, $otherExtension))766 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(array($classExtension, 'mbstring', 'socket', $anOtherExtension))767 ;768 }769 public function testAddClassPhpVersion()770 {771 $this772 ->if($test = new notEmptyTest())773 ->then774 ->object($test->addClassPhpVersion('5.3'))->isIdenticalTo($test)775 ->array($test->getClassPhpVersions())->isEqualTo(array('5.3' => '>='))776 ->object($test->addClassPhpVersion('5.4', '<='))->isIdenticalTo($test)777 ->array($test->getClassPhpVersions())->isEqualTo(array('5.3' => '>=', '5.4' => '<='))778 ;779 }780 public function testAddMethodPhpVersion()781 {782 $this783 ->if($test = new notEmptyTest())784 ->then785 ->exception(function() use ($test, & $method) { $test->addMethodPhpVersion($method, '6.0'); })786 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')787 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')788 ->object($test->addMethodPhpVersion('testMethod1', '5.3'))->isIdenticalTo($test)789 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.3' => '>='), 'testMethod2' => array()))790 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.3' => '>='))791 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()792 ->object($test->addMethodPhpVersion('testMethod1', '5.4', '<='))->isIdenticalTo($test)793 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.3' => '>=', '5.4' => '<='), 'testMethod2' => array()))794 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.3' => '>=', '5.4' => '<='))795 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()796 ->object($test->addMethodPhpVersion('testMethod2', '5.4', '>='))->isIdenticalTo($test)797 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.3' => '>=', '5.4' => '<='), 'testMethod2' => array('5.4' => '>=')))798 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.3' => '>=', '5.4' => '<='))799 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(array('5.4' => '>='))800 ->if($test->addClassPhpVersion('5.5'))801 ->then802 ->array($test->getMethodPhpVersions())->isEqualTo(array('testMethod1' => array('5.5' => '>=', '5.3' => '>=', '5.4' => '<='), 'testMethod2' => array('5.5' => '>=', '5.4' => '>=')))803 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(array('5.5' => '>=', '5.3' => '>=', '5.4' => '<='))804 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(array('5.5' => '>=', '5.4' => '>='))805 ;806 }807 public function testRun()808 {809 $this810 ->mockTestedClass('mock\tests\units')811 ->if($test = new \mock\tests\units\test())812 ->then813 ->object($test->run())->isIdenticalTo($test)814 ->mock($test)815 ->call('callObservers')816 ->withArguments(\mageekguy\atoum\test::runStart)->never()817 ->withArguments(\mageekguy\atoum\test::runStop)->never()818 ->withArguments(\mageekguy\atoum\test::beforeSetUp)->never()819 ->withArguments(\mageekguy\atoum\test::afterSetUp)->never()820 ->withArguments(\mageekguy\atoum\test::beforeTestMethod)->never()821 ->withArguments(\mageekguy\atoum\test::afterTestMethod)->never()822 ;823 }824 public function testSetTestedClassName()825 {826 $this827 ->if($test = new foo())828 ->then829 ->string($test->getTestedClassName())->isEqualTo('mageekguy\atoum\test')830 ->exception(function() use ($test) { $test->setTestedClassName(uniqid()); })831 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')832 ->hasMessage('Tested class name is already defined')833 ->if($test = new self())834 ->then835 ->object($test->setTestedClassName($class = uniqid()))->isIdenticalTo($test)836 ->string($test->getTestedClassName())->isEqualTo($class)837 ->exception(function() use ($test) { $test->setTestedClassName(uniqid()); })838 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')839 ->hasMessage('Tested class name is already defined')840 ;841 }842 public function testMockClass()843 {844 $this845 ->if($test = new emptyTest())846 ->then847 ->object($test->mockClass(__CLASS__))->isIdenticalTo($test)848 ->class('mock\\' . __CLASS__)->isSubClassOf(__CLASS__)849 ->object($test->mockClass(__CLASS__, 'foo'))->isIdenticalTo($test)850 ->class('foo\test')->isSubClassOf(__CLASS__)851 ->object($test->mockClass(__CLASS__, 'foo\bar'))->isIdenticalTo($test)852 ->class('foo\bar\test')->isSubClassOf(__CLASS__)853 ->object($test->mockClass(__CLASS__, 'foo', 'bar'))->isIdenticalTo($test)854 ->class('foo\bar')->isSubClassOf(__CLASS__)855 ;856 }857 public function testMockTestedClass()858 {859 $this860 ->if($test = new emptyTest())861 ->and($testedClassName = $test->getTestedClassName())862 ->then863 ->object($test->mockTestedClass())->isIdenticalTo($test)864 ->class('mock\\' . $testedClassName)->isSubClassOf($testedClassName)865 ->object($test->mockTestedClass('foo'))->isIdenticalTo($test)866 ->class('foo\emptyTest')->isSubClassOf($testedClassName)867 ->object($test->mockTestedClass('foo\bar'))->isIdenticalTo($test)868 ->class('foo\bar\emptyTest')->isSubClassOf($testedClassName)869 ->object($test->mockTestedClass('foo', 'bar'))->isIdenticalTo($test)870 ->class('foo\bar')->isSubClassOf($testedClassName)871 ;872 }873 public function testGetTaggedTestMethods()874 {875 $this876 ->if($test = new emptyTest())877 ->then878 ->array($test->getTaggedTestMethods(array()))->isEmpty()879 ->array($test->getTaggedTestMethods(array(uniqid())))->isEmpty()880 ->array($test->getTaggedTestMethods(array(uniqid(), uniqid())))->isEmpty()881 ->if($test = new notEmptyTest())882 ->then883 ->array($test->getTaggedTestMethods(array()))->isEmpty()884 ->array($test->getTaggedTestMethods(array(uniqid())))->isEmpty()885 ->array($test->getTaggedTestMethods(array(uniqid(), uniqid())))->isEmpty()886 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid())))->isEmpty()887 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid(), 'testMethod2')))->isEmpty()888 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2')))->isEmpty()889 ->if($test->ignore(false))890 ->then891 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid())))->isEqualTo(array('testMethod1'))892 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod2', uniqid())))->isEqualTo(array('testMethod2'))893 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2')))->isEqualTo(array('Testmethod1', 'Testmethod2'))894 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'), array('one')))->isEqualTo(array('Testmethod1'))895 ->if($test->ignoreMethod('testMethod1', true))896 ->then897 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod1', uniqid())))->isEmpty()898 ->array($test->getTaggedTestMethods(array(uniqid(), 'testMethod2', uniqid())))->isEqualTo(array('testMethod2'))899 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2')))->isEqualTo(array('Testmethod2'))900 ->array($test->getTaggedTestMethods(array(uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'), array('one')))->isEmpty()901 ;902 }903 public function testSetDataProvider()904 {905 $this906 ->if($test = new emptyTest())907 ->then908 ->exception(function() use ($test, & $method) { $test->setDataProvider($method = uniqid(), uniqid()); })909 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')910 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')911 ->if($test = new notEmptyTest())912 ->then913 ->exception(function() use ($test, & $dataProvider) { $test->setDataProvider('testMethod1', $dataProvider = uniqid()); })914 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')915 ->hasMessage('Data provider ' . get_class($test) . '::' . $dataProvider . '() is unknown')916 ->object($test->setDataProvider('testMethod1', 'aDataProvider'))->isIdenticalTo($test)917 ->array($test->getDataProviders())->isEqualTo(array('testMethod1' => 'aDataProvider'))918 ->if($test = new dataProviderTest())919 ->then920 ->object($test->setDataProvider('testMethod2'))->isIdenticalTo($test)921 ->array($providers = $test->getDataProviders())922 ->object['testMethod2']->isInstanceOf('mageekguy\atoum\test\data\provider\aggregator')923 ->exception(function() use ($providers) { $providers['testMethod2'](); })924 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')925 ->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')926 ->if($test->getMockGenerator()->allIsInterface())927 ->then928 ->exception(function() use ($providers) { $providers['testMethod2'](); })929 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')930 ->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')931 ->if($test->getMockGenerator()->setDefaultNamespace('testMocks'))932 ->then933 ->array($providers['testMethod2']())->isEqualTo(array(array(new \testMocks\splFileInfo())))934 ->if($test = new dataProviderTest())935 ->then936 ->exception(function() use ($test, & $dataProvider) { $test->setDataProvider('testMethod3'); })937 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')938 ->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')939 ->object($test->setDataProvider('testMethod1'))->isIdenticalTo($test)940 ->array($test->getDataProviders())941 ->object['testMethod1']->isInstanceOf('mageekguy\atoum\test\data\provider\aggregator')942 ->if($test = new dataProviderTest())943 ->then944 ->exception(function() use ($test, & $dataProvider) { $test->setDataProvider('testMethod3', function() {}); })945 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')946 ->hasMessage('Cannot use a closure as a data provider for method ' . get_class($test) . '::testMethod3()')947 ;948 }949 public function testCalling()950 {951 $this952 ->if($test = new emptyTest())953 ->and($mock = new \mock\foo())954 ->and($test->calling($mock)->bar = $value = uniqid())955 ->then956 ->string($mock->bar())->isEqualTo($value)957 ->and($test->ƒ($mock)->bar = $otherValue = uniqid())958 ->then959 ->string($mock->bar())->isEqualTo($otherValue)960 ;961 }962 public function testResetMock()963 {964 $this965 ->if($test = new emptyTest())966 ->and($mockController = new \mock\mageekguy\atoum\mock\controller())967 ->and($mockController->control($mock = new \mock\object()))968 ->and($this->resetMock($mockController))969 ->then970 ->object($test->resetMock($mock))->isIdenticalTo($mock->getMockController())971 ->mock($mockController)->call('resetCalls')->once()972 ;973 }974 public function testResetFunction()975 {976 $this977 ->if($test = new emptyTest())978 ->and($this->function->md5 = uniqid())979 ->then980 ->object($test->resetFunction($this->function->md5))->isIdenticalTo($this->function->md5)981 ;982 }983 public function testResetAdapter()984 {985 $this986 ->if($test = new emptyTest())987 ->and($adapter = new \mock\mageekguy\atoum\test\adapter())988 ->and($this->resetMock($adapter))989 ->then990 ->object($test->resetAdapter($adapter))->isIdenticalTo($adapter)991 ->mock($adapter)->call('resetCalls')->once()992 ;993 }994 public function testErrorHandler()995 {996 $this997 ->if($test = new emptyTest())998 ->and($adapter = new atoum\test\adapter())999 ->and($adapter->error_reporting = 0)1000 ->and($test->setAdapter($adapter))1001 ->then1002 ->boolean($test->errorHandler(rand(1, PHP_INT_MAX), uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1003 ->array($test->getScore()->getErrors())->isEmpty()1004 ->if($adapter->error_reporting = E_ALL)1005 ->then1006 ->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1007 ->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()1008 ->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1009 ->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()1010 ->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1011 ->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()1012 ->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1013 ->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()1014 ->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1015 ->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNotNull()1016 ->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isFalse()1017 ->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNotNull()1018 ->if($adapter->error_reporting = E_ALL & ~E_DEPRECATED)1019 ->then1020 ->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1021 ->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()1022 ->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1023 ->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()1024 ->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1025 ->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()1026 ->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1027 ->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()1028 ->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1029 ->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNull()1030 ->if($adapter->error_reporting = E_ALL & ~E_RECOVERABLE_ERROR)1031 ->then1032 ->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1033 ->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNull()1034 ->if($adapter->error_reporting = 32767)1035 ->and($factory = function($class) use (& $reflection, & $filename, & $classname) {1036 $reflection = new \mock\ReflectionClass($class);1037 $reflection->getMockController()->getFilename = $filename = 'filename';1038 $reflection->getMockController()->getName = $classname = 'classname';1039 return $reflection;1040 })1041 ->and($score = new \mock\mageekguy\atoum\test\score())1042 ->and($test = new emptyTest(null, null, null, null, $factory))1043 ->and($test->setAdapter($adapter))1044 ->and($test->setScore($score))1045 ->then1046 ->boolean($test->errorHandler($errno = E_NOTICE, $errstr = 'errstr', $errfile = 'errfile', $errline = rand(1, PHP_INT_MAX)))->isTrue()1047 ->mock($score)1048 ->call('addError')->withArguments($errfile, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, $errfile, $errline, null, null, null)->once()1049 ->boolean($test->errorHandler($errno, $errstr, null, $errline = rand(1, PHP_INT_MAX)))->isTrue()1050 ->mock($score)1051 ->call('addError')->withArguments($filename, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, null, $errline, null, null, null)->once()1052 ;1053 }1054 public function testGetTestedClassNameFromTestClass()1055 {1056 $this1057 ->string(atoum\test::getTestedClassNameFromTestClass(__CLASS__))->isEqualTo('mageekguy\atoum\test')1058 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\tests\units\testedClass'))->isEqualTo('foo\bar\testedClass')1059 ->if(atoum\test::setNamespace('test\unit'))1060 ->then1061 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\test\unit\testedClass'))->isEqualTo('foo\bar\testedClass')1062 ->if(atoum\test::setNamespace('\test\unit\\'))1063 ->then1064 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\test\unit\testedClass'))->isEqualTo('foo\bar\testedClass')1065 ->if(atoum\test::setNamespace('test\unit\\'))1066 ->then1067 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\test\unit\testedClass'))->isEqualTo('foo\bar\testedClass')1068 ->if(atoum\test::setNamespace('\test\unit'))1069 ->then1070 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\test\unit\testedClass'))->isEqualTo('foo\bar\testedClass')1071 ->exception(function() { atoum\test::getTestedClassNameFromTestClass('foo\bar\aaa\bbb\testedClass'); })1072 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')1073 ->hasMessage('Test class \'foo\bar\aaa\bbb\testedClass\' is not in a namespace which contains \'' . atoum\test::getNamespace() . '\'')1074 ->if(atoum\test::setNamespace('#(?:^|\\\)xxxs?\\\yyys?\\\#i'))1075 ->then1076 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\xxx\yyy\testedClass'))->isEqualTo('foo\bar\testedClass')1077 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\xxxs\yyy\testedClass'))->isEqualTo('foo\bar\testedClass')1078 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\xxxs\yyys\testedClass'))->isEqualTo('foo\bar\testedClass')1079 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\xxx\yyys\testedClass'))->isEqualTo('foo\bar\testedClass')1080 ->exception(function() { atoum\test::getTestedClassNameFromTestClass('foo\bar\aaa\bbb\testedClass'); })1081 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')1082 ->hasMessage('Test class \'foo\bar\aaa\bbb\testedClass\' is not in a namespace which match pattern \'' . atoum\test::getNamespace() . '\'')1083 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\aaa\bbb\testedClass', '#(?:^|\\\)aaas?\\\bbbs?\\\#i'))->isEqualTo('foo\bar\testedClass')1084 ;1085 }1086 public function testAddExtension()1087 {1088 $this1089 ->if($test = new emptyTest())1090 ->then1091 ->object($test->addExtension($extension = new \mock\mageekguy\atoum\extension()))->isIdenticalTo($test)1092 ->array(iterator_to_array($test->getExtensions()))->isEqualTo(array($extension))1093 ->array($test->getObservers())->isEqualTo(array($extension))1094 ->mock($extension)1095 ->call('setTest')->withArguments($test)->once()1096 ->if($this->resetMock($extension))1097 ->then1098 ->object($test->addExtension($extension))->isIdenticalTo($test)1099 ->array(iterator_to_array($test->getExtensions()))->isEqualTo(array($extension))1100 ->array($test->getObservers())->isEqualTo(array($extension))1101 ->mock($extension)1102 ->call('setTest')->once();1103 ;1104 }1105 public function testRemoveExtension()1106 {1107 $this1108 ->if($test = new emptyTest())1109 ->then1110 ->object($test->getExtensions())->isEqualTo(new \splObjectStorage())1111 ->array($test->getObservers())->isEmpty()1112 ->object($test->removeExtension(new \mock\mageekguy\atoum\extension()))->isIdenticalTo($test)1113 ->object($test->getExtensions())->isEqualTo(new \splObjectStorage())1114 ->array($test->getObservers())->isEmpty()1115 ->if($extension = new \mock\mageekguy\atoum\extension())1116 ->and($otherExtension = new \mock\mageekguy\atoum\extension())1117 ->and($test->addExtension($extension)->addExtension($otherExtension))1118 ->then1119 ->array(iterator_to_array($test->getExtensions()))->isEqualTo(array($extension, $otherExtension))1120 ->array($test->getObservers())->isEqualTo(array($extension, $otherExtension))1121 ->object($test->removeExtension(new \mock\mageekguy\atoum\extension()))->isIdenticalTo($test)1122 ->array(iterator_to_array($test->getExtensions()))->isEqualTo(array($extension, $otherExtension))1123 ->array($test->getObservers())->isEqualTo(array($extension, $otherExtension))1124 ->object($test->removeExtension($extension))->isIdenticalTo($test)1125 ->array(iterator_to_array($test->getExtensions()))->isEqualTo(array($otherExtension))1126 ->array($test->getObservers())->isEqualTo(array($otherExtension))1127 ->object($test->removeExtension($otherExtension))->isIdenticalTo($test)1128 ->object($test->getExtensions())->isEqualTo(new \splObjectStorage())1129 ->array($test->getObservers())->isEmpty()1130 ;1131 }1132 public function testRemoveExtensions()1133 {1134 $this1135 ->if($test = new emptyTest())1136 ->then1137 ->object($test->getExtensions())->isEqualTo(new \splObjectStorage())1138 ->array($test->getObservers())->isEmpty()1139 ->object($test->removeExtensions())->isIdenticalTo($test)1140 ->object($test->getExtensions())->isEqualTo(new \splObjectStorage())1141 ->array($test->getObservers())->isEmpty()1142 ->if($extension = new \mock\mageekguy\atoum\extension())1143 ->and($otherExtension = new \mock\mageekguy\atoum\extension())1144 ->and($test->addExtension($extension)->addExtension($otherExtension))1145 ->then1146 ->array(iterator_to_array($test->getExtensions()))->isEqualTo(array($extension, $otherExtension))1147 ->array($test->getObservers())->isEqualTo(array($extension, $otherExtension))1148 ->object($test->removeExtensions())->isIdenticalTo($test)1149 ->object($test->getExtensions())->isEqualTo(new \splObjectStorage())1150 ->array($test->getObservers())->isEmpty()1151 ;1152 }1153 public function testGetExtensionConfiguration()1154 {1155 $this1156 ->if(1157 $test = new emptyTest(),1158 $extension = new \mock\mageekguy\atoum\extension()1159 )1160 ->then1161 ->variable($test->getExtensionConfiguration($extension))->isNull1162 ->if($test->addExtension($extension))1163 ->then1164 ->variable($test->getExtensionConfiguration($extension))->isNull1165 ->given($configuration = new \mock\mageekguy\atoum\extension\configuration())1166 ->if($test->addExtension($extension, $configuration))1167 ->then1168 ->object($test->getExtensionConfiguration($extension))->isIdenticalTo($configuration)1169 ;1170 }1171 public function testCallStaticOnTestedClass()1172 {1173 $this1174 ->if($test = new withStatic())1175 ->then1176 ->string($test->callStaticOnTestedClass('staticMethod', $return = uniqid()))1177 ->isEqualTo($return)1178 ->array($test->callStaticOnTestedClass(1179 'someOtherStaticMethod',1180 $return1 = uniqid(),1181 $return2 = uniqid(),1182 $return3 = uniqid()1183 ))1184 ->isEqualTo(array($return1, $return2, $return3))1185 ;1186 }1187 public function testNewMockInstance()1188 {1189 $this1190 ->if($test = new emptyTest())1191 ->then1192 ->object($mock = $test->newMockInstance('stdClass'))1193 ->isInstanceOf('mock\stdClass')1194 ->isInstanceOf('stdClass')1195 ->object($test->newMockInstance('stdClass'))1196 ->isInstanceOf('mock\stdClass')1197 ->isInstanceOf('stdClass')1198 ->isNotIdenticalTo($mock)1199 ->object($test->newMockInstance('stdClass', 'foobar'))1200 ->isInstanceOf('foobar\stdClass')1201 ->isInstanceOf('stdClass')1202 ->object($test->newMockInstance('stdClass', 'foo', 'bar'))1203 ->isInstanceOf('foo\bar')1204 ->isInstanceOf('stdClass')1205 ->given($arguments = array($firstArgument = uniqid(), $secondArgument = rand(0, PHP_INT_MAX)))1206 ->then1207 ->object($mock = $test->newMockInstance('mageekguy\atoum\dummy', null, null, $arguments))1208 ->isInstanceOf('mock\mageekguy\atoum\dummy')1209 ->isInstanceOf('mageekguy\atoum\dummy')1210 ->mock($mock)1211 ->call('__construct')->withArguments($firstArgument, $secondArgument)->once1212 ->given($arguments = array(uniqid(), rand(0, PHP_INT_MAX), $controller = new mock\controller()))1213 ->then1214 ->object($mock = $test->newMockInstance('mageekguy\atoum\dummy', null, null, $arguments))1215 ->isInstanceOf('mock\mageekguy\atoum\dummy')1216 ->isInstanceOf('mageekguy\atoum\dummy')1217 ->object($mock->getMockController())->isIdenticalTo($controller)1218 ->given(1219 $arguments = array(uniqid(), rand(0, PHP_INT_MAX)),1220 $controller = new mock\controller()1221 )1222 ->then1223 ->object($mock = $test->newMockInstance('mageekguy\atoum\dummy', null, null, $arguments))1224 ->isInstanceOf('mock\mageekguy\atoum\dummy')1225 ->isInstanceOf('mageekguy\atoum\dummy')...

Full Screen

Full Screen

__construct

Using AI Code Generation

copy

Full Screen

1$obj = new emptyTest;2$obj->test();3$obj = new emptyTest;4$obj->test();5$obj = new emptyTest;6$obj->test();7$obj = new emptyTest;8$obj->test();9$obj = new emptyTest;10$obj->test();11$obj = new emptyTest;12$obj->test();13$obj = new emptyTest;14$obj->test();15$obj = new emptyTest;16$obj->test();17$obj = new emptyTest;18$obj->test();19$obj = new emptyTest;20$obj->test();21$obj = new emptyTest;22$obj->test();23$obj = new emptyTest;24$obj->test();25$obj = new emptyTest;26$obj->test();27$obj = new emptyTest;28$obj->test();29$obj = new emptyTest;30$obj->test();31$obj = new emptyTest;32$obj->test();33$obj = new emptyTest;34$obj->test();

Full Screen

Full Screen

__construct

Using AI Code Generation

copy

Full Screen

1$test = new emptyTest();2$test->test();3$test = new emptyTest();4$test->test();5$test = new emptyTest();6$test->test();7$test = new emptyTest();8$test->test();9$test = new emptyTest();10$test->test();11$test = new emptyTest();12$test->test();13$test = new emptyTest();14$test->test();15$test = new emptyTest();16$test->test();17$test = new emptyTest();18$test->test();19$test = new emptyTest();20$test->test();21$test = new emptyTest();22$test->test();23$test = new emptyTest();24$test->test();25$test = new emptyTest();26$test->test();27$test = new emptyTest();28$test->test();29$test = new emptyTest();30$test->test();31$test = new emptyTest();32$test->test();

Full Screen

Full Screen

__construct

Using AI Code Generation

copy

Full Screen

1$obj = new emptyTest();2$obj->hello();3$obj = new emptyTest();4$obj->hello();5$obj = new emptyTest();6$obj->hello();7$obj = new emptyTest();8$obj->hello();9$obj = new emptyTest();10$obj->hello();11$obj = new emptyTest();12$obj->hello();13$obj = new emptyTest();14$obj->hello();15$obj = new emptyTest();16$obj->hello();17$obj = new emptyTest();18$obj->hello();19$obj = new emptyTest();20$obj->hello();21$obj = new emptyTest();22$obj->hello();23$obj = new emptyTest();24$obj->hello();25$obj = new emptyTest();26$obj->hello();27$obj = new emptyTest();28$obj->hello();29$obj = new emptyTest();30$obj->hello();31$obj = new emptyTest();32$obj->hello();33$obj = new emptyTest();34$obj->hello();

Full Screen

Full Screen

__construct

Using AI Code Generation

copy

Full Screen

1$test = new emptyTest();2echo $test->emptyTest();3$test = new emptyTest();4echo $test->emptyTest();5$test = new emptyTest();6echo $test->emptyTest();7How to use __construct() method in PHP?8How to use __destruct() method in PHP?9How to use __call() method in PHP?10How to use __callStatic() method in PHP?11How to use __get() method in PHP?12How to use __set() method in PHP?13How to use __isset() method in PHP?14How to use __unset() method in PHP?15How to use __sleep() method in PHP?16How to use __wakeup() method in PHP?17How to use __toString() method in PHP?18How to use __invoke() method in PHP?19How to use __set_state() method in PHP?20How to use __debugInfo() method in PHP?21How to use __clone() method in PHP?

Full Screen

Full Screen

__construct

Using AI Code Generation

copy

Full Screen

1$obj = new emptyTest();2if(empty($obj)){3 echo "Object is empty";4}else{5 echo "Object is not empty";6}7$obj = new emptyTest();8if(empty($obj)){9 echo "Object is empty";10}else{11 echo "Object is not empty";12}13Recommended Posts: PHP | empty() Function14PHP | is_null() Function15PHP | is_string() Function16PHP | is_array() Function17PHP | is_numeric() Function18PHP | is_int() Function19PHP | is_float() Function20PHP | is_bool() Function21PHP | is_double() Function22PHP | is_real() Function23PHP | is_long() Function24PHP | is_resource() Function25PHP | is_scalar() Function26PHP | is_object() Function27PHP | is_callable() Function28PHP | is_iterable() Function29PHP | is_countable() Function30PHP | is_subclass_of() Function31PHP | is_a() Function32PHP | get_class() Function33PHP | get_parent_class() Function34PHP | get_class_methods() Function35PHP | get_class_vars() Function36PHP | get_declared_classes() Function37PHP | get_declared_interfaces() Function38PHP | get_declared_traits() Function39PHP | get_object_vars() Function40PHP | gettype() Function41PHP | get_resource_type() Function42PHP | get_resource_id() Function43PHP | get_defined_functions() Function44PHP | get_defined_vars() Function

Full Screen

Full Screen

__construct

Using AI Code Generation

copy

Full Screen

1$test = new emptyTest();2$test->test();3How to check if an array is empty in PHP using count() ?4How to check if a variable is empty or not in PHP using isset() ?5How to check if a directory is empty or not in PHP using count() ?6How to check if a string is empty or not in PHP using empty() ?7How to check if a file is empty or not in PHP using filesize() ?8How to check if a string is empty or not in PHP using isset() ?9How to check if a file is empty or not in PHP using empty() ?10How to check if a directory is empty or not in PHP using empty() ?11How to check if an array is empty or not in PHP using empty() ?12How to check if a string is empty or not in PHP using count() ?13How to check if a file is empty or not in PHP using count() ?14How to check if a directory is empty or not in PHP using isset() ?15How to check if an array is empty or not in PHP using isset() ?16How to check if a string is empty or not in PHP using filesize() ?17How to check if a file is empty or not in PHP using isset() ?18How to check if a directory is empty or not in PHP using filesize() ?19How to check if an array is empty or not in PHP using count() ?20How to check if a string is empty or not in PHP using isset() ?21How to check if a file is empty or not in PHP using count() ?22How to check if a directory is empty or not in PHP using empty() ?23How to check if an array is empty or not in PHP using filesize() ?

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger __construct code on LambdaTest Cloud Grid

Execute automation tests with __construct on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful