Server IP : 127.0.0.2 / Your IP : 3.144.112.72 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,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,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/ |
Upload File : |
<?php /* * This file is part of the PHPUnit_MockObject package. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Mocker for invocations which are sent from * PHPUnit_Framework_MockObject_MockObject objects. * * Keeps track of all expectations and stubs as well as registering * identifications for builders. * * @since Class available since Release 1.0.0 */ class PHPUnit_Framework_MockObject_InvocationMocker implements PHPUnit_Framework_MockObject_Stub_MatcherCollection, PHPUnit_Framework_MockObject_Invokable, PHPUnit_Framework_MockObject_Builder_Namespace { /** * @var PHPUnit_Framework_MockObject_Matcher_Invocation[] */ protected $matchers = []; /** * @var PHPUnit_Framework_MockObject_Builder_Match[] */ protected $builderMap = []; /** * @var string[] */ private $configurableMethods = []; /** * @param array $configurableMethods */ public function __construct(array $configurableMethods) { $this->configurableMethods = $configurableMethods; } /** * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher */ public function addMatcher(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) { $this->matchers[] = $matcher; } /** * @since Method available since Release 1.1.0 */ public function hasMatchers() { foreach ($this->matchers as $matcher) { if ($matcher->hasMatchers()) { return true; } } return false; } /** * @param mixed $id * * @return bool|null */ public function lookupId($id) { if (isset($this->builderMap[$id])) { return $this->builderMap[$id]; } return; } /** * @param mixed $id * @param PHPUnit_Framework_MockObject_Builder_Match $builder * * @throws PHPUnit_Framework_MockObject_RuntimeException */ public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder) { if (isset($this->builderMap[$id])) { throw new PHPUnit_Framework_MockObject_RuntimeException( 'Match builder with id <' . $id . '> is already registered.' ); } $this->builderMap[$id] = $builder; } /** * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher * * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker */ public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher) { return new PHPUnit_Framework_MockObject_Builder_InvocationMocker( $this, $matcher, $this->configurableMethods ); } /** * @param PHPUnit_Framework_MockObject_Invocation $invocation * * @return mixed * * @throws Exception */ public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) { $exception = null; $hasReturnValue = false; $returnValue = null; foreach ($this->matchers as $match) { try { if ($match->matches($invocation)) { $value = $match->invoked($invocation); if (!$hasReturnValue) { $returnValue = $value; $hasReturnValue = true; } } } catch (Exception $e) { $exception = $e; } } if ($exception !== null) { throw $exception; } if ($hasReturnValue) { return $returnValue; } elseif (strtolower($invocation->methodName) == '__tostring') { return ''; } return $invocation->generateReturnValue(); } /** * @param PHPUnit_Framework_MockObject_Invocation $invocation * * @return bool */ public function matches(PHPUnit_Framework_MockObject_Invocation $invocation) { foreach ($this->matchers as $matcher) { if (!$matcher->matches($invocation)) { return false; } } return true; } /** * @return bool */ public function verify() { foreach ($this->matchers as $matcher) { $matcher->verify(); } } }