Skip to content

Commit

Permalink
Update tests for PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
fire015 committed Jan 19, 2021
1 parent 6d57c9f commit 59a14ad
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 51 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/vendor
/docs
/build
composer.lock
.idea
.idea
.phpunit.result.cache
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $users = new Flintstone('users', ['dir' => '/path/to/database/dir/']);

### Requirements

- PHP 7.0+
- PHP 7.3+

### Data types

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
}
],
"require": {
"php": ">=7.0"
"php": ">=7.3"
},
"autoload": {
"psr-4": {
"Flintstone\\": "src/"
}
},
"require-dev" : {
"phpunit/phpunit": "^6"
"phpunit/phpunit": "^9"
}
}
33 changes: 11 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<testsuites>
<testsuite name="Flintstone Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Flintstone Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/Flintstone.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Flintstone
*
* @var string
*/
const VERSION = '2.2';
const VERSION = '2.3';

/**
* Database class.
Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/ArrayCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ArrayCacheTest extends \PHPUnit\Framework\TestCase
*/
private $cache;

protected function setUp()
protected function setUp(): void
{
$this->cache = new ArrayCache();
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
7 changes: 3 additions & 4 deletions tests/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DatabaseTest extends \PHPUnit\Framework\TestCase
*/
private $db;

protected function setUp()
protected function setUp(): void
{
$config = new Config([
'dir' => __DIR__,
Expand All @@ -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());
Expand All @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/FlintstoneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Formatter/JsonFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class JsonFormatterTest extends \PHPUnit\Framework\TestCase
*/
private $formatter;

protected function setUp()
protected function setUp(): void
{
$this->formatter = new JsonFormatter();
}
Expand Down Expand Up @@ -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('{');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Formatter/SerializeFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SerializeFormatterTest extends \PHPUnit\Framework\TestCase
*/
private $formatter;

protected function setUp()
protected function setUp(): void
{
$this->formatter = new SerializeFormatter();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/LineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
6 changes: 2 additions & 4 deletions tests/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit 59a14ad

Please sign in to comment.