Best Atoum code snippet using runner.doNotfailIfVoidMethods
runner.php
Source:runner.php  
1<?php2namespace atoum\atoum\tests\units\scripts;3use atoum\atoum;4use atoum\atoum\cli;5use atoum\atoum\mock\stream;6use atoum\atoum\scripts\runner as testedClass;7use atoum\atoum\writer;8use mock\atoum\atoum as mock;9require_once __DIR__ . '/../../runner.php';10class runner extends atoum\test11{12    public function testClass()13    {14        $this->testedClass->extends(atoum\script\configurable::class);15    }16    public function testClassConstants()17    {18        $this19            ->string(testedClass::defaultConfigFile)->isEqualTo('.atoum.php')20            ->string(testedClass::defaultBootstrapFile)->isEqualTo('.bootstrap.atoum.php')21        ;22    }23    public function test__construct()24    {25        $this26            ->if($runner = new testedClass($name = uniqid()))27            ->then28                ->boolean($runner->hasDefaultArguments())->isFalse()29                ->array($runner->getDefaultArguments())->isEmpty()30                ->string($runner->getName())->isEqualTo($name)31                ->object($runner->getAdapter())->isInstanceOf(atoum\adapter::class)32                ->object($runner->getLocale())->isInstanceOf(atoum\locale::class)33                ->object($runner->getIncluder())->isInstanceOf(atoum\includer::class)34                ->object($runner->getRunner())->isInstanceOf(atoum\runner::class)35                ->variable($runner->getScoreFile())->isNull()36                ->array($runner->getReports())->isEmpty()37                ->array($runner->getArguments())->isEmpty()38                ->array($runner->getHelp())->isEqualTo(39                    [40                        [41                            ['-h', '--help'],42                            null,43                            'Display this help'44                        ],45                        [46                            ['-c', '--configurations'],47                            '<file>...',48                            'Use all configuration files <file>'49                        ],50                        [51                            ['-v', '--version'],52                            null,53                            'Display version'54                        ],55                        [56                            ['+verbose', '++verbose'],57                            null,58                            'Enable verbose mode'59                        ],60                        [61                            ['--init'],62                            '<path/to/directory>',63                            sprintf($runner->getLocale()->_('Create configuration and bootstrap files in <path/to/directory> (Optional, default: %s)'), $runner->getDirectory())64                        ],65                        [66                            ['-p', '--php'],67                            '<path/to/php/binary>',68                            'Path to PHP binary which must be used to run tests'69                        ],70                        [71                            ['-drt', '--default-report-title'],72                            '<string>',73                            'Define default report title with <string>'74                        ],75                        [76                            ['-sf', '--score-file'],77                            '<file>',78                            'Save score in file <file>'79                        ],80                        [81                            ['-mcn', '--max-children-number'],82                            '<integer>',83                            'Maximum number of sub-processes which will be run simultaneously'84                        ],85                        [86                            ['-ncc', '--no-code-coverage'],87                            null,88                            'Disable code coverage'89                        ],90                        [91                            ['-nccid', '--no-code-coverage-in-directories'],92                            '<directory>...',93                            'Disable code coverage in directories <directory>'94                        ],95                        [96                            ['-nccfns', '--no-code-coverage-for-namespaces'],97                            '<namespace>...',98                            'Disable code coverage for namespaces <namespace>'99                        ],100                        [101                            ['-nccfc', '--no-code-coverage-for-classes'],102                            '<class>...',103                            'Disable code coverage for classes <class>'104                        ],105                        [106                            ['-nccfm', '--no-code-coverage-for-methods'],107                            '<method>...',108                            'Disable code coverage for methods <method>'109                        ],110                        [111                            ['-ebpc', '--enable-branch-and-path-coverage'],112                            null,113                            'Enable branch and path coverage'114                        ],115                        [116                            ['-f', '--files'],117                            '<file>...',118                            'Execute all unit test files <file>'119                        ],120                        [121                            ['-d', '--directories'],122                            '<directory>...',123                            'Execute unit test files in all <directory>'124                        ],125                        [126                            ['-tfe', '--test-file-extensions'],127                            '<extension>...',128                            'Execute unit test files with one of extensions <extension>'129                        ],130                        [131                            ['-g', '--glob'],132                            '<pattern>...',133                            'Execute unit test files which match <pattern>'134                        ],135                        [136                            ['-t', '--tags'],137                            '<tag>...',138                            'Execute only unit test with tags <tag>'139                        ],140                        [141                            ['-m', '--methods'],142                            '<class::method>...',143                            'Execute all <class::method>, * may be used as wildcard for class name or method name'144                        ],145                        [146                            ['-ns', '--namespaces'],147                            '<namespace>...',148                            'Execute all classes in all namespaces <namespace>'149                        ],150                        [151                            ['-l', '--loop'],152                            null,153                            'Execute tests in an infinite loop'154                        ],155                        [156                            ['--test-it'],157                            null,158                            'Execute atoum unit tests'159                        ],160                        [161                            ['-ft', '--force-terminal'],162                            null,163                            'Force output as in terminal'164                        ],165                        [166                            ['-af', '--autoloader-file'],167                            '<file>',168                            'Include autoloader <file> before executing each test method'169                        ],170                        [171                            ['-bf', '--bootstrap-file'],172                            '<file>',173                            'Include bootstrap <file> before executing each test method'174                        ],175                        [176                            ['-ulr', '--use-light-report'],177                            null,178                            'Use "light" CLI report'179                        ],180                        [181                            ['-udr', '--use-dot-report'],182                            null,183                            'Use "dot" CLI report'184                        ],185                        [186                            ['-utr', '--use-tap-report'],187                            null,188                            'Use TAP report'189                        ],190                        [191                            ['--debug'],192                            null,193                            'Enable debug mode'194                        ],195                        [196                            ['-xc', '--xdebug-config'],197                            null,198                            'Set XDEBUG_CONFIG variable'199                        ],200                        [201                            ['-fivm', '--fail-if-void-methods'],202                            null,203                            'Make the test suite fail if there is at least one void test method'204                        ],205                        [206                            ['-fism', '--fail-if-skipped-methods'],207                            null,208                            'Make the test suite fail if there is at least one skipped test method'209                        ]210                    ]211                )212            ->if($runner = new testedClass($name = uniqid(), $adapter = new atoum\adapter()))213            ->then214                ->string($runner->getName())->isEqualTo($name)215                ->object($runner->getAdapter())->isIdenticalTo($adapter)216                ->object($runner->getLocale())->isInstanceOf(atoum\locale::class)217                ->object($runner->getIncluder())->isInstanceOf(atoum\includer::class)218                ->object($runner->getRunner())->isInstanceOf(atoum\runner::class)219                ->variable($runner->getScoreFile())->isNull()220                ->array($runner->getArguments())->isEmpty()221                ->array($runner->getHelp())->isEqualTo(222                    [223                        [224                            ['-h', '--help'],225                            null,226                            'Display this help'227                        ],228                        [229                            ['-c', '--configurations'],230                            '<file>...',231                            'Use all configuration files <file>'232                        ],233                        [234                            ['-v', '--version'],235                            null,236                            'Display version'237                        ],238                        [239                            ['+verbose', '++verbose'],240                            null,241                            'Enable verbose mode'242                        ],243                        [244                            ['--init'],245                            '<path/to/directory>',246                            sprintf($runner->getLocale()->_('Create configuration and bootstrap files in <path/to/directory> (Optional, default: %s)'), $runner->getDirectory())247                        ],248                        [249                            ['-p', '--php'],250                            '<path/to/php/binary>',251                            'Path to PHP binary which must be used to run tests'252                        ],253                        [254                            ['-drt', '--default-report-title'],255                            '<string>',256                            'Define default report title with <string>'257                        ],258                        [259                            ['-sf', '--score-file'],260                            '<file>',261                            'Save score in file <file>'262                        ],263                        [264                            ['-mcn', '--max-children-number'],265                            '<integer>',266                            'Maximum number of sub-processes which will be run simultaneously'267                        ],268                        [269                            ['-ncc', '--no-code-coverage'],270                            null,271                            'Disable code coverage'272                        ],273                        [274                            ['-nccid', '--no-code-coverage-in-directories'],275                            '<directory>...',276                            'Disable code coverage in directories <directory>'277                        ],278                        [279                            ['-nccfns', '--no-code-coverage-for-namespaces'],280                            '<namespace>...',281                            'Disable code coverage for namespaces <namespace>'282                        ],283                        [284                            ['-nccfc', '--no-code-coverage-for-classes'],285                            '<class>...',286                            'Disable code coverage for classes <class>'287                        ],288                        [289                            ['-nccfm', '--no-code-coverage-for-methods'],290                            '<method>...',291                            'Disable code coverage for methods <method>'292                        ],293                        [294                            ['-ebpc', '--enable-branch-and-path-coverage'],295                            null,296                            'Enable branch and path coverage'297                        ],298                        [299                            ['-f', '--files'],300                            '<file>...',301                            'Execute all unit test files <file>'302                        ],303                        [304                            ['-d', '--directories'],305                            '<directory>...',306                            'Execute unit test files in all <directory>'307                        ],308                        [309                            ['-tfe', '--test-file-extensions'],310                            '<extension>...',311                            'Execute unit test files with one of extensions <extension>'312                        ],313                        [314                            ['-g', '--glob'],315                            '<pattern>...',316                            'Execute unit test files which match <pattern>'317                        ],318                        [319                            ['-t', '--tags'],320                            '<tag>...',321                            'Execute only unit test with tags <tag>'322                        ],323                        [324                            ['-m', '--methods'],325                            '<class::method>...',326                            'Execute all <class::method>, * may be used as wildcard for class name or method name'327                        ],328                        [329                            ['-ns', '--namespaces'],330                            '<namespace>...',331                            'Execute all classes in all namespaces <namespace>'332                        ],333                        [334                            ['-l', '--loop'],335                            null,336                            'Execute tests in an infinite loop'337                        ],338                        [339                            ['--test-it'],340                            null,341                            'Execute atoum unit tests'342                        ],343                        [344                            ['-ft', '--force-terminal'],345                            null,346                            'Force output as in terminal'347                        ],348                        [349                            ['-af', '--autoloader-file'],350                            '<file>',351                            'Include autoloader <file> before executing each test method'352                        ],353                        [354                            ['-bf', '--bootstrap-file'],355                            '<file>',356                            'Include bootstrap <file> before executing each test method'357                        ],358                        [359                            ['-ulr', '--use-light-report'],360                            null,361                            'Use "light" CLI report'362                        ],363                        [364                            ['-udr', '--use-dot-report'],365                            null,366                            'Use "dot" CLI report'367                        ],368                        [369                            ['-utr', '--use-tap-report'],370                            null,371                            'Use TAP report'372                        ],373                        [374                            ['--debug'],375                            null,376                            'Enable debug mode'377                        ],378                        [379                            ['-xc', '--xdebug-config'],380                            null,381                            'Set XDEBUG_CONFIG variable'382                        ],383                        [384                            ['-fivm', '--fail-if-void-methods'],385                            null,386                            'Make the test suite fail if there is at least one void test method'387                        ],388                        [389                            ['-fism', '--fail-if-skipped-methods'],390                            null,391                            'Make the test suite fail if there is at least one skipped test method'392                        ]393                    ]394                )395        ;396    }397    public function testSetArguments()398    {399        $this400            ->if($runner = new testedClass($name = uniqid()))401            ->then402                ->object($runner->setArguments([]))->isIdenticalTo($runner)403                ->array($runner->getArguments())->isEmpty()404                ->object($runner->setArguments($arguments = [uniqid(), uniqid(), uniqid()]))->isIdenticalTo($runner)405                ->array($runner->getArguments())->isEqualTo($arguments)406        ;407    }408    public function testUseConfigFile()409    {410        $this411            ->if($runner = new testedClass(uniqid()))412            ->and($runner->setLocale($locale = new \mock\atoum\atoum\locale()))413            ->then414                ->exception(function () use ($runner, & $file) {415                    $runner->useConfigFile($file = uniqid());416                })417                    ->isInstanceOf(atoum\includer\exception::class)418                    ->hasMessage('Unable to find configuration file \'' . $file . '\'')419                ->mock($locale)->call('_')->withArguments('Unable to find configuration file \'%s\'')->once()420            ->if($configFile = stream::get())421            ->and($configFile->file_get_contents = '<?php $runner->disableCodeCoverage(); ?>')422            ->then423                ->boolean($runner->getRunner()->codeCoverageIsEnabled())->isTrue()424                ->object($runner->useConfigFile((string) $configFile))->isIdenticalTo($runner)425                ->boolean($runner->getRunner()->codeCoverageIsEnabled())->isFalse()426        ;427    }428    public function testAddDefaultReport()429    {430        $this431            ->given(432                $adapter = new atoum\test\adapter(),433                $adapter->getenv = false434            )435            ->if($runner = new \mock\atoum\atoum\scripts\runner(uniqid(), $adapter))436            ->then437                ->object($report = $runner->addDefaultReport())->isInstanceOf(atoum\reports\realtime\cli::class)438                ->array($report->getWriters())->isEqualTo([new atoum\writers\std\out()])439                ->adapter($adapter)440                    ->call('getenv')->withArguments('TRAVIS')->once441            ->given($adapter->getenv = true)442            ->then443                ->object($report = $runner->addDefaultReport())->isInstanceOf(atoum\reports\realtime\cli\travis::class)444                ->array($report->getWriters())->isEqualTo([new atoum\writers\std\out()])445                ->adapter($adapter)446                    ->call('getenv')->withArguments('TRAVIS')->twice447        ;448    }449    public function testAddReport()450    {451        $this452            ->if($runner = new \mock\atoum\atoum\scripts\runner(uniqid()))453            ->then454                ->object($runner->addReport($report = new \mock\atoum\atoum\report()))->isIdenticalTo($runner)455                ->array($runner->getReports())->isEqualTo([$report])456                ->object($runner->addReport($otherReport = new \mock\atoum\atoum\report()))->isIdenticalTo($runner)457                ->array($runner->getReports())->isEqualTo([$report, $otherReport])458        ;459    }460    public function testSetReport()461    {462        $this463            ->if($runner = new \mock\atoum\atoum\scripts\runner(uniqid()))464            ->then465                ->object($runner->setReport($report = new \mock\atoum\atoum\report()))->isIdenticalTo($runner)466                ->array($runner->getReports())->isEqualTo([$report])467                ->object($runner->setReport($otherReport = new \mock\atoum\atoum\report()))->isIdenticalTo($runner)468                ->array($runner->getReports())->isEqualTo([$otherReport])469            ->if($runner->addReport($report))470            ->then471                ->array($runner->getReports())->isEqualTo([$otherReport])472        ;473    }474    public function testSetNamespaces()475    {476        $this477            ->if($runner = new \mock\atoum\atoum\scripts\runner(uniqid()))478            ->then479                ->object($runner->testNamespaces([]))->isIdenticalTo($runner)480                ->array($runner->getTestedNamespaces())->isEmpty()481                ->object($runner->testNamespaces(['foo', '\bar', 'foo\bar\\', '\this\is\a\namespace\\']))->isIdenticalTo($runner)482                ->array($runner->getTestedNamespaces())->isEqualTo(['foo', 'bar', 'foo\bar', 'this\is\a\namespace'])483        ;484    }485    public function testSetPhpPath()486    {487        $this488            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))489            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))490            ->then491                ->object($script->setPhpPath($phpPath = uniqid()))->isIdenticalTo($script)492                ->mock($runner)->call('setPhpPath')->withArguments($phpPath)->once()493        ;494    }495    public function testSetDefaultReportTitle()496    {497        $this498            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))499            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))500            ->then501                ->object($script->setDefaultReportTitle($reportTitle = uniqid()))->isIdenticalTo($script)502                ->mock($runner)->call('setDefaultReportTitle')->withArguments($reportTitle)->once()503        ;504    }505    public function testSetMaxChildrenNumber()506    {507        $this508            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))509            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))510            ->then511                ->object($script->setMaxChildrenNumber($childrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($script)512                ->mock($runner)->call('setMaxChildrenNumber')->withArguments($childrenNumber)->once()513        ;514    }515    public function testDisableCodeCoverage()516    {517        $this518            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))519            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))520            ->then521                ->object($script->disableCodeCoverage($childrenNumber = rand(1, PHP_INT_MAX)))->isIdenticalTo($script)522                ->mock($runner)->call('disableCodeCoverage')->withoutAnyArgument()->once()523        ;524    }525    public function testExcludeNamespacesFromCoverage()526    {527        $this528            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))529            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))530            ->and($this->calling($runner)->getCoverage = $coverage = new \mock\atoum\atoum\score\coverage())531            ->then532                ->object($script->excludeNamespacesFromCoverage(['foo', 'bar']))->isIdenticalTo($script)533                ->mock($coverage)->call('excludeNamespace')534                    ->withArguments('foo')->once()535                    ->withArguments('bar')->once()536        ;537    }538    public function testExcludeDirectoriesFromCoverage()539    {540        $this541            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))542            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))543            ->and($this->calling($runner)->getCoverage = $coverage = new \mock\atoum\atoum\score\coverage())544            ->then545                ->object($script->excludeDirectoriesFromCoverage(['foo', 'bar']))->isIdenticalTo($script)546                ->mock($coverage)->call('excludeDirectory')547                    ->withArguments('foo')->once()548                    ->withArguments('bar')->once()549        ;550    }551    public function testExcludeClassesFromCoverage()552    {553        $this554            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))555            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))556            ->and($this->calling($runner)->getCoverage = $coverage = new \mock\atoum\atoum\score\coverage())557            ->then558                ->object($script->excludeClassesFromCoverage(['foo', 'bar']))->isIdenticalTo($script)559                ->mock($coverage)->call('excludeClass')560                    ->withArguments('foo')->once()561                    ->withArguments('bar')->once()562        ;563    }564    public function testAddTest()565    {566        $this567            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))568            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))569            ->then570                ->object($script->addTest($testPath = uniqid()))->isIdenticalTo($script)571                ->mock($runner)->call('addTest')->withArguments($testPath)->once()572        ;573    }574    public function testAddTests()575    {576        $this577            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))578            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))579            ->then580                ->object($script->addTests([$testPath1 = uniqid(), $testPath2 = uniqid()]))->isIdenticalTo($script)581                ->mock($runner)582                    ->call('addTest')583                        ->withArguments($testPath1)->once()584                        ->withArguments($testPath2)->once()585        ;586    }587    public function testAddTestsFromDirectory()588    {589        $this590            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))591            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))592            ->and($this->calling($runner)->addTestsFromDirectory->doesNothing())593            ->then594                ->object($script->addTestsFromDirectory($directory = uniqid()))->isIdenticalTo($script)595                ->mock($runner)->call('addTestsFromDirectory')->withArguments($directory)->once()596        ;597    }598    public function testAddTestsFromDirectories()599    {600        $this601            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))602            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))603            ->and($this->calling($runner)->addTestsFromDirectory->doesNothing())604            ->then605                ->object($script->addTestsFromDirectories([$directory1 = uniqid(), $directory2 = uniqid()]))->isIdenticalTo($script)606                ->mock($runner)607                    ->call('addTestsFromDirectory')608                        ->withArguments($directory1)->once()609                        ->withArguments($directory2)->once()610        ;611    }612    public function testAddTestsFromPattern()613    {614        $this615            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))616            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))617            ->and($this->calling($runner)->addTestsFromPattern->doesNothing())618            ->then619                ->object($script->addTestsFromPattern($pattern = uniqid()))->isIdenticalTo($script)620                ->mock($runner)->call('addTestsFromPattern')->withArguments($pattern)->once()621        ;622    }623    public function testAddTestsFromPatterns()624    {625        $this626            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))627            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))628            ->and($this->calling($runner)->addTestsFromPattern->doesNothing())629            ->then630                ->object($script->addTestsFromPatterns([$pattern1 = uniqid(), $pattern2 = uniqid()]))->isIdenticalTo($script)631                ->mock($runner)632                    ->call('addTestsFromPattern')633                        ->withArguments($pattern1)->once()634                        ->withArguments($pattern2)->once()635        ;636    }637    public function testAcceptTestFileExtensions()638    {639        $this640            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))641            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))642            ->and($this->calling($runner)->acceptTestFileExtensions->doesNothing())643            ->then644                ->object($script->acceptTestFileExtensions($testFileExtensions = [uniqid(), uniqid()]))->isIdenticalTo($script)645                ->mock($runner)->call('acceptTestFileExtensions')->withArguments($testFileExtensions)->once()646        ;647    }648    public function testSetBootstrapFile()649    {650        $this651            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))652            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))653            ->and($this->calling($runner)->setBootstrapFile->doesNothing())654            ->then655                ->object($script->setBootstrapFile($bootstrapFile = uniqid()))->isIdenticalTo($script)656                ->mock($runner)->call('setBootstrapFile')->withArguments($bootstrapFile)->once()657        ;658    }659    public function testSetXdebugConfig()660    {661        $this662            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))663            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))664            ->and($this->calling($runner)->setXdebugConfig->doesNothing())665            ->then666                ->object($script->setXdebugConfig($xdebugConfig = uniqid()))->isIdenticalTo($script)667                ->mock($runner)->call('setXdebugConfig')->withArguments($xdebugConfig)->once()668        ;669    }670    public function testFailIfVoidMethods()671    {672        $this673            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))674            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))675            ->then676                ->object($script->failIfVoidMethods())->isIdenticalTo($script)677                ->mock($runner)->call('failIfVoidMethods')->once()678        ;679    }680    public function testDoNotFailIfVoidMethods()681    {682        $this683            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))684            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))685            ->then686                ->object($script->doNotFailIfVoidMethods())->isIdenticalTo($script)687                ->mock($runner)->call('doNotFailIfVoidMethods')->once()688        ;689    }690    public function testShouldFailIfVoidMethods()691    {692        $this693            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))694            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))695            ->then696                ->boolean($script->shouldFailIfVoidMethods())->isFalse()697                ->mock($runner)->call('shouldFailIfVoidMethods')->once()698            ->if($this->calling($runner)->shouldFailIfVoidMethods = true)699            ->then700                ->boolean($script->shouldFailIfVoidMethods())->isTrue()701            ->if($this->calling($runner)->shouldFailIfVoidMethods = false)702            ->then703                ->boolean($script->shouldFailIfVoidMethods())->isFalse()704        ;705    }706    public function testFailIfSkippedMethods()707    {708        $this709            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))710            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))711            ->then712                ->object($script->failIfSkippedMethods())->isIdenticalTo($script)713                ->mock($runner)->call('failIfSkippedMethods')->once()714        ;715    }716    public function testDoNotFailIfSkippedMethods()717    {718        $this719            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))720            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))721            ->then722                ->object($script->doNotFailIfSkippedMethods())->isIdenticalTo($script)723                ->mock($runner)->call('doNotFailIfSkippedMethods')->once()724        ;725    }726    public function testShouldFailIfSkippedMethods()727    {728        $this729            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))730            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))731            ->then732                ->boolean($script->shouldFailIfSkippedMethods())->isFalse()733                ->mock($runner)->call('shouldFailIfSkippedMethods')->once()734            ->if($this->calling($runner)->shouldFailIfSkippedMethods = true)735            ->then736                ->boolean($script->shouldFailIfSkippedMethods())->isTrue()737            ->if($this->calling($runner)->shouldFailIfSkippedMethods = false)738            ->then739                ->boolean($script->shouldFailIfSkippedMethods())->isFalse()740        ;741    }742    public function testEnableDebugMode()743    {744        $this745            ->if($script = new \mock\atoum\atoum\scripts\runner(uniqid()))746            ->and($script->setRunner($runner = new \mock\atoum\atoum\runner()))747            ->and($this->calling($runner)->enableDebugMode->doesNothing())748            ->then749                ->object($script->enableDebugMode())->isIdenticalTo($script)750                ->mock($runner)->call('enableDebugMode')->withoutAnyArgument()->once()751        ;752    }753    public function testAddDefaultArguments()754    {755        $this756            ->if($runner = new \mock\atoum\atoum\scripts\runner(uniqid()))757            ->then758                ->object($runner->addDefaultArguments($arg1 = uniqid()))->isInstanceOf($runner)759                ->boolean($runner->hasDefaultArguments())->isTrue()760                ->array($runner->getDefaultArguments())->isEqualTo([$arg1])761                ->object($runner->addDefaultArguments($arg2 = uniqid(), $arg3 = uniqid()))->isInstanceOf($runner)762                ->boolean($runner->hasDefaultArguments())->isTrue()763                ->array($runner->getDefaultArguments())->isEqualTo([$arg1, $arg2, $arg3])764        ;765    }766    public function testInit()767    {768        $this769            ->given($runner = new testedClass(__FILE__))770            ->and($runner->setAdapter($adapter = new atoum\test\adapter()))771            ->and($runner->setInfoWriter($outputWriter = new \mock\atoum\atoum\writers\std\out()))772            ->and($runner->setPrompt($prompt = new \mock\atoum\atoum\script\prompt()))773            ->and($adapter->copy = true)774            ->and($adapter->file_exists = false)775            ->and($this->calling($outputWriter)->write = function () {776            })777            ->then778                ->object($runner->init())->isIdenticalTo($runner)779                ->mock($prompt)780                    ->call('ask')781                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' already exists in ' . $runner->getDirectory() . ', type \'Y\' to overwrite it...')->never()782                ->mock($outputWriter)783                    ->call('write')784                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' was successfully created in ' . $runner->getDirectory())->once()785                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' was successfully created in ' . $runner->getDirectory())->once()786                ->adapter($adapter)787                    ->call('copy')788                        ->withArguments(atoum\directory . '/resources/configurations/runner/atoum.php.dist', getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultConfigFile)->once()789                        ->withArguments(atoum\directory . '/resources/configurations/runner/bootstrap.php.dist', getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultBootstrapFile)->once()790            ->if($this->resetAdapter($adapter))791            ->and($this->resetMock($outputWriter))792            ->then793                ->object($runner->init($directory = uniqid()))->isIdenticalTo($runner)794                ->mock($prompt)795                    ->call('ask')796                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' already exists in ' . $directory . ', type \'Y\' to overwrite it...')->never()797                ->mock($outputWriter)798                    ->call('write')799                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' was successfully created in ' . $directory . DIRECTORY_SEPARATOR)->once()800                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' was successfully created in ' . $directory . DIRECTORY_SEPARATOR)->once()801                ->adapter($adapter)802                    ->call('copy')803                        ->withArguments(atoum\directory . '/resources/configurations/runner/atoum.php.dist', $directory . DIRECTORY_SEPARATOR . testedClass::defaultConfigFile)->once()804                        ->withArguments(atoum\directory . '/resources/configurations/runner/bootstrap.php.dist', $directory . DIRECTORY_SEPARATOR . testedClass::defaultBootstrapFile)->once()805            ->if($this->resetAdapter($adapter))806            ->and($this->resetMock($outputWriter))807            ->and($adapter->file_exists = true)808            ->and($this->calling($prompt)->ask = 'Y')809            ->then810                ->object($runner->init())->isIdenticalTo($runner)811                ->mock($prompt)812                    ->call('ask')813                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' already exists in ' . $runner->getDirectory() . ', type \'Y\' to overwrite it...')->once()814                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' already exists in ' . $runner->getDirectory() . ', type \'Y\' to overwrite it...')->once()815                ->mock($outputWriter)816                    ->call('write')817                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' was successfully created in ' . $runner->getDirectory())->once()818                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' was successfully created in ' . $runner->getDirectory())->once()819                ->adapter($adapter)820                    ->call('copy')821                        ->withArguments(atoum\directory . '/resources/configurations/runner/atoum.php.dist', getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultConfigFile)->once()822                        ->withArguments(atoum\directory . '/resources/configurations/runner/bootstrap.php.dist', getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultBootstrapFile)->once()823            ->if($this->resetAdapter($adapter))824            ->and($this->resetMock($outputWriter))825            ->and($this->resetMock($prompt))826            ->and($adapter->file_exists = true)827            ->and($this->calling($prompt)->ask = 'y')828            ->then829                ->object($runner->init())->isIdenticalTo($runner)830                ->mock($prompt)831                    ->call('ask')832                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' already exists in ' . $runner->getDirectory() . ', type \'Y\' to overwrite it...')->once()833                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' already exists in ' . $runner->getDirectory() . ', type \'Y\' to overwrite it...')->once()834                ->mock($outputWriter)835                    ->call('write')836                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' was successfully created in ' . $runner->getDirectory())->never()837                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' was successfully created in ' . $runner->getDirectory())->never()838                ->adapter($adapter)839                    ->call('copy')840                        ->withArguments(atoum\directory . '/resources/configurations/runner/atoum.php.dist', getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultConfigFile)->never()841                        ->withArguments(atoum\directory . '/resources/configurations/runner/bootstrap.php.dist', getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultBootstrapFile)->never()842            ->if($this->resetAdapter($adapter))843            ->and($this->resetMock($outputWriter))844            ->and($this->resetMock($prompt))845            ->and($adapter->file_exists = true)846            ->and($this->calling($prompt)->ask = uniqid())847            ->then848                ->object($runner->init())->isIdenticalTo($runner)849                ->mock($prompt)850                    ->call('ask')851                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' already exists in ' . $runner->getDirectory() . ', type \'Y\' to overwrite it...')->once()852                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' already exists in ' . $runner->getDirectory() . ', type \'Y\' to overwrite it...')->once()853                ->mock($outputWriter)854                    ->call('write')855                        ->withArguments('Default configuration file \'' . testedClass::defaultConfigFile . '\' was successfully created in ' . $runner->getDirectory() . PHP_EOL)->never()856                        ->withArguments('Default bootstrap file \'' . testedClass::defaultBootstrapFile . '\' was successfully created in ' . $runner->getDirectory() . PHP_EOL)->never()857                ->adapter($adapter)858                    ->call('copy')859                        ->withArguments(atoum\directory . '/resources/configurations/runner/atoum.php.dist', __DIR__ . DIRECTORY_SEPARATOR . testedClass::defaultConfigFile)->never()860                        ->withArguments(atoum\directory . '/resources/configurations/runner/bootstrap.php.dist', __DIR__ . DIRECTORY_SEPARATOR . testedClass::defaultBootstrapFile)->never()861            ->if($this->calling($prompt)->ask = 'Y')862            ->and($adapter->copy = false)863            ->then864                ->exception(function () use ($runner) {865                    $runner->init();866                })867                    ->isInstanceOf(atoum\exceptions\runtime::class)868                    ->hasMessage('Unable to write \'' . atoum\directory . '/resources/configurations/runner/atoum.php.dist\' to \'' . getcwd() . DIRECTORY_SEPARATOR . testedClass::defaultConfigFile . '\'')869        ;870    }871    public function testSetInfoWriter()872    {873        $this874            ->given($runner = new testedClass(uniqid()))875            ->then876                ->object($runner->setInfoWriter($errorWriter = new atoum\writers\std\err()))->isIdenticalTo($runner)877                ->object($runner->getInfoWriter())->isIdenticalTo($errorWriter)878            ->given(879                $defaultInfoWriter = new atoum\writers\std\out(),880                $defaultInfoWriter881                    ->addDecorator(new writer\decorators\rtrim())882                    ->addDecorator(new writer\decorators\eol())883                    ->addDecorator(new atoum\cli\clear())884                    ->addDecorator(new cli\colorizer('0;32'))885            )886            ->then887                ->object($runner->setInfoWriter())->isIdenticalTo($runner)888                ->object($runner->getInfoWriter())->isEqualTo($defaultInfoWriter)889        ;890    }891    public function testSetWarningWriter()892    {893        $this894            ->given($runner = new testedClass(uniqid()))895            ->then896                ->object($runner->setWarningWriter($warningWriter = new atoum\writers\std\err()))->isIdenticalTo($runner)897                ->object($runner->getWarningWriter())->isIdenticalTo($warningWriter)898            ->given($colorizer = new cli\colorizer('0;33'))899            ->and($colorizer->setPattern('/^([^:]+:)/'))900            ->and($defaultWarningWriter = new atoum\writers\std\err())901            ->and($defaultWarningWriter->addDecorator($colorizer))902            ->then903                ->object($runner->setWarningWriter())->isIdenticalTo($runner)904                ->object($runner->getWarningWriter())->isEqualTo($defaultWarningWriter)905        ;906    }907    public function testSetErrorWriter()908    {909        $this910            ->given($runner = new testedClass(uniqid()))911            ->then912                ->object($runner->setErrorWriter($errorWriter = new atoum\writers\std\err()))->isIdenticalTo($runner)913                ->object($runner->getErrorWriter())->isIdenticalTo($errorWriter)914            ->given(915                $colorizer = new cli\colorizer('0;31'),916                $colorizer->setPattern('/^([^:]+:)/'),917                $defaultErrorWriter = new atoum\writers\std\err(),918                $defaultErrorWriter919                    ->addDecorator(new writer\decorators\trim())920                    ->addDecorator(new writer\decorators\prompt($runner->getLocale()->_('Error: ')))921                    ->addDecorator(new writer\decorators\eol())922                    ->addDecorator(new atoum\cli\clear())923                    ->addDecorator($colorizer)924            )925            ->then926                ->object($runner->setErrorWriter())->isIdenticalTo($runner)927                ->object($runner->getErrorWriter())->isEqualTo($defaultErrorWriter)928        ;929    }930    public function testHelp()931    {932        $this933            ->if($argumentsParser = new mock\script\arguments\parser())934            ->and($this->calling($argumentsParser)->addHandler = function () {935            })936            ->and($locale = new mock\locale())937            ->and($this->calling($locale)->_ = function ($string) {938                return vsprintf($string, array_slice(func_get_args(), 1));939            })940            ->and($helpWriter = new mock\writers\std\out())941            ->and($this->calling($helpWriter)->write = function () {942            })943            ->and($runner = new testedClass($name = uniqid()))944            ->and($runner->setArgumentsParser($argumentsParser))945            ->and($runner->setLocale($locale))946            ->and($runner->setHelpWriter($helpWriter))947            ->then948                ->object($runner->help())->isIdenticalTo($runner)949                ->mock($helpWriter)->call('write')950                    ->atLeastOnce()951                    ->withArguments('Usage: ' . $name . ' [path/to/test/file] [options]' . PHP_EOL)->once()952        ;953    }954    public function testRun()955    {956        $this957            ->if($locale = new mock\locale())958            ->and($this->calling($locale)->_ = function ($string) {959                return $string;960            })961            ->and($helpWriter = new mock\writers\std\out())962            ->and($this->calling($helpWriter)->write = function () {963            })964            ->and($errorWriter = new mock\writers\std\err())965            ->and($this->calling($errorWriter)->clear = $errorWriter)966            ->and($this->calling($errorWriter)->write = $errorWriter)967            ->and($runner = new mock\runner())968            ->and($this->calling($runner)->getTestPaths = [])969            ->and($this->calling($runner)->getDeclaredTestClasses = [])970            ->and($this->calling($runner)->run = function () {971            })972            ->and($script = new testedClass($name = uniqid()))973            ->and($script->setLocale($locale))974            ->and($script->setHelpWriter($helpWriter))975            ->and($script->setErrorWriter($errorWriter))976            ->and($script->setRunner($runner))977            ->then978                ->object($script->run())->isIdenticalTo($script)979                ->mock($locale)980                    ->call('_')981                        ->withArguments('No test found')->once()982                ->mock($errorWriter)->call('write')->withArguments('No test found')->once()983        ;984    }985    public function testAutorun()986    {987        $this988            ->if($script = new testedClass(uniqid()))989            ->and($script->setAdapter($adapter = new atoum\test\adapter()))990            ->and($adapter->realpath = function ($path) {991                return $path;992            })993            ->when(function () {994                if (isset($_SERVER['argv']) === true) {995                    unset($_SERVER['argv']);996                }997            })998            ->then999                ->boolean($script->autorun())->isTrue()1000            ->if($_SERVER['argv'] = [])1001            ->then1002                ->boolean($script->autorun())->isTrue()1003            ->if($_SERVER['argv'][0] = $script->getName())1004            ->then1005                ->boolean($script->autorun())->isFalse()1006            ->if($adapter->realpath = uniqid())1007            ->then1008                ->boolean($script->autorun())->isTrue()1009        ;1010    }1011}...doNotfailIfVoidMethods
Using AI Code Generation
1require_once 'PHPUnit/Autoload.php';2require_once 'PHPUnit/Extensions/Database/TestCase.php';3require_once 'PHPUnit/Extensions/Database/DataSet/QueryDataSet.php';4require_once 'PHPUnit/Extensions/Database/DataSet/DefaultDataSet.php';5require_once 'PHPUnit/Extensions/Database/DataSet/DefaultTable.php';6require_once 'PHPUnit/Extensions/Database/DataSet/DefaultTableMetaData.php';7require_once 'PHPUnit/Extensions/Database/DataSet/DefaultTableIterator.php';doNotfailIfVoidMethods
Using AI Code Generation
1$runner = new runner();2$runner->doNotfailIfVoidMethods();3$runner->run();4$runner = new runner();5$runner->doNotfailIfVoidMethods();6$runner->run();7$runner = new runner();8$runner->doNotfailIfVoidMethods();9$runner->run();10$runner = new runner();11$runner->doNotfailIfVoidMethods();12$runner->run();13$runner = new runner();14$runner->doNotfailIfVoidMethods();15$runner->run();16$runner = new runner();17$runner->doNotfailIfVoidMethods();18$runner->run();19$runner = new runner();20$runner->doNotfailIfVoidMethods();21$runner->run();22$runner = new runner();23$runner->doNotfailIfVoidMethods();24$runner->run();25$runner = new runner();26$runner->doNotfailIfVoidMethods();27$runner->run();28$runner = new runner();29$runner->doNotfailIfVoidMethods();30$runner->run();31$runner = new runner();32$runner->doNotfailIfVoidMethods();33$runner->run();34$runner = new runner();35$runner->doNotfailIfVoidMethods();36$runner->run();doNotfailIfVoidMethods
Using AI Code Generation
1public function voidMethod() {2}3public function returnMethod() {4    return 1;5}6public function voidMethod2() {7}8public function returnMethod2() {9    return 1;10}11public function voidMethod3() {12}13public function returnMethod3() {14    return 1;15}16public function voidMethod4() {17}18public function returnMethod4() {19    return 1;20}21public function voidMethod5() {22}23public function returnMethod5() {24    return 1;25}26public function voidMethod6() {27}28public function returnMethod6() {29    return 1;30}31public function voidMethod7() {32}33public function returnMethod7() {34    return 1;35}36public function voidMethod8() {37}38public function returnMethod8() {39    return 1;40}41public function voidMethod9() {Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with doNotfailIfVoidMethods on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!
