From 59a14adf11fe6565899c81a86f779a73e6c220ec Mon Sep 17 00:00:00 2001 From: fire015 Date: Tue, 19 Jan 2021 14:47:07 +0000 Subject: [PATCH] Update tests for PHP 8 --- .gitignore | 5 ++-- .travis.yml | 4 +-- CHANGELOG.md | 4 +++ README.md | 2 +- composer.json | 4 +-- phpunit.xml.dist | 33 ++++++++-------------- src/Flintstone.php | 2 +- tests/Cache/ArrayCacheTest.php | 2 +- tests/ConfigTest.php | 6 ++-- tests/DatabaseTest.php | 7 ++--- tests/FlintstoneTest.php | 3 +- tests/Formatter/JsonFormatterTest.php | 6 ++-- tests/Formatter/SerializeFormatterTest.php | 2 +- tests/LineTest.php | 2 +- tests/ValidationTest.php | 6 ++-- 15 files changed, 37 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 6880b43..c1d6dc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /vendor -/docs -/build composer.lock -.idea \ No newline at end of file +.idea +.phpunit.result.cache \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5eae83b..6650897 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,9 @@ language: php sudo: false php: - - 7.0 - - 7.1 - - 7.2 - 7.3 - 7.4 + - 8.0 install: - travis_retry composer install --no-interaction --prefer-dist --no-suggest diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b222ea..8d4a97a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Change Log ========== +### 19/01/2021 - 2.3 +* Bump minimum PHP version to 7.3 +* Update PHPUnit to version 9 (ensure Flintstone is compatible with PHP 8) + ### 12/03/2019 - 2.2 * Bump minimum PHP version to 7.0 * Update PHPUnit to version 6 diff --git a/README.md b/README.md index 8ac1e19..7abfb45 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ $users = new Flintstone('users', ['dir' => '/path/to/database/dir/']); ### Requirements -- PHP 7.0+ +- PHP 7.3+ ### Data types diff --git a/composer.json b/composer.json index 674bc61..d1edeec 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=7.0" + "php": ">=7.3" }, "autoload": { "psr-4": { @@ -20,6 +20,6 @@ } }, "require-dev" : { - "phpunit/phpunit": "^6" + "phpunit/phpunit": "^9" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a9c62fe..db726eb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,13 @@ - - - - ./src - - - - - - ./tests - - + + + + ./src + + + + + ./tests + + diff --git a/src/Flintstone.php b/src/Flintstone.php index e2c21e9..37e3e33 100644 --- a/src/Flintstone.php +++ b/src/Flintstone.php @@ -9,7 +9,7 @@ class Flintstone * * @var string */ - const VERSION = '2.2'; + const VERSION = '2.3'; /** * Database class. diff --git a/tests/Cache/ArrayCacheTest.php b/tests/Cache/ArrayCacheTest.php index 868796a..839dbb7 100644 --- a/tests/Cache/ArrayCacheTest.php +++ b/tests/Cache/ArrayCacheTest.php @@ -9,7 +9,7 @@ class ArrayCacheTest extends \PHPUnit\Framework\TestCase */ private $cache; - protected function setUp() + protected function setUp(): void { $this->cache = new ArrayCache(); } diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index c941ab4..e0ef3c3 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -55,30 +55,30 @@ public function setValidFormatter() /** * @test - * @expectedException Flintstone\Exception */ public function setInvalidFormatter() { + $this->expectException(\Flintstone\Exception::class); $config = new Config(); $config->setFormatter(new self()); } /** * @test - * @expectedException Flintstone\Exception */ public function invalidDirSet() { + $this->expectException(\Flintstone\Exception::class); $config = new Config(); $config->setDir('/x/y/z/foo'); } /** * @test - * @expectedException Flintstone\Exception */ public function invalidCacheSet() { + $this->expectException(\Flintstone\Exception::class); $config = new Config(); $config->setCache(new self()); } diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index 6120170..2f274e0 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -11,7 +11,7 @@ class DatabaseTest extends \PHPUnit\Framework\TestCase */ private $db; - protected function setUp() + protected function setUp(): void { $config = new Config([ 'dir' => __DIR__, @@ -20,7 +20,7 @@ protected function setUp() $this->db = new Database('test', $config); } - protected function tearDown() + protected function tearDown(): void { if (is_file($this->db->getPath())) { unlink($this->db->getPath()); @@ -29,11 +29,10 @@ protected function tearDown() /** * @test - * @expectedException Flintstone\Exception - * @expectedExceptionMessage Invalid characters in database name */ public function databaseHasInvalidName() { + $this->expectException(\Flintstone\Exception::class); $config = new Config(); new Database('test!123', $config); } diff --git a/tests/FlintstoneTest.php b/tests/FlintstoneTest.php index 474f49a..21c28a2 100644 --- a/tests/FlintstoneTest.php +++ b/tests/FlintstoneTest.php @@ -20,11 +20,10 @@ public function testGetDatabaseAndConfig() /** * @test - * @expectedException \Flintstone\Exception - * @expectedExceptionMessage Invalid characters in key */ public function keyHasInvalidName() { + $this->expectException(\Flintstone\Exception::class); $db = new Flintstone('test', []); $db->get('test!123'); } diff --git a/tests/Formatter/JsonFormatterTest.php b/tests/Formatter/JsonFormatterTest.php index d97fede..39f4fef 100644 --- a/tests/Formatter/JsonFormatterTest.php +++ b/tests/Formatter/JsonFormatterTest.php @@ -9,7 +9,7 @@ class JsonFormatterTest extends \PHPUnit\Framework\TestCase */ private $formatter; - protected function setUp() + protected function setUp(): void { $this->formatter = new JsonFormatter(); } @@ -45,19 +45,19 @@ public function decodesAnObject() /** * @test - * @expectedException \Flintstone\Exception */ public function encodingInvalidDataThrowsException() { + $this->expectException(\Flintstone\Exception::class); $this->formatter->encode(chr(241)); } /** * @test - * @expectedException \Flintstone\Exception */ public function decodingInvalidDataThrowsException() { + $this->expectException(\Flintstone\Exception::class); $this->formatter->decode('{'); } diff --git a/tests/Formatter/SerializeFormatterTest.php b/tests/Formatter/SerializeFormatterTest.php index cf2fd87..2d8d06e 100644 --- a/tests/Formatter/SerializeFormatterTest.php +++ b/tests/Formatter/SerializeFormatterTest.php @@ -9,7 +9,7 @@ class SerializeFormatterTest extends \PHPUnit\Framework\TestCase */ private $formatter; - protected function setUp() + protected function setUp(): void { $this->formatter = new SerializeFormatter(); } diff --git a/tests/LineTest.php b/tests/LineTest.php index e29bc50..746d3db 100644 --- a/tests/LineTest.php +++ b/tests/LineTest.php @@ -9,7 +9,7 @@ class LineTest extends \PHPUnit\Framework\TestCase */ private $line; - protected function setUp() + protected function setUp(): void { $this->line = new Line('foo=bar'); } diff --git a/tests/ValidationTest.php b/tests/ValidationTest.php index b11f912..1fe1ff1 100644 --- a/tests/ValidationTest.php +++ b/tests/ValidationTest.php @@ -6,21 +6,19 @@ class ValidationTest extends \PHPUnit\Framework\TestCase { /** * @test - * @expectedException Flintstone\Exception - * @expectedExceptionMessage Invalid characters in key */ public function validateKey() { + $this->expectException(\Flintstone\Exception::class); Validation::validateKey('test!123'); } /** * @test - * @expectedException Flintstone\Exception - * @expectedExceptionMessage Invalid characters in database name */ public function validateDatabaseName() { + $this->expectException(\Flintstone\Exception::class); Validation::validateDatabaseName('test!123'); } }