Server IP : 127.0.0.2 / Your IP : 3.15.26.108 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/guzzlehttp/streams/tests/ |
Upload File : |
<?php namespace GuzzleHttp\Tests\Stream; use GuzzleHttp\Stream\Stream; use GuzzleHttp\Stream\FnStream; /** * @covers GuzzleHttp\Stream\FnStream */ class FnStreamTest extends \PHPUnit_Framework_TestCase { /** * @expectedException \BadMethodCallException * @expectedExceptionMessage seek() is not implemented in the FnStream */ public function testThrowsWhenNotImplemented() { (new FnStream([]))->seek(1); } public function testProxiesToFunction() { $s = new FnStream([ 'read' => function ($len) { $this->assertEquals(3, $len); return 'foo'; } ]); $this->assertEquals('foo', $s->read(3)); } public function testCanCloseOnDestruct() { $called = false; $s = new FnStream([ 'close' => function () use (&$called) { $called = true; } ]); unset($s); $this->assertTrue($called); } public function testDoesNotRequireClose() { $s = new FnStream([]); unset($s); } public function testDecoratesStream() { $a = Stream::factory('foo'); $b = FnStream::decorate($a, []); $this->assertEquals(3, $b->getSize()); $this->assertEquals($b->isWritable(), true); $this->assertEquals($b->isReadable(), true); $this->assertEquals($b->isSeekable(), true); $this->assertEquals($b->read(3), 'foo'); $this->assertEquals($b->tell(), 3); $this->assertEquals($a->tell(), 3); $this->assertEquals($b->eof(), true); $this->assertEquals($a->eof(), true); $b->seek(0); $this->assertEquals('foo', (string) $b); $b->seek(0); $this->assertEquals('foo', $b->getContents()); $this->assertEquals($a->getMetadata(), $b->getMetadata()); $b->seek(0, SEEK_END); $b->write('bar'); $this->assertEquals('foobar', (string) $b); $this->assertInternalType('resource', $b->detach()); $b->close(); } public function testDecoratesWithCustomizations() { $called = false; $a = Stream::factory('foo'); $b = FnStream::decorate($a, [ 'read' => function ($len) use (&$called, $a) { $called = true; return $a->read($len); } ]); $this->assertEquals('foo', $b->read(3)); $this->assertTrue($called); } }