diff --git a/composer.json b/composer.json index 2750be19..9d816c9e 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "sort-packages": true, "platform": { - "php": "7.3.99" + "php": "7.4.99" } }, "extra": { @@ -34,7 +34,7 @@ } }, "require": { - "php": "^7.3 || ~8.0.0 || ~8.1.0", + "php": "^7.4 || ~8.0.0 || ~8.1.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0" }, @@ -44,10 +44,9 @@ "ext-gd": "*", "ext-libxml": "*", "http-interop/http-factory-tests": "^0.9.0", - "laminas/laminas-coding-standard": "~2.4.0", + "laminas/laminas-coding-standard": "^2.4.0", "php-http/psr7-integration-tests": "^1.1.1", - "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^9.5.23", "psalm/plugin-phpunit": "^0.17.0", "vimeo/psalm": "^4.24.0" }, @@ -56,7 +55,6 @@ "psr/http-message-implementation": "1.0" }, "conflict": { - "phpspec/prophecy": "<1.9.0", "zendframework/zend-diactoros": "*" }, "autoload": { diff --git a/composer.lock b/composer.lock index 9f2c57d3..2fb7e52d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab56f78e3052c428dda4d5d8e0cdb17b", + "content-hash": "045a64c18e2a12cc4d77ad3273984e8b", "packages": [ { "name": "psr/http-factory", @@ -907,25 +907,28 @@ }, { "name": "laminas/laminas-coding-standard", - "version": "2.3.0", + "version": "2.4.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-coding-standard.git", - "reference": "bcf6e07fe4690240be7beb6d884d0b0fafa6a251" + "reference": "eb076dd86aa93dd424856b150c9b6f76c1fdfabc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/bcf6e07fe4690240be7beb6d884d0b0fafa6a251", - "reference": "bcf6e07fe4690240be7beb6d884d0b0fafa6a251", + "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/eb076dd86aa93dd424856b150c9b6f76c1fdfabc", + "reference": "eb076dd86aa93dd424856b150c9b6f76c1fdfabc", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "php": "^7.3 || ^8.0", + "php": "^7.4 || ^8.0", "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.6", "webimpress/coding-standard": "^1.2" }, + "conflict": { + "phpstan/phpdoc-parser": ">=1.6.0" + }, "type": "phpcodesniffer-standard", "autoload": { "psr-4": { @@ -956,7 +959,7 @@ "type": "community_bridge" } ], - "time": "2021-05-29T15:53:59+00:00" + "time": "2022-08-24T17:45:47+00:00" }, { "name": "myclabs/deep-copy", @@ -1507,137 +1510,18 @@ }, "time": "2022-03-15T21:29:03+00:00" }, - { - "name": "phpspec/prophecy", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" - }, - "time": "2021-12-08T12:19:24+00:00" - }, - { - "name": "phpspec/prophecy-phpunit", - "version": "v2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy-phpunit.git", - "reference": "2d7a9df55f257d2cba9b1d0c0963a54960657177" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy-phpunit/zipball/2d7a9df55f257d2cba9b1d0c0963a54960657177", - "reference": "2d7a9df55f257d2cba9b1d0c0963a54960657177", - "shasum": "" - }, - "require": { - "php": "^7.3 || ^8", - "phpspec/prophecy": "^1.3", - "phpunit/phpunit": "^9.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\PhpUnit\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christophe Coevoet", - "email": "stof@notk.org" - } - ], - "description": "Integrating the Prophecy mocking library in PHPUnit test cases", - "homepage": "http://phpspec.net", - "keywords": [ - "phpunit", - "prophecy" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy-phpunit/issues", - "source": "https://github.com/phpspec/prophecy-phpunit/tree/v2.0.1" - }, - "time": "2020-07-09T08:33:42+00:00" - }, { "name": "phpstan/phpdoc-parser", - "version": "1.7.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "367a8d9d5f7da2a0136422d27ce8840583926955" + "reference": "981cc368a216c988e862a75e526b6076987d1b50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/367a8d9d5f7da2a0136422d27ce8840583926955", - "reference": "367a8d9d5f7da2a0136422d27ce8840583926955", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50", + "reference": "981cc368a216c988e862a75e526b6076987d1b50", "shasum": "" }, "require": { @@ -1647,7 +1531,6 @@ "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" @@ -1667,29 +1550,29 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.7.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1" }, - "time": "2022-08-09T12:23:23+00:00" + "time": "2022-05-05T11:32:40+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.15", + "version": "9.2.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" + "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2593003befdcc10db5e213f9f28814f5aa8ac073", + "reference": "2593003befdcc10db5e213f9f28814f5aa8ac073", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^4.14", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -1738,7 +1621,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.16" }, "funding": [ { @@ -1746,7 +1629,7 @@ "type": "github" } ], - "time": "2022-03-07T09:28:20+00:00" + "time": "2022-08-20T05:26:47+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1991,16 +1874,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.21", + "version": "9.5.23", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1" + "reference": "888556852e7e9bbeeedb9656afe46118765ade34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0e32b76be457de00e83213528f6bb37e2a38fcb1", - "reference": "0e32b76be457de00e83213528f6bb37e2a38fcb1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/888556852e7e9bbeeedb9656afe46118765ade34", + "reference": "888556852e7e9bbeeedb9656afe46118765ade34", "shasum": "" }, "require": { @@ -2015,7 +1898,6 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", @@ -2033,9 +1915,6 @@ "sebastian/type": "^3.0", "sebastian/version": "^3.0.2" }, - "require-dev": { - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { "ext-soap": "*", "ext-xdebug": "*" @@ -2077,7 +1956,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.21" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.23" }, "funding": [ { @@ -2089,7 +1968,7 @@ "type": "github" } ], - "time": "2022-06-19T12:14:25+00:00" + "time": "2022-08-22T14:01:36+00:00" }, { "name": "psalm/plugin-phpunit", @@ -4485,7 +4364,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.3 || ~8.0.0 || ~8.1.0" + "php": "^7.4 || ~8.0.0 || ~8.1.0" }, "platform-dev": { "ext-curl": "*", @@ -4494,7 +4373,7 @@ "ext-libxml": "*" }, "platform-overrides": { - "php": "7.3.99" + "php": "7.4.99" }, "plugin-api-version": "2.3.0" } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e57e265e..46c3d8d5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + null|callable diff --git a/test/RelativeStreamTest.php b/test/RelativeStreamTest.php index 4cd79d32..4802a4f4 100644 --- a/test/RelativeStreamTest.php +++ b/test/RelativeStreamTest.php @@ -7,8 +7,6 @@ use Laminas\Diactoros\RelativeStream; use Laminas\Diactoros\Stream; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; -use Prophecy\PhpUnit\ProphecyTrait; use RuntimeException; use const SEEK_SET; @@ -18,144 +16,142 @@ */ class RelativeStreamTest extends TestCase { - use ProphecyTrait; - public function testToString(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->isSeekable()->willReturn(true); - $decorated->tell()->willReturn(100); - $decorated->seek(100, SEEK_SET)->shouldBeCalled(); - $decorated->getContents()->shouldBeCalled()->willReturn('foobarbaz'); + $decorated = $this->createMock(Stream::class); + $decorated->method('isSeekable')->willReturn(true); + $decorated->method('tell')->willReturn(100); + $decorated->expects(self::once())->method('seek')->with(100, SEEK_SET); + $decorated->expects(self::once())->method('getContents')->willReturn('foobarbaz'); - $stream = new RelativeStream($decorated->reveal(), 100); + $stream = new RelativeStream($decorated, 100); $ret = $stream->__toString(); $this->assertSame('foobarbaz', $ret); } public function testClose(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->close()->shouldBeCalled(); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('close'); + $stream = new RelativeStream($decorated, 100); $stream->close(); } public function testDetach(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->detach()->shouldBeCalled()->willReturn(250); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('detach')->willReturn(250); + $stream = new RelativeStream($decorated, 100); $ret = $stream->detach(); $this->assertSame(250, $ret); } public function testGetSize(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->getSize()->shouldBeCalled()->willReturn(250); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('getSize')->willReturn(250); + $stream = new RelativeStream($decorated, 100); $ret = $stream->getSize(); $this->assertSame(150, $ret); } public function testTell(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->tell()->shouldBeCalled()->willReturn(188); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('tell')->willReturn(188); + $stream = new RelativeStream($decorated, 100); $ret = $stream->tell(); $this->assertSame(88, $ret); } public function testIsSeekable(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->isSeekable()->shouldBeCalled()->willReturn(true); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('isSeekable')->willReturn(true); + $stream = new RelativeStream($decorated, 100); $ret = $stream->isSeekable(); $this->assertSame(true, $ret); } public function testIsWritable(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->isWritable()->shouldBeCalled()->willReturn(true); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('isWritable')->willReturn(true); + $stream = new RelativeStream($decorated, 100); $ret = $stream->isWritable(); $this->assertSame(true, $ret); } public function testIsReadable(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->isReadable()->shouldBeCalled()->willReturn(false); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('isReadable')->willReturn(false); + $stream = new RelativeStream($decorated, 100); $ret = $stream->isReadable(); $this->assertSame(false, $ret); } public function testSeek(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->seek(126, SEEK_SET)->shouldBeCalled(); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('seek')->with(126, SEEK_SET); + $stream = new RelativeStream($decorated, 100); $this->assertNull($stream->seek(26)); } public function testRewind(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->seek(100, SEEK_SET)->shouldBeCalled(); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('seek')->with(100, SEEK_SET); + $stream = new RelativeStream($decorated, 100); $this->assertNull($stream->rewind()); } public function testWrite(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->tell()->willReturn(100); - $decorated->write("foobaz")->shouldBeCalled()->willReturn(6); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->method('tell')->willReturn(100); + $decorated->expects(self::once())->method('write')->with('foobaz')->willReturn(6); + $stream = new RelativeStream($decorated, 100); $ret = $stream->write("foobaz"); $this->assertSame(6, $ret); } public function testRead(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->tell()->willReturn(100); - $decorated->read(3)->shouldBeCalled()->willReturn("foo"); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->method('tell')->willReturn(100); + $decorated->expects(self::once())->method('read')->with(3)->willReturn('foo'); + $stream = new RelativeStream($decorated, 100); $ret = $stream->read(3); $this->assertSame("foo", $ret); } public function testGetContents(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->tell()->willReturn(100); - $decorated->getContents()->shouldBeCalled()->willReturn("foo"); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->method('tell')->willReturn(100); + $decorated->expects(self::once())->method('getContents')->willReturn('foo'); + $stream = new RelativeStream($decorated, 100); $ret = $stream->getContents(); $this->assertSame("foo", $ret); } public function testGetMetadata(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->getMetadata("bar")->shouldBeCalled()->willReturn("foo"); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('getMetadata')->with('bar')->willReturn('foo'); + $stream = new RelativeStream($decorated, 100); $ret = $stream->getMetadata("bar"); $this->assertSame("foo", $ret); } public function testWriteRaisesExceptionWhenPointerIsBehindOffset(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->tell()->shouldBeCalled()->willReturn(0); - $decorated->write("foobaz")->shouldNotBeCalled(); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('tell')->willReturn(0); + $decorated->expects(self::never())->method('write')->with('foobaz'); + $stream = new RelativeStream($decorated, 100); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid pointer position'); @@ -165,10 +161,10 @@ public function testWriteRaisesExceptionWhenPointerIsBehindOffset(): void public function testReadRaisesExceptionWhenPointerIsBehindOffset(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->tell()->shouldBeCalled()->willReturn(0); - $decorated->read(3)->shouldNotBeCalled(); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('tell')->willReturn(0); + $decorated->expects(self::never())->method('read')->with(3); + $stream = new RelativeStream($decorated, 100); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid pointer position'); @@ -178,10 +174,10 @@ public function testReadRaisesExceptionWhenPointerIsBehindOffset(): void public function testGetContentsRaisesExceptionWhenPointerIsBehindOffset(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->tell()->shouldBeCalled()->willReturn(0); - $decorated->getContents()->shouldNotBeCalled(); - $stream = new RelativeStream($decorated->reveal(), 100); + $decorated = $this->createMock(Stream::class); + $decorated->expects(self::once())->method('tell')->willReturn(0); + $decorated->expects(self::never())->method('getContents'); + $stream = new RelativeStream($decorated, 100); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid pointer position'); @@ -191,13 +187,13 @@ public function testGetContentsRaisesExceptionWhenPointerIsBehindOffset(): void public function testCanReadContentFromNotSeekableResource(): void { - $decorated = $this->prophesize(Stream::class); - $decorated->isSeekable()->willReturn(false); - $decorated->seek(Argument::any())->shouldNotBeCalled(); - $decorated->tell()->willReturn(3); - $decorated->getContents()->willReturn('CONTENTS'); + $decorated = $this->createMock(Stream::class); + $decorated->method('isSeekable')->willReturn(false); + $decorated->expects(self::never())->method('seek'); + $decorated->method('tell')->willReturn(3); + $decorated->method('getContents')->willReturn('CONTENTS'); - $stream = new RelativeStream($decorated->reveal(), 3); + $stream = new RelativeStream($decorated, 3); $this->assertSame('CONTENTS', $stream->__toString()); } } diff --git a/test/Response/HtmlResponseTest.php b/test/Response/HtmlResponseTest.php index a794ae2a..614ff1c0 100644 --- a/test/Response/HtmlResponseTest.php +++ b/test/Response/HtmlResponseTest.php @@ -7,13 +7,10 @@ use InvalidArgumentException; use Laminas\Diactoros\Response\HtmlResponse; use PHPUnit\Framework\TestCase; -use Prophecy\PhpUnit\ProphecyTrait; use Psr\Http\Message\StreamInterface; class HtmlResponseTest extends TestCase { - use ProphecyTrait; - public function testConstructorAcceptsHtmlString(): void { $body = 'Uh oh not found'; @@ -50,8 +47,7 @@ public function testConstructorAllowsPassingHeaders(): void public function testAllowsStreamsForResponseBody(): void { - $stream = $this->prophesize(StreamInterface::class); - $body = $stream->reveal(); + $body = $this->createStub(StreamInterface::class); $response = new HtmlResponse($body); $this->assertSame($body, $response->getBody()); }