Skip to content

Commit 4aeed0d

Browse files
authored
Upgrade to PHP 8.1 (#6)
* Updated PHP requirements to >=8.0 * Removed Scrutinizer integration * Updated Codeception to ^5 and replaced `zendframework/zend-diactoros` with `nyholm/psr7` * Updated `mindplay/middleman` to ^4 * Replaced Travis with Github Actions
1 parent a6e8d64 commit 4aeed0d

17 files changed

+126
-131
lines changed

.github/workflows/test.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Codeception tests
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: ${{matrix.operating-system}}, PHP ${{ matrix.php }}
8+
9+
runs-on: ${{ matrix.operating-system }}
10+
11+
strategy:
12+
matrix:
13+
operating-system: [ ubuntu-latest, ubuntu-20.04 ]
14+
php: [ '8.0', '8.1' ]
15+
16+
steps:
17+
- uses: actions/checkout@master
18+
19+
- name: Setup PHP
20+
uses: nanasess/setup-php@master
21+
with:
22+
php-version: ${{ matrix.php }}
23+
24+
- name: Install dependencies
25+
run: composer install
26+
27+
- name: Run tests
28+
run: php vendor/bin/codecept run

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
/vendor
44
/tests/_output/
55
/tests/_support/_generated/**/*
6-
/tests/*.suite.yml

.scrutinizer.yml

-4
This file was deleted.

.travis.yml

-15
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kodus/chrome-logger
22
===================
33

4-
[![PHP Version](https://img.shields.io/badge/php-7.0%2B-blue.svg)](https://packagist.org/packages/kodus/chrome-logger)
4+
[![PHP Version](https://img.shields.io/badge/php-8.0%2B-blue.svg)](https://packagist.org/packages/kodus/chrome-logger)
55
[![Build Status](https://travis-ci.org/kodus/chrome-logger.svg?branch=master)](https://travis-ci.org/kodus/chrome-logger)
66
[![Code Coverage](https://scrutinizer-ci.com/g/kodus/chrome-logger/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/kodus/chrome-logger/?branch=master)
77

codeception.dist.yml codeception.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
actor: Tester
22
paths:
33
tests: tests
4-
log: tests/_output
4+
output: tests/_output
55
data: tests/_data
66
support: tests/_support
77
envs: tests/_envs
88
settings:
9-
bootstrap: _bootstrap.php
10-
colors: false
119
memory_limit: 1024M
1210
extensions:
1311
enabled:

composer.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.0",
19+
"php": ">=8.0",
2020
"psr/log": "^1",
2121
"psr/http-message": "^1",
2222
"psr/http-server-middleware": "^1"
2323
},
2424
"require-dev": {
25-
"codeception/codeception": "^2",
26-
"mockery/mockery": "^0.9",
27-
"zendframework/zend-diactoros": "^1.8.5",
28-
"mindplay/middleman": "^3.0.3"
25+
"codeception/codeception": "^5",
26+
"codeception/module-asserts": "^3",
27+
"mockery/mockery": "^1.5",
28+
"nyholm/psr7": "^1.5",
29+
"mindplay/middleman": "^4"
2930
},
3031
"autoload": {
3132
"psr-4": {
@@ -38,4 +39,4 @@
3839
"Kodus\\Logging\\Test\\Unit\\": "tests/unit/"
3940
}
4041
}
41-
}
42+
}

tests/Fixtures/Bar.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Kodus\Logging\Test\Fixtures;
4+
5+
class Bar extends Foo
6+
{
7+
public $bat = "BAT";
8+
}

tests/Fixtures/Baz.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Kodus\Logging\Test\Fixtures;
4+
5+
class Baz
6+
{
7+
public $foo;
8+
public $bar;
9+
public $baz;
10+
11+
public function __construct()
12+
{
13+
$this->foo = new Foo();
14+
$this->bar = new Bar();
15+
$this->baz = $this;
16+
}
17+
}

tests/Fixtures/Foo.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Kodus\Logging\Test\Fixtures;
4+
5+
class Foo
6+
{
7+
public $foo = "FOO";
8+
protected $bar = "BAR";
9+
private $baz = "BAZ";
10+
}

tests/Mocks/MockMiddleware.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Kodus\Logging\Test\Mocks;
4+
5+
use Kodus\Logging\ChromeLogger;
6+
use Nyholm\Psr7\Response;
7+
use Psr\Http\Message\ResponseInterface;
8+
use Psr\Http\Message\ServerRequestInterface;
9+
use Psr\Http\Server\MiddlewareInterface;
10+
use Psr\Http\Server\RequestHandlerInterface;
11+
12+
class MockMiddleware implements MiddlewareInterface
13+
{
14+
/**
15+
* @var ChromeLogger
16+
*/
17+
private $logger;
18+
19+
public function __construct(ChromeLogger $logger)
20+
{
21+
$this->logger = $logger;
22+
}
23+
24+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
25+
{
26+
$this->logger->notice("running mock middleware");
27+
28+
return new Response(headers: ['Content-Type' => 'text/plain'], body: "Hello");
29+
}
30+
}

tests/_bootstrap.php

-2
This file was deleted.

tests/example.php

+2-27
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22

33
use Kodus\Logging\ChromeLogger;
4+
use Kodus\Logging\Test\Fixtures\Baz;
45

56
require dirname(__DIR__) . '/vendor/autoload.php';
67

78
// ChromeLogger output example - run on a web-server and open in a browser.
89

9-
function foo()
10+
function foo(): void
1011
{
1112
bar();
1213
}
@@ -16,32 +17,6 @@ function bar()
1617
throw new RuntimeException("ouch!"); // for stack-trace test!
1718
}
1819

19-
class Foo
20-
{
21-
public $foo = "FOO";
22-
protected $bar = "BAR";
23-
private $baz = "BAZ";
24-
}
25-
26-
class Bar extends Foo
27-
{
28-
public $bat = "BAT";
29-
}
30-
31-
class Baz
32-
{
33-
public $foo;
34-
public $bar;
35-
public $baz;
36-
37-
public function __construct()
38-
{
39-
$this->foo = new Foo();
40-
$this->bar = new Bar();
41-
$this->baz = $this;
42-
}
43-
}
44-
4520
try {
4621
foo();
4722
} catch (RuntimeException $e) {

tests/unit.suite.dist.yml tests/unit.suite.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class_name: UnitTester
1+
actor: UnitTester
22
modules:
33
enabled:
44
- Asserts

tests/unit/ChromeLoggerCest.php

+17-41
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,20 @@
33
namespace Kodus\Logging\Test\Unit;
44

55
use Codeception\Util\FileSystem;
6-
use function json_decode;
76
use Kodus\Logging\ChromeLogger;
7+
use Kodus\Logging\Test\Fixtures\Bar;
8+
use Kodus\Logging\Test\Fixtures\Baz;
9+
use Kodus\Logging\Test\Fixtures\Foo;
810
use Mockery;
911
use Mockery\MockInterface;
12+
use Nyholm\Psr7\Response;
1013
use Psr\Http\Message\ResponseInterface;
1114
use RuntimeException;
12-
use function str_repeat;
1315
use UnitTester;
14-
use Zend\Diactoros\Response;
15-
16-
class Foo
17-
{
18-
public $foo = "FOO";
19-
protected $bar = "BAR";
20-
private $baz = "BAZ";
21-
}
22-
23-
class Bar extends Foo
24-
{
25-
public $bat = "BAT";
26-
}
27-
28-
class Baz
29-
{
30-
public $foo;
31-
public $bar;
32-
public $baz;
33-
34-
public function __construct()
35-
{
36-
$this->foo = new Foo();
37-
$this->bar = new Bar();
38-
$this->baz = $this;
39-
}
40-
}
4116

4217
class ChromeLoggerCest
4318
{
44-
public function writeLogMessages(UnitTester $I)
19+
public function writeLogMessages(UnitTester $I): void
4520
{
4621
$logger = new ChromeLogger();
4722

@@ -73,7 +48,7 @@ public function writeLogMessages(UnitTester $I)
7348
);
7449
}
7550

76-
public function serializeContextValues(UnitTester $I)
51+
public function serializeContextValues(UnitTester $I): void
7752
{
7853
$logger = new ChromeLogger();
7954

@@ -129,7 +104,7 @@ public function serializeContextValues(UnitTester $I)
129104
fclose($resource);
130105
}
131106

132-
public function obtainStackTrace(UnitTester $I)
107+
public function obtainStackTrace(UnitTester $I): void
133108
{
134109
try {
135110
$this->foo();
@@ -157,7 +132,7 @@ public function obtainStackTrace(UnitTester $I)
157132
], $data["rows"]);
158133
}
159134

160-
public function renderTables(UnitTester $I)
135+
public function renderTables(UnitTester $I): void
161136
{
162137
$logger = new ChromeLogger();
163138

@@ -178,14 +153,14 @@ public function renderTables(UnitTester $I)
178153
], $data["rows"]);
179154
}
180155

181-
public function truncateExcessiveLogData(UnitTester $I)
156+
public function truncateExcessiveLogData(UnitTester $I): void
182157
{
183158
$logger = new ChromeLogger();
184159

185160
$logger->setLimit(10*1024);
186161

187162
for ($n=0; $n<200; $n++) {
188-
$message = str_repeat("0123456789", rand(1,20)); // between 10 and 200 bytes
163+
$message = str_repeat("0123456789", rand(1, 20)); // between 10 and 200 bytes
189164

190165
$logger->debug($message);
191166
}
@@ -195,7 +170,7 @@ public function truncateExcessiveLogData(UnitTester $I)
195170
$I->assertEquals(ChromeLogger::LIMIT_WARNING, end($data["rows"])[0][0]);
196171
}
197172

198-
public function persistToLocalFiles(UnitTester $I)
173+
public function persistToLocalFiles(UnitTester $I): void
199174
{
200175
$logger = new class extends ChromeLogger
201176
{
@@ -242,7 +217,7 @@ protected function getTime(): int
242217
$logger->debug(str_repeat("0123456789", 20));
243218
}
244219

245-
$response = new Response(fopen("php://temp", "rw+"));
220+
$response = new Response(body: fopen("php://temp", "rw+"));
246221

247222
$response = $logger->writeToResponse($response);
248223

@@ -278,7 +253,7 @@ protected function getTime(): int
278253
"previous {$num_files} log-files should be garbage-collected");
279254
}
280255

281-
public function allowMultipleLocationHeaders(UnitTester $I)
256+
public function allowMultipleLocationHeaders(UnitTester $I): void
282257
{
283258
$logger = new ChromeLogger();
284259

@@ -294,7 +269,7 @@ public function allowMultipleLocationHeaders(UnitTester $I)
294269

295270
$logger->info("TEST");
296271

297-
$response = new Response(fopen("php://temp", "rw+"));
272+
$response = new Response(body: fopen("php://temp", "rw+"));
298273

299274
$response = $response->withHeader("X-ServerLog-Location", "/foo");
300275

@@ -312,7 +287,7 @@ public function allowMultipleLocationHeaders(UnitTester $I)
312287
*
313288
* @return array
314289
*/
315-
private function extractResult(ChromeLogger $logger)
290+
private function extractResult(ChromeLogger $logger): array
316291
{
317292
/**
318293
* @var MockInterface|ResponseInterface $response
@@ -336,7 +311,8 @@ private function extractResult(ChromeLogger $logger)
336311
return json_decode(base64_decode($calls[0][1]), true);
337312
}
338313

339-
private function foo() {
314+
private function foo(): void
315+
{
340316
$this->bar();
341317
}
342318

0 commit comments

Comments
 (0)