Skip to content
Snippets Groups Projects
Commit 531680a1 authored by David Prévot's avatar David Prévot
Browse files

Update upstream source from tag 'upstream/2.0.0'

Update to upstream version '2.0.0'
with Debian dir ef6a6b96627e340bcfd64ef8a8fa211a4a057ea2
parents daa0c341 e0373572
No related branches found
No related tags found
No related merge requests found
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.0.0] - 2023-10-21
- Require PHP 8.x and PHPUnit 10.x #47
## [1.1.0] - 2023-10-21
- Final release that supports PHP 7.x.
## [1.0.0] - 2023-10-10
- Add tests for streams #39
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
"authors": [ "authors": [
{ {
"name": "PHP-FIG", "name": "PHP-FIG",
"homepage": "http://www.php-fig.org/" "homepage": "https://www.php-fig.org/"
} }
], ],
"require": { "require": {
"php": "^7.1 || ^8.0", "php": "^8.0",
"psr/http-factory": "^1.0", "psr/http-factory": "^1.0",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" "phpunit/phpunit": "^10.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
......
...@@ -38,7 +38,7 @@ abstract class RequestFactoryTestCase extends TestCase ...@@ -38,7 +38,7 @@ abstract class RequestFactoryTestCase extends TestCase
$this->assertSame($uri, (string) $request->getUri()); $this->assertSame($uri, (string) $request->getUri());
} }
public function dataMethods() public static function dataMethods()
{ {
return [ return [
['GET'], ['GET'],
......
...@@ -29,7 +29,7 @@ abstract class ResponseFactoryTestCase extends TestCase ...@@ -29,7 +29,7 @@ abstract class ResponseFactoryTestCase extends TestCase
$this->assertSame($code, $response->getStatusCode()); $this->assertSame($code, $response->getStatusCode());
} }
public function dataCodes() public static function dataCodes()
{ {
return [ return [
[200], [200],
......
...@@ -38,7 +38,7 @@ abstract class ServerRequestFactoryTestCase extends TestCase ...@@ -38,7 +38,7 @@ abstract class ServerRequestFactoryTestCase extends TestCase
$this->assertSame($uri, (string) $request->getUri()); $this->assertSame($uri, (string) $request->getUri());
} }
public function dataMethods() public static function dataMethods()
{ {
return [ return [
['GET'], ['GET'],
...@@ -50,11 +50,11 @@ abstract class ServerRequestFactoryTestCase extends TestCase ...@@ -50,11 +50,11 @@ abstract class ServerRequestFactoryTestCase extends TestCase
]; ];
} }
public function dataServer() public static function dataServer()
{ {
$data = []; $data = [];
foreach ($this->dataMethods() as $methodData) { foreach (static::dataMethods() as $methodData) {
$data[] = [ $data[] = [
[ [
'REQUEST_METHOD' => $methodData[0], 'REQUEST_METHOD' => $methodData[0],
......
...@@ -68,6 +68,17 @@ abstract class StreamFactoryTestCase extends TestCase ...@@ -68,6 +68,17 @@ abstract class StreamFactoryTestCase extends TestCase
$this->assertStream($stream, $string); $this->assertStream($stream, $string);
} }
public function testCreateStreamCursorPosition()
{
$this->markTestIncomplete('This behaviour has not been specified by PHP-FIG yet.');
$string = 'would you like some crumpets?';
$stream = $this->factory->createStream($string);
$this->assertSame(strlen($string), $stream->tell());
}
public function testCreateStreamFromFile() public function testCreateStreamFromFile()
{ {
$string = 'would you like some crumpets?'; $string = 'would you like some crumpets?';
...@@ -132,6 +143,22 @@ abstract class StreamFactoryTestCase extends TestCase ...@@ -132,6 +143,22 @@ abstract class StreamFactoryTestCase extends TestCase
$stream = $this->factory->createStreamFromFile($filename, "\u{2620}"); $stream = $this->factory->createStreamFromFile($filename, "\u{2620}");
} }
public function testCreateStreamFromFileCursorPosition()
{
$string = 'would you like some crumpets?';
$filename = $this->createTemporaryFile();
file_put_contents($filename, $string);
$resource = fopen($filename, 'r');
$fopenTell = ftell($resource);
fclose($resource);
$stream = $this->factory->createStreamFromFile($filename);
$this->assertSame($fopenTell, $stream->tell());
}
public function testCreateStreamFromResource() public function testCreateStreamFromResource()
{ {
$string = 'would you like some crumpets?'; $string = 'would you like some crumpets?';
...@@ -141,4 +168,24 @@ abstract class StreamFactoryTestCase extends TestCase ...@@ -141,4 +168,24 @@ abstract class StreamFactoryTestCase extends TestCase
$this->assertStream($stream, $string); $this->assertStream($stream, $string);
} }
public function testCreateStreamFromResourceCursorPosition()
{
$string = 'would you like some crumpets?';
$resource1 = $this->createTemporaryResource($string);
fseek($resource1, 0, SEEK_SET);
$stream1 = $this->factory->createStreamFromResource($resource1);
$this->assertSame(0, $stream1->tell());
$resource2 = $this->createTemporaryResource($string);
fseek($resource2, 0, SEEK_END);
$stream2 = $this->factory->createStreamFromResource($resource2);
$this->assertSame(strlen($string), $stream2->tell());
$resource3 = $this->createTemporaryResource($string);
fseek($resource3, 15, SEEK_SET);
$stream3 = $this->factory->createStreamFromResource($resource3);
$this->assertSame(15, $stream3->tell());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment