MAJ Librarys
This commit is contained in:
parent
1d3ed3af6d
commit
03ef74d0cf
17 changed files with 347 additions and 194 deletions
|
@ -98,6 +98,33 @@ class CachingStreamTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('ing', $this->body->read(3));
|
||||
}
|
||||
|
||||
public function testCanSeekToReadBytesWithPartialBodyReturned()
|
||||
{
|
||||
$stream = fopen('php://temp', 'r+');
|
||||
fwrite($stream, 'testing');
|
||||
fseek($stream, 0);
|
||||
|
||||
$this->decorated = $this->getMockBuilder('\GuzzleHttp\Psr7\Stream')
|
||||
->setConstructorArgs([$stream])
|
||||
->setMethods(['read'])
|
||||
->getMock();
|
||||
|
||||
$this->decorated->expects($this->exactly(2))
|
||||
->method('read')
|
||||
->willReturnCallback(function($length) use ($stream){
|
||||
return fread($stream, 2);
|
||||
});
|
||||
|
||||
$this->body = new CachingStream($this->decorated);
|
||||
|
||||
$this->assertEquals(0, $this->body->tell());
|
||||
$this->body->seek(4, SEEK_SET);
|
||||
$this->assertEquals(4, $this->body->tell());
|
||||
|
||||
$this->body->seek(0);
|
||||
$this->assertEquals('test', $this->body->read(4));
|
||||
}
|
||||
|
||||
public function testWritesToBufferStream()
|
||||
{
|
||||
$this->body->read(2);
|
||||
|
|
|
@ -13,4 +13,27 @@ class InflateStreamtest extends \PHPUnit_Framework_TestCase
|
|||
$b = new InflateStream($a);
|
||||
$this->assertEquals('test', (string) $b);
|
||||
}
|
||||
|
||||
public function testInflatesStreamsWithFilename()
|
||||
{
|
||||
$content = $this->getGzipStringWithFilename('test');
|
||||
$a = Psr7\stream_for($content);
|
||||
$b = new InflateStream($a);
|
||||
$this->assertEquals('test', (string) $b);
|
||||
}
|
||||
|
||||
private function getGzipStringWithFilename($original_string)
|
||||
{
|
||||
$gzipped = bin2hex(gzencode($original_string));
|
||||
|
||||
$header = substr($gzipped, 0, 20);
|
||||
// set FNAME flag
|
||||
$header[6]=0;
|
||||
$header[7]=8;
|
||||
// make a dummy filename
|
||||
$filename = "64756d6d7900";
|
||||
$rest = substr($gzipped, 20);
|
||||
|
||||
return hex2bin($header . $filename . $rest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
|
|||
[self::RFC3986_BASE, 'g;x=1/../y', 'http://a/b/c/y'],
|
||||
['http://u@a/b/c/d;p?q', '.', 'http://u@a/b/c/'],
|
||||
['http://u:p@a/b/c/d;p?q', '.', 'http://u:p@a/b/c/'],
|
||||
//[self::RFC3986_BASE, 'http:g', 'http:g'],
|
||||
['http://a/b/c/d/', 'e', 'http://a/b/c/d/e'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue