How to use testGetTestedClassName method of withStatic class

Best Atoum code snippet using withStatic.testGetTestedClassName

test.php

Source:test.php Github

copy

Full Screen

...499 ->then500 ->string($test->getTestMethodPrefix())->isEqualTo($testMethodPrefix)501 ;502 }503 public function testGetTestedClassName()504 {505 $mockClass = '\mock\\' . __CLASS__;506 $this507 ->if($test = new $mockClass())508 ->and($test->getMockController()->getClass = $testClass = 'foo')509 ->then510 ->exception(function () use ($test) {511 $test->getTestedClassName();512 })513 ->isInstanceOf(atoum\exceptions\runtime::class)514 ->hasMessage('Test class \'' . $testClass . '\' is not in a namespace which matches pattern \'' . $test->getTestNamespace() . '\'')515 ->if($test->getMockController()->getClass = 'tests\units\foo')516 ->then517 ->string($test->getTestedClassName())->isEqualTo('foo')518 ;519 }520 public function testGetTestedClassPath()521 {522 $this523 ->if($testedClass = new \reflectionClass($this->getTestedClassName()))524 ->then525 ->string($this->getTestedClassPath())->isEqualTo($testedClass->getFilename())526 ;527 }528 public function testGetAdapter()529 {530 $this531 ->if($test = new emptyTest())532 ->then533 ->object($test->getAdapter())->isInstanceOf(atoum\adapter::class)534 ;535 }536 public function testSetAdapter()537 {538 $this539 ->if($test = new emptyTest())540 ->then541 ->object($test->setAdapter($adapter = new atoum\test\adapter()))->isIdenticalTo($test)542 ->object($test->getAdapter())->isIdenticalTo($adapter)543 ;544 }545 public function testSetLocale()546 {547 $this548 ->if($test = new emptyTest())549 ->then550 ->object($test->setLocale($locale = new atoum\locale()))->isIdenticalTo($test)551 ->object($test->getLocale())->isIdenticalTo($locale)552 ;553 }554 public function testSetScore()555 {556 $this557 ->if($test = new emptyTest())558 ->then559 ->object($test->setScore($score = new atoum\test\score()))->isIdenticalTo($test)560 ->object($test->getScore())->isIdenticalTo($score)561 ;562 }563 public function testSetBootstrapFile()564 {565 $this566 ->if($test = new emptyTest())567 ->then568 ->object($test->setBootstrapFile($path = uniqid()))->isIdenticalTo($test)569 ->string($test->getBootstrapFile())->isEqualTo($path)570 ;571 }572 public function testSetMaxChildrenNumber()573 {574 $this575 ->if($test = new emptyTest())576 ->then577 ->exception(function () use ($test) {578 $test->setMaxChildrenNumber(- rand(1, PHP_INT_MAX));579 })580 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)581 ->hasMessage('Maximum number of children must be greater or equal to 1')582 ->exception(function () use ($test) {583 $test->setMaxChildrenNumber(0);584 })585 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)586 ->hasMessage('Maximum number of children must be greater or equal to 1')587 ->object($test->setMaxChildrenNumber($maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)588 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)589 ->object($test->setMaxChildrenNumber((string) $maxChildrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)590 ->integer($test->getMaxChildrenNumber())->isEqualTo($maxChildrenNumber)591 ;592 }593 public function testGetClass()594 {595 $this596 ->if($test = new emptyTest())597 ->then598 ->string($test->getClass())->isEqualTo(__NAMESPACE__ . '\emptyTest')599 ;600 }601 public function testGetPath()602 {603 $this604 ->if($test = new emptyTest())605 ->then606 ->string($test->getPath())->isEqualTo(__FILE__)607 ;608 }609 public function testGetCoverage()610 {611 $this612 ->if($test = new emptyTest())613 ->then614 ->object($test->getCoverage())->isIdenticalTo($test->getScore()->getCoverage())615 ;616 }617 public function testIsIgnored()618 {619 $this620 ->if($test = new emptyTest())621 ->then622 ->boolean($test->isIgnored())->isTrue()623 ->object($test->ignore(false))->isIdenticalTo($test)624 ->boolean($test->isIgnored())->isTrue()625 ->object($test->ignore(true))->isIdenticalTo($test)626 ->boolean($test->isIgnored())->isTrue()627 ->if($test = new notEmptyTest())628 ->then629 ->boolean($test->isIgnored())->isTrue()630 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()631 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()632 ->object($test->ignore(false))->isIdenticalTo($test)633 ->boolean($test->isIgnored())->isFalse()634 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()635 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()636 ->object($test->ignore(true))->isIdenticalTo($test)637 ->boolean($test->isIgnored())->isTrue()638 ->boolean($test->methodIsIgnored('testMethod1'))->istrue()639 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()640 ;641 }642 public function testGetCurrentMethod()643 {644 $this645 ->if($test = new emptyTest())646 ->then647 ->variable($test->getCurrentMethod())->isNull()648 ;649 }650 public function testCount()651 {652 $this653 ->sizeOf(new emptyTest())->isEqualTo(0)654 ->if($test = new notEmptyTest())655 ->then656 ->sizeOf($test)->isEqualTo(0)657 ->if($test->ignore(false))658 ->then659 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()660 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()661 ->sizeOf($test)->isEqualTo(2)662 ->if($test->ignoreMethod('testMethod1', true))663 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()664 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()665 ->sizeOf($test)->isEqualTo(1)666 ->if($test->ignoreMethod('testMethod2', true))667 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()668 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()669 ->sizeOf($test)->isEqualTo(0)670 ;671 }672 public function testGetTestMethods()673 {674 $this675 ->if($test = new emptyTest())676 ->then677 ->boolean($test->ignore(false)->isIgnored())->isTrue()678 ->sizeOf($test)->isZero()679 ->array($test->getTestMethods())->isEmpty()680 ->if($test = new notEmptyTest())681 ->then682 ->boolean($test->isIgnored())->isTrue()683 ->boolean($test->methodIsIgnored('testMethod1'))->isTrue()684 ->boolean($test->methodIsIgnored('testMethod2'))->isTrue()685 ->sizeOf($test)->isEqualTo(0)686 ->array($test->getTestMethods())->isEmpty()687 ->boolean($test->ignore(false)->isIgnored())->isFalse()688 ->boolean($test->methodIsIgnored('testMethod1'))->isFalse()689 ->boolean($test->methodIsIgnored('testMethod2'))->isFalse()690 ->sizeOf($test)->isEqualTo(2)691 ->array($test->getTestMethods())->isEqualTo(['testMethod1', 'testMethod2'])692 ->array($test->getTestMethods(['method']))->isEqualTo(['testMethod1', 'testMethod2'])693 ->array($test->getTestMethods(['test']))->isEqualTo(['testMethod1', 'testMethod2'])694 ->array($test->getTestMethods(['two']))->isEqualTo(['testMethod2'])695 ->array($test->getTestMethods([uniqid()]))->isEmpty()696 ->array($test->getTestMethods(['test', 'method']))->isEqualTo(['testMethod1', 'testMethod2'])697 ->array($test->getTestMethods(['test', 'method', uniqid()]))->isEqualTo(['testMethod1', 'testMethod2'])698 ->array($test->getTestMethods(['test', 'method', 'two', uniqid()]))->isEqualTo(['testMethod1', 'testMethod2'])699 ;700 }701 public function testGetPhpPath()702 {703 $this704 ->if($test = new emptyTest())705 ->then706 ->variable($test->getPhpPath())->isNull()707 ->if($test->setPhpPath($phpPath = uniqid()))708 ->then709 ->string($test->getPhpPath())->isEqualTo($phpPath)710 ;711 }712 public function testSetPhpPath()713 {714 $this715 ->if($test = new emptyTest())716 ->then717 ->object($test->setPhpPath($phpPath = uniqid()))->isIdenticalTo($test)718 ->string($test->getPhpPath())->isIdenticalTo($phpPath)719 ->object($test->setPhpPath($phpPath = rand(1, PHP_INT_MAX)))->isIdenticalTo($test)720 ->string($test->getPhpPath())->isIdenticalTo((string) $phpPath)721 ;722 }723 public function testMethodIsIgnored()724 {725 $this726 ->if($test = new emptyTest())727 ->then728 ->exception(function () use ($test, & $method) {729 $test->methodIsIgnored($method = uniqid());730 })731 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)732 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')733 ;734 }735 public function testSetTags()736 {737 $this738 ->if($test = new emptyTest())739 ->then740 ->object($test->setTags($tags = [uniqid(), uniqid()]))->isIdenticalTo($test)741 ->array($test->getTags())->isEqualTo($tags)742 ;743 }744 public function testSetMethodTags()745 {746 $this747 ->if($test = new notEmptyTest())748 ->then749 ->object($test->setMethodTags('testMethod1', $tags = [uniqid(), uniqid()]))->isIdenticalTo($test)750 ->array($test->getMethodTags('testMethod1'))->isEqualTo($tags)751 ->exception(function () use ($test, & $method) {752 $test->setMethodTags($method = uniqid(), []);753 })754 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)755 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')756 ;757 }758 public function testGetMethodTags()759 {760 $this761 ->if($test = new notEmptyTest())762 ->then763 ->array($test->getMethodTags('testMethod1'))->isEqualTo(['test', 'method', 'one'])764 ->exception(function () use ($test, & $method) {765 $test->getMethodTags($method = uniqid());766 })767 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)768 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')769 ->if($test = new inheritedTagsTest())770 ->then771 ->array($test->getMethodTags())->isEqualTo(['testMethod1' => ['first', 'second', 'third'], 'testMethod2' => ['first', 'second', 'third']])772 ->array($test->getMethodTags('testMethod1'))->isEqualTo(['first', 'second', 'third'])773 ->array($test->getMethodTags('testMethod2'))->isEqualTo(['first', 'second', 'third'])774 ->if($test = new dataProviderTest())775 ->then776 ->array($test->getMethodTags())->isEqualTo(['testMethod1' => [], 'testMethod2' => [], 'testMethod3' => []])777 ->array($test->getMethodTags('testMethod1'))->isEqualTo([])778 ->array($test->getMethodTags('testMethod2'))->isEqualTo([])779 ->array($test->getMethodTags('testMethod3'))->isEqualTo([])780 ;781 }782 public function testAddMandatoryClassExtension()783 {784 $this785 ->if($test = new notEmptyTest())786 ->then787 ->object($test->addMandatoryClassExtension($extension = uniqid()))->isIdenticalTo($test)788 ->array($test->getMandatoryClassExtensions())->isEqualTo([$extension])789 ->object($test->addMandatoryClassExtension($otherExtension = uniqid()))->isIdenticalTo($test)790 ->array($test->getMandatoryClassExtensions())->isEqualTo([$extension, $otherExtension])791 ;792 }793 public function testGetMandatoryMethodExtensions()794 {795 $this796 ->if($test = new notEmptyTest())797 ->then798 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEmpty()799 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket'])800 ;801 }802 public function testAddMandatoryMethodExtension()803 {804 $this805 ->if($test = new notEmptyTest())806 ->then807 ->exception(function () use ($test, & $method) {808 $test->addMandatoryMethodExtension($method = uniqid(), uniqid());809 })810 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)811 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')812 ->object($test->addMandatoryMethodExtension('testMethod1', $extension = uniqid()))->isIdenticalTo($test)813 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$extension], 'testMethod2' => ['mbstring', 'socket']])814 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$extension])815 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket'])816 ->object($test->addMandatoryMethodExtension('testMethod1', $otherExtension = uniqid()))->isIdenticalTo($test)817 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$extension, $otherExtension], 'testMethod2' => ['mbstring', 'socket']])818 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$extension, $otherExtension])819 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket'])820 ->object($test->addMandatoryMethodExtension('testMethod2', $anOtherExtension = uniqid()))->isIdenticalTo($test)821 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$extension, $otherExtension], 'testMethod2' => ['mbstring', 'socket', $anOtherExtension]])822 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$extension, $otherExtension])823 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo(['mbstring', 'socket', $anOtherExtension])824 ->if($test->addMandatoryClassExtension($classExtension = uniqid()))825 ->then826 ->array($test->getMandatoryMethodExtensions())->isEqualTo(['testMethod1' => [$classExtension, $extension, $otherExtension], 'testMethod2' => [$classExtension, 'mbstring', 'socket', $anOtherExtension]])827 ->array($test->getMandatoryMethodExtensions('testMethod1'))->isEqualTo([$classExtension, $extension, $otherExtension])828 ->array($test->getMandatoryMethodExtensions('testMethod2'))->isEqualTo([$classExtension, 'mbstring', 'socket', $anOtherExtension])829 ;830 }831 public function testAddClassPhpVersion()832 {833 $this834 ->if($test = new notEmptyTest())835 ->then836 ->object($test->addClassPhpVersion('5.3'))->isIdenticalTo($test)837 ->array($test->getClassPhpVersions())->isEqualTo(['5.3' => '>='])838 ->object($test->addClassPhpVersion('5.4', '<='))->isIdenticalTo($test)839 ->array($test->getClassPhpVersions())->isEqualTo(['5.3' => '>=', '5.4' => '<='])840 ;841 }842 public function testAddMethodPhpVersion()843 {844 $this845 ->if($test = new notEmptyTest())846 ->then847 ->exception(function () use ($test, & $method) {848 $test->addMethodPhpVersion($method, '6.0');849 })850 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)851 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')852 ->object($test->addMethodPhpVersion('testMethod1', '5.3'))->isIdenticalTo($test)853 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.3' => '>='], 'testMethod2' => []])854 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.3' => '>='])855 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()856 ->object($test->addMethodPhpVersion('testMethod1', '5.4', '<='))->isIdenticalTo($test)857 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.3' => '>=', '5.4' => '<='], 'testMethod2' => []])858 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.3' => '>=', '5.4' => '<='])859 ->array($test->getMethodPhpVersions('testMethod2'))->isEmpty()860 ->object($test->addMethodPhpVersion('testMethod2', '5.4', '>='))->isIdenticalTo($test)861 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.3' => '>=', '5.4' => '<='], 'testMethod2' => ['5.4' => '>=']])862 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.3' => '>=', '5.4' => '<='])863 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(['5.4' => '>='])864 ->if($test->addClassPhpVersion('5.5'))865 ->then866 ->array($test->getMethodPhpVersions())->isEqualTo(['testMethod1' => ['5.5' => '>=', '5.3' => '>=', '5.4' => '<='], 'testMethod2' => ['5.5' => '>=', '5.4' => '>=']])867 ->array($test->getMethodPhpVersions('testMethod1'))->isEqualTo(['5.5' => '>=', '5.3' => '>=', '5.4' => '<='])868 ->array($test->getMethodPhpVersions('testMethod2'))->isEqualTo(['5.5' => '>=', '5.4' => '>='])869 ;870 }871 public function testRun()872 {873 $this874 ->mockTestedClass('mock\tests\units')875 ->if($test = new \mock\tests\units\test())876 ->then877 ->object($test->run())->isIdenticalTo($test)878 ->mock($test)879 ->call('callObservers')880 ->withArguments(\atoum\atoum\test::runStart)->never()881 ->withArguments(\atoum\atoum\test::runStop)->never()882 ->withArguments(\atoum\atoum\test::beforeSetUp)->never()883 ->withArguments(\atoum\atoum\test::afterSetUp)->never()884 ->withArguments(\atoum\atoum\test::beforeTestMethod)->never()885 ->withArguments(\atoum\atoum\test::afterTestMethod)->never()886 ;887 }888 public function testSetTestedClassName()889 {890 $this891 ->if($test = new foo())892 ->then893 ->string($test->getTestedClassName())->isEqualTo('atoum\atoum\test')894 ->exception(function () use ($test) {895 $test->setTestedClassName(uniqid());896 })897 ->isInstanceOf(atoum\exceptions\runtime::class)898 ->hasMessage('Tested class name is already defined')899 ->if($test = new self())900 ->then901 ->object($test->setTestedClassName($class = uniqid()))->isIdenticalTo($test)902 ->string($test->getTestedClassName())->isEqualTo($class)903 ->exception(function () use ($test) {904 $test->setTestedClassName(uniqid());905 })906 ->isInstanceOf(atoum\exceptions\runtime::class)907 ->hasMessage('Tested class name is already defined')908 ;909 }910 public function testMockClass()911 {912 $this913 ->if($test = new emptyTest())914 ->then915 ->object($test->mockClass(__CLASS__))->isIdenticalTo($test)916 ->class('mock\\' . __CLASS__)->isSubClassOf(__CLASS__)917 ->object($test->mockClass(__CLASS__, 'foo'))->isIdenticalTo($test)918 ->class('foo\test')->isSubClassOf(__CLASS__)919 ->object($test->mockClass(__CLASS__, 'foo\bar'))->isIdenticalTo($test)920 ->class('foo\bar\test')->isSubClassOf(__CLASS__)921 ->object($test->mockClass(__CLASS__, 'foo', 'bar'))->isIdenticalTo($test)922 ->class('foo\bar')->isSubClassOf(__CLASS__)923 ;924 }925 public function testMockTestedClass()926 {927 $this928 ->if($test = new emptyTest())929 ->and($testedClassName = $test->getTestedClassName())930 ->then931 ->object($test->mockTestedClass())->isIdenticalTo($test)932 ->class('mock\\' . $testedClassName)->isSubClassOf($testedClassName)933 ->object($test->mockTestedClass('foo'))->isIdenticalTo($test)934 ->class('foo\emptyTest')->isSubClassOf($testedClassName)935 ->object($test->mockTestedClass('foo\bar'))->isIdenticalTo($test)936 ->class('foo\bar\emptyTest')->isSubClassOf($testedClassName)937 ->object($test->mockTestedClass('foo', 'bar'))->isIdenticalTo($test)938 ->class('foo\bar')->isSubClassOf($testedClassName)939 ;940 }941 public function testGetTaggedTestMethods()942 {943 $this944 ->if($test = new emptyTest())945 ->then946 ->array($test->getTaggedTestMethods([]))->isEmpty()947 ->array($test->getTaggedTestMethods([uniqid()]))->isEmpty()948 ->array($test->getTaggedTestMethods([uniqid(), uniqid()]))->isEmpty()949 ->if($test = new notEmptyTest())950 ->then951 ->array($test->getTaggedTestMethods([]))->isEmpty()952 ->array($test->getTaggedTestMethods([uniqid()]))->isEmpty()953 ->array($test->getTaggedTestMethods([uniqid(), uniqid()]))->isEmpty()954 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid()]))->isEmpty()955 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid(), 'testMethod2']))->isEmpty()956 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2']))->isEmpty()957 ->if($test->ignore(false))958 ->then959 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid()]))->isEqualTo(['testMethod1'])960 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod2', uniqid()]))->isEqualTo(['testMethod2'])961 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2']))->isEqualTo(['Testmethod1', 'Testmethod2'])962 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'], ['one']))->isEqualTo(['Testmethod1'])963 ->if($test->ignoreMethod('testMethod1', true))964 ->then965 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod1', uniqid()]))->isEmpty()966 ->array($test->getTaggedTestMethods([uniqid(), 'testMethod2', uniqid()]))->isEqualTo(['testMethod2'])967 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2']))->isEqualTo(['Testmethod2'])968 ->array($test->getTaggedTestMethods([uniqid(), 'Testmethod1', uniqid(), 'Testmethod2'], ['one']))->isEmpty()969 ;970 }971 public function testSetDataProvider()972 {973 $this974 ->if($test = new emptyTest())975 ->then976 ->exception(function () use ($test, & $method) {977 $test->setDataProvider($method = uniqid(), uniqid());978 })979 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)980 ->hasMessage('Test method ' . get_class($test) . '::' . $method . '() does not exist')981 ->if($test = new notEmptyTest())982 ->then983 ->exception(function () use ($test, & $dataProvider) {984 $test->setDataProvider('testMethod1', $dataProvider = uniqid());985 })986 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)987 ->hasMessage('Data provider ' . get_class($test) . '::' . $dataProvider . '() is unknown')988 ->object($test->setDataProvider('testMethod1', 'aDataProvider'))->isIdenticalTo($test)989 ->array($test->getDataProviders())->isEqualTo(['testMethod1' => 'aDataProvider'])990 ->if($test = new dataProviderTest())991 ->then992 ->object($test->setDataProvider('testMethod2'))->isIdenticalTo($test)993 ->array($providers = $test->getDataProviders())994 ->object['testMethod2']->isInstanceOf(atoum\test\data\provider\aggregator::class)995 ->exception(function () use ($providers) {996 $providers['testMethod2']();997 })998 ->isInstanceOf(atoum\exceptions\runtime::class)999 ->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')1000 ->if($test->getMockGenerator()->allIsInterface())1001 ->then1002 ->exception(function () use ($providers) {1003 $providers['testMethod2']();1004 })1005 ->isInstanceOf(atoum\exceptions\runtime::class)1006 ->hasMessage('Could not instanciate a mock from ' . $test->getMockGenerator()->getDefaultNamespace() . '\\SplFileInfo because SplFileInfo::__construct() has at least one mandatory argument')1007 ->if($test->getMockGenerator()->setDefaultNamespace('testMocks'))1008 ->then1009 ->array($providers['testMethod2']())->isEqualTo([[new \testMocks\SplFileInfo()]])1010 ->if($test = new dataProviderTest())1011 ->then1012 ->exception(function () use ($test, & $dataProvider) {1013 $test->setDataProvider('testMethod3');1014 })1015 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)1016 ->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')1017 ->object($test->setDataProvider('testMethod1'))->isIdenticalTo($test)1018 ->array($test->getDataProviders())1019 ->object['testMethod1']->isInstanceOf(atoum\test\data\provider\aggregator::class)1020 ->if($test = new dataProviderTest())1021 ->then1022 ->exception(function () use ($test, & $dataProvider) {1023 $test->setDataProvider('testMethod3', function () {1024 });1025 })1026 ->isInstanceOf(atoum\exceptions\logic\invalidArgument::class)1027 ->hasMessage('Cannot use a closure as a data provider for method ' . get_class($test) . '::testMethod3()')1028 ;1029 }1030 public function testCalling()1031 {1032 $this1033 ->if($test = new emptyTest())1034 ->and($mock = new \mock\foo())1035 ->and($test->calling($mock)->bar = $value = uniqid())1036 ->then1037 ->string($mock->bar())->isEqualTo($value)1038 ->and($test->ƒ($mock)->bar = $otherValue = uniqid())1039 ->then1040 ->string($mock->bar())->isEqualTo($otherValue)1041 ;1042 }1043 public function testResetMock()1044 {1045 $this1046 ->if($test = new emptyTest())1047 ->and($mockController = new \mock\atoum\atoum\mock\controller())1048 ->and($mockController->control($mock = new \mock\phpObject()))1049 ->and($this->resetMock($mockController))1050 ->then1051 ->object($test->resetMock($mock))->isIdenticalTo($mock->getMockController())1052 ->mock($mockController)->call('resetCalls')->once()1053 ;1054 }1055 public function testResetFunction()1056 {1057 $this1058 ->if($test = new emptyTest())1059 ->and($this->function->md5 = uniqid())1060 ->then1061 ->object($test->resetFunction($this->function->md5))->isIdenticalTo($this->function->md5)1062 ;1063 }1064 public function testResetAdapter()1065 {1066 $this1067 ->if($test = new emptyTest())1068 ->and($adapter = new \mock\atoum\atoum\test\adapter())1069 ->and($this->resetMock($adapter))1070 ->then1071 ->object($test->resetAdapter($adapter))->isIdenticalTo($adapter)1072 ->mock($adapter)->call('resetCalls')->once()1073 ;1074 }1075 public function testErrorHandler()1076 {1077 $this1078 ->if($test = new emptyTest())1079 ->and($adapter = new atoum\test\adapter())1080 ->and($adapter->error_reporting = 0)1081 ->and($test->setAdapter($adapter))1082 ->then1083 ->boolean($test->errorHandler(rand(1, PHP_INT_MAX), uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1084 ->array($test->getScore()->getErrors())->isEmpty()1085 ->if($adapter->error_reporting = E_ALL)1086 ->then1087 ->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1088 ->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()1089 ->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1090 ->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()1091 ->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1092 ->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()1093 ->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1094 ->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()1095 ->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1096 ->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNotNull()1097 ->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isFalse()1098 ->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNotNull()1099 ->if($adapter->error_reporting = E_ALL & ~E_DEPRECATED)1100 ->then1101 ->boolean($test->errorHandler(E_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1102 ->variable($test->getScore()->errorExists($errstr, E_NOTICE))->isNotNull()1103 ->boolean($test->errorHandler(E_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1104 ->variable($test->getScore()->errorExists($errstr, E_WARNING))->isNotNull()1105 ->boolean($test->errorHandler(E_USER_NOTICE, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1106 ->variable($test->getScore()->errorExists($errstr, E_USER_NOTICE))->isNotNull()1107 ->boolean($test->errorHandler(E_USER_WARNING, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1108 ->variable($test->getScore()->errorExists($errstr, E_USER_WARNING))->isNotNull()1109 ->boolean($test->errorHandler(E_DEPRECATED, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1110 ->variable($test->getScore()->errorExists($errstr, E_DEPRECATED))->isNull()1111 ->if($adapter->error_reporting = E_ALL & ~E_RECOVERABLE_ERROR)1112 ->then1113 ->boolean($test->errorHandler(E_RECOVERABLE_ERROR, $errstr = uniqid(), uniqid(), rand(1, PHP_INT_MAX), uniqid()))->isTrue()1114 ->variable($test->getScore()->errorExists($errstr, E_RECOVERABLE_ERROR))->isNull()1115 ->if($adapter->error_reporting = 32767)1116 ->and($factory = function ($class) use (& $reflection, & $filename, & $classname) {1117 $reflection = new \mock\ReflectionClass($class);1118 $reflection->getMockController()->getFilename = $filename = 'filename';1119 $reflection->getMockController()->getName = $classname = 'classname';1120 return $reflection;1121 })1122 ->and($score = new \mock\atoum\atoum\test\score())1123 ->and($test = new emptyTest(null, null, null, null, $factory))1124 ->and($test->setAdapter($adapter))1125 ->and($test->setScore($score))1126 ->then1127 ->boolean($test->errorHandler($errno = E_NOTICE, $errstr = 'errstr', $errfile = 'errfile', $errline = rand(1, PHP_INT_MAX)))->isTrue()1128 ->mock($score)1129 ->call('addError')->withArguments($errfile, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, $errfile, $errline, null, null, null)->once()1130 ->boolean($test->errorHandler($errno, $errstr, null, $errline = rand(1, PHP_INT_MAX)))->isTrue()1131 ->mock($score)1132 ->call('addError')->withArguments($filename, $classname, $test->getCurrentMethod(), $errline, $errno, $errstr, null, $errline, null, null, null)->once()1133 ;1134 }1135 public function testGetTestedClassNameFromTestClass()1136 {1137 $this1138 ->string(atoum\test::getTestedClassNameFromTestClass(__CLASS__))->isEqualTo('atoum\atoum\test')1139 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\tests\units\testedClass'))->isEqualTo('foo\bar\testedClass')1140 ->if(atoum\test::setNamespace('test\unit'))1141 ->then1142 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\test\unit\testedClass'))->isEqualTo('foo\bar\testedClass')1143 ->if(atoum\test::setNamespace('\test\unit\\'))1144 ->then1145 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\test\unit\testedClass'))->isEqualTo('foo\bar\testedClass')1146 ->if(atoum\test::setNamespace('test\unit\\'))1147 ->then1148 ->string(atoum\test::getTestedClassNameFromTestClass('foo\bar\test\unit\testedClass'))->isEqualTo('foo\bar\testedClass')1149 ->if(atoum\test::setNamespace('\test\unit'))...

Full Screen

Full Screen

testGetTestedClassName

Using AI Code Generation

copy

Full Screen

1$test = new withStatic();2echo $test->testGetTestedClassName();3$test = new withStatic();4echo $test->testGetTestedClassName();5class withStatic {6 public function testGetTestedClassName() {7 return self::getTestedClassName();8 }9 private static function getTestedClassName() {10 return __CLASS__;11 }12}13class withStatic {14 public function testGetTestedClassName() {15 return static::getTestedClassName();16 }17 private static function getTestedClassName() {18 return __CLASS__;19 }20}21class withStatic {22 public function testGetTestedClassName() {23 return self::getTestedClassName();24 }25 private static function getTestedClassName() {26 return __CLASS__;27 }28}29class withStatic {30 public function testGetTestedClassName() {31 return static::getTestedClassName();32 }33 private static function getTestedClassName() {34 return __CLASS__;35 }36}37Now if we use the self keyword, then the getTestedClassName() method will be called from the class where the getTestedClassName() method

Full Screen

Full Screen

testGetTestedClassName

Using AI Code Generation

copy

Full Screen

1$test = new withStatic();2echo $test->testGetTestedClassName();3$test = new withStatic();4echo $test->testGetTestedClassName();5namespace root;6{7 public function testGetTestedClassName()8 {9 return __CLASS__;10 }11}12namespace sub;13{14 public function testGetTestedClassName()15 {16 return __CLASS__;17 }18}19$test = new \root\withStatic();20echo $test->testGetTestedClassName();21$test = new \sub\withStatic();22echo $test->testGetTestedClassName();

Full Screen

Full Screen

testGetTestedClassName

Using AI Code Generation

copy

Full Screen

1$test = new withStatic;2$test->testGetTestedClassName();3$test = new withStatic;4$test->testGetTestedClassName();5$test = new withStatic;6$test->testGetTestedClassName();7$test = new withStatic;8$test->testGetTestedClassName();9$test = new withStatic;10$test->testGetTestedClassName();11$test = new withStatic;12$test->testGetTestedClassName();13$test = new withStatic;14$test->testGetTestedClassName();15$test = new withStatic;16$test->testGetTestedClassName();17$test = new withStatic;18$test->testGetTestedClassName();19$test = new withStatic;20$test->testGetTestedClassName();21$test = new withStatic;22$test->testGetTestedClassName();23$test = new withStatic;24$test->testGetTestedClassName();25$test = new withStatic;26$test->testGetTestedClassName();

Full Screen

Full Screen

testGetTestedClassName

Using AI Code Generation

copy

Full Screen

1require_once 'withStatic.php';2require_once 'PHPUnit/Framework/TestCase.php';3{4 public function testGetTestedClassName()5 {6 $this->assertEquals("withStatic", withStatic::getTestedClassName());7 }8}9require_once 'withStatic.php';10require_once 'PHPUnit/Framework/TestCase.php';11{12 public function testGetTestedClassName()13 {14 $this->assertEquals("withStatic", withStatic::getTestedClassName());15 }16}17require_once 'withStatic.php';18require_once 'PHPUnit/Framework/TestCase.php';19{20 public function testGetTestedClassName()21 {22 $this->assertEquals("withStatic", withStatic::getTestedClassName());23 }24}25require_once 'withStatic.php';26require_once 'PHPUnit/Framework/TestCase.php';27{28 public function testGetTestedClassName()29 {30 $this->assertEquals("withStatic", withStatic::getTestedClassName());31 }32}33require_once 'withStatic.php';34require_once 'PHPUnit/Framework/TestCase.php';35{36 public function testGetTestedClassName()37 {38 $this->assertEquals("withStatic", withStatic::getTestedClassName());39 }40}41require_once 'withStatic.php';42require_once 'PHPUnit/Framework/TestCase.php';43{44 public function testGetTestedClassName()45 {46 $this->assertEquals("withStatic", withStatic::getTestedClassName());47 }48}49require_once 'withStatic.php';

Full Screen

Full Screen

testGetTestedClassName

Using AI Code Generation

copy

Full Screen

1$withStatic = new withStatic();2$withStatic->testGetTestedClassName();3$withStatic = new withStatic();4$withStatic->testGetTestedClassName();5$withStatic = new withStatic();6$withStatic->testGetTestedClassName();7$withStatic = new withStatic();8$withStatic->testGetTestedClassName();9$withStatic = new withStatic();10$withStatic->testGetTestedClassName();11$withStatic = new withStatic();12$withStatic->testGetTestedClassName();13$withStatic = new withStatic();14$withStatic->testGetTestedClassName();15$withStatic = new withStatic();16$withStatic->testGetTestedClassName();17$withStatic = new withStatic();18$withStatic->testGetTestedClassName();19$withStatic = new withStatic();20$withStatic->testGetTestedClassName();

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 testGetTestedClassName code on LambdaTest Cloud Grid

Execute automation tests with testGetTestedClassName 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