Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/vendor/codeception/stub/tests/ |
Upload File : |
<?php declare(strict_types=1); use Codeception\Stub\Expected; use Codeception\Test\Feature\Stub; use PHPUnit\Framework\TestCase; require_once __DIR__ .'/ResetMocks.php'; final class StubTraitTest extends TestCase { use ResetMocks; use Stub; protected DummyClass $dummy; public function setUp(): void { require_once $file = __DIR__. '/_data/DummyOverloadableClass.php'; require_once $file = __DIR__. '/_data/DummyClass.php'; $this->dummy = new DummyClass(true); } public function testMakeStubs() { $this->dummy = $this->make('DummyClass', ['helloWorld' => 'bye']); $this->assertEquals('bye', $this->dummy->helloWorld()); $this->assertEquals('good bye', $this->dummy->goodByeWorld()); $this->dummy = $this->makeEmpty('DummyClass', ['helloWorld' => 'bye']); $this->assertEquals('bye', $this->dummy->helloWorld()); $this->assertNull($this->dummy->goodByeWorld()); $this->dummy = $this->makeEmptyExcept('DummyClass', 'goodByeWorld', ['helloWorld' => 'bye']); $this->assertEquals('bye', $this->dummy->helloWorld()); $this->assertEquals('good bye', $this->dummy->goodByeWorld()); $this->assertNull($this->dummy->exceptionalMethod()); } public function testConstructStubs() { $this->dummy = $this->construct('DummyClass', ['!'], ['helloWorld' => 'bye']); $this->assertEquals('constructed: !', $this->dummy->getCheckMe()); $this->assertEquals('bye', $this->dummy->helloWorld()); $this->assertEquals('good bye', $this->dummy->goodByeWorld()); $this->dummy = $this->constructEmpty('DummyClass', ['!'], ['helloWorld' => 'bye']); $this->assertNull($this->dummy->getCheckMe()); $this->assertEquals('bye', $this->dummy->helloWorld()); $this->assertNull($this->dummy->goodByeWorld()); $this->dummy = $this->constructEmptyExcept('DummyClass', 'getCheckMe', ['!'], ['helloWorld' => 'bye']); $this->assertEquals('constructed: !', $this->dummy->getCheckMe()); $this->assertEquals('bye', $this->dummy->helloWorld()); $this->assertNull($this->dummy->goodByeWorld()); $this->assertNull($this->dummy->exceptionalMethod()); } public function testMakeMocks() { $this->dummy = $this->make('DummyClass', [ 'helloWorld' => Expected::once() ]); $this->dummy->helloWorld(); try { $this->dummy->helloWorld(); } catch (Exception $exception) { $this->assertTrue( strpos('was not expected to be called more than once', $exception->getMessage()) >= 0, 'String contains' ); $this->resetMockObjects(); return; } $this->fail('No exception thrown'); } }