From cae1a9485912d62b90a34cb9da2fdba699bc9011 Mon Sep 17 00:00:00 2001 From: Oscar Otero Date: Thu, 3 Dec 2020 02:13:50 +0100 Subject: [PATCH] new version --- CHANGELOG.md | 5 ++++ tests/ReportingLoggerTest.php | 53 ++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc3b9c..48e7f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.0.1] - 2020-12-03 +### Added +- Support for PHP 8.0 + ## [2.0.0] - 2019-11-30 ### Added - Added a second argument to the constructor to set a `ResponseFactoryInterface` @@ -21,5 +25,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## 1.0.0 - 2018-06-07 First version +[2.0.1]: https://github.com/middlewares/reporting-logger/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/middlewares/reporting-logger/compare/v1.1.0...v2.0.0 [1.1.0]: https://github.com/middlewares/reporting-logger/compare/v1.0.0...v1.1.0 diff --git a/tests/ReportingLoggerTest.php b/tests/ReportingLoggerTest.php index 7e50418..c7f952e 100644 --- a/tests/ReportingLoggerTest.php +++ b/tests/ReportingLoggerTest.php @@ -11,6 +11,19 @@ class ReportingLoggerTest extends TestCase { + /** + * phpunit 8 support + */ + public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void + { + if (method_exists(parent::class, 'assertMatchesRegularExpression')) { + parent::assertMatchesRegularExpression($pattern, $string, $message); + return; + } + + self::assertRegExp($pattern, $string, $message); + } + private function createLogger(): array { $logs = fopen('php://temp', 'r+'); @@ -36,9 +49,9 @@ function () { rewind($logs); - $this->assertSame(200, $response->getStatusCode()); - $this->assertEmpty((string) $response->getBody()); - $this->assertMatchesRegularExpression('#.* test.ERROR: Reporting .*#', stream_get_contents($logs)); + self::assertSame(200, $response->getStatusCode()); + self::assertEmpty((string) $response->getBody()); + self::assertMatchesRegularExpression('#.* test.ERROR: Reporting .*#', stream_get_contents($logs)); } public function testCustomMessage() @@ -57,9 +70,9 @@ function () { rewind($logs); - $this->assertSame(200, $response->getStatusCode()); - $this->assertEmpty((string) $response->getBody()); - $this->assertMatchesRegularExpression('#.* test.ERROR: Csp Error .*#', stream_get_contents($logs)); + self::assertSame(200, $response->getStatusCode()); + self::assertEmpty((string) $response->getBody()); + self::assertMatchesRegularExpression('#.* test.ERROR: Csp Error .*#', stream_get_contents($logs)); } public function testCustomMessageWithVariable() @@ -78,9 +91,9 @@ function () { rewind($logs); - $this->assertSame(200, $response->getStatusCode()); - $this->assertEmpty((string) $response->getBody()); - $this->assertMatchesRegularExpression('#.* test.ERROR: Error: Foo in %{var2} and \[1,2,3\] .*#', stream_get_contents($logs)); + self::assertSame(200, $response->getStatusCode()); + self::assertEmpty((string) $response->getBody()); + self::assertMatchesRegularExpression('#.* test.ERROR: Error: Foo in %{var2} and \[1,2,3\] .*#', stream_get_contents($logs)); } public function testCustomPath() @@ -99,9 +112,9 @@ function () { rewind($logs); - $this->assertSame(200, $response->getStatusCode()); - $this->assertEmpty((string) $response->getBody()); - $this->assertMatchesRegularExpression('#.* test.ERROR: Reporting .*#', stream_get_contents($logs)); + self::assertSame(200, $response->getStatusCode()); + self::assertEmpty((string) $response->getBody()); + self::assertMatchesRegularExpression('#.* test.ERROR: Reporting .*#', stream_get_contents($logs)); } public function testMethod() @@ -120,8 +133,8 @@ function () { rewind($logs); - $this->assertEquals('no reporting', (string) $response->getBody()); - $this->assertEmpty(stream_get_contents($logs)); + self::assertEquals('no reporting', (string) $response->getBody()); + self::assertEmpty(stream_get_contents($logs)); } public function testPath() @@ -140,8 +153,8 @@ function () { rewind($logs); - $this->assertEquals('no reporting', (string) $response->getBody()); - $this->assertEmpty(stream_get_contents($logs)); + self::assertEquals('no reporting', (string) $response->getBody()); + self::assertEmpty(stream_get_contents($logs)); } public function testEmptyData() @@ -159,8 +172,8 @@ function () { rewind($logs); - $this->assertEquals('no reporting', (string) $response->getBody()); - $this->assertEmpty(stream_get_contents($logs)); + self::assertEquals('no reporting', (string) $response->getBody()); + self::assertEmpty(stream_get_contents($logs)); } public function testCspReport() @@ -193,7 +206,7 @@ function () { rewind($logs); - $this->assertEmpty((string) $response->getBody()); - $this->assertMatchesRegularExpression('#.* test.ERROR: Reporting \{"csp-report"\:\{.*#', stream_get_contents($logs)); + self::assertEmpty((string) $response->getBody()); + self::assertMatchesRegularExpression('#.* test.ERROR: Reporting \{"csp-report"\:\{.*#', stream_get_contents($logs)); } }