Skip to content

Commit

Permalink
Merge pull request #40 from jobcloud/feat/add-support-for-php8
Browse files Browse the repository at this point in the history
  • Loading branch information
Taluu authored May 6, 2021
2 parents f62856a + 01fadc5 commit 410b9a5
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 164 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ coveralls-upload.json
vendor
composer.lock
bin

8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- 7.3
- 7.4
- 8.0

sudo: false

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Totem
\\\\////
|.)(.|
| || | Changeset calculator between two state of a data
\(__)/ Requires PHP 5.4 ; Compatible PHP 5.5, PHP 5.6, PHP 7 and HHVM
\(__)/ Compatibile with PHP 7.3, 7.4 or 8.0
|-..-|
|o\/o|
.----\ /----.
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@
},

"require": {
"php": "^5.4 || ^7.0",
"php": "^7.3 || ^8.0",
"symfony/property-access": "^2.5 || ^3.0"
},

"extra": {
"branch-alias": {
"dev-master": "1.5.0-dev"
}
},

"require-dev": {
"phpunit/phpunit": "^9.5"
}
}
36 changes: 11 additions & 25 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "./vendor/autoload.php">

<testsuites>
<testsuite name="Project Test Suite">
<directory>./test</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Project Test Suite">
<directory>./test</directory>
</testsuite>
</testsuites>
</phpunit>

9 changes: 0 additions & 9 deletions src/AbstractSnapshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ final public function getDataKeys()
return array_keys($this->getComparableData());
}

/**
* Clone this object
*
* @codeCoverageIgnore
*/
final private function __clone()
{
}

/** {@inheritDoc} */
final public function offsetExists($offset)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
use Totem\Change\Addition;
use Totem\Change\Modification;

use Totem\SetInterface;
use Totem\AbstractSnapshot;
use Totem\Snapshot\CollectionSnapshot;

/**
Expand Down
2 changes: 0 additions & 2 deletions src/SetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Totem;

use Totem\AbstractSnapshot;

/**
* Represents a set of changes between two data
*
Expand Down
6 changes: 3 additions & 3 deletions test/AbstractChangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

namespace Totem;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

class AbstractChangeTest extends PHPUnit_Framework_TestCase
class AbstractChangeTest extends TestCase
{
/** @var Totem\AbstractChange */
private $mock;

public function setUp()
protected function setUp(): void
{
$this->mock = $this->getMockForAbstractClass('Totem\\AbstractChange', ['old', 'new']);
}
Expand Down
56 changes: 27 additions & 29 deletions test/AbstractSnapshotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@

namespace Totem;

use BadMethodCallException;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use ReflectionProperty;
use Totem\Exception\IncomparableDataException;

use PHPUnit_Framework_TestCase;

class AbstractSnapshotTest extends PHPUnit_Framework_TestCase
class AbstractSnapshotTest extends TestCase
{
/**
* @expectedException Totem\Exception\IncomparableDataException
* @expectedExceptionMessage This data is not comparable with the base
*/
public function testDiffIncomparable()
{
$this->expectException(IncomparableDataException::class);
$this->expectExceptionMessage('This data is not comparable with the base');

$snapshot = new Snapshot(['comparable' => false]);
$snapshot->diff($snapshot);
}

/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage The computed data is not an array, "string" given
*/
public function testComparableDataFailure()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The computed data is not an array, "string" given');

$snapshot = new Snapshot(['data' => 'foo']);
$snapshot->getComparableData();
}
Expand All @@ -53,32 +53,29 @@ public function existsProvider()
['bar', false]];
}

/**
* @expectedException BadMethodCallException
* @expectedExceptionMessage A snapshot is frozen by nature
*/
public function testOffsetUnset()
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('A snapshot is frozen by nature');

$snapshot = new Snapshot(['data' => ['foo' => 'bar']]);
unset($snapshot['foo']);
}

/**
* @expectedException BadMethodCallException
* @expectedExceptionMessage A snapshot is frozen by nature
*/
public function testOffsetSet()
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('A snapshot is frozen by nature');

$snapshot = new Snapshot(['data' => ['foo' => 'bar']]);
$snapshot[] = 'foo';
}

/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage The computed data is not an array, "string" given
*/
public function testInvalidDataNormalizer()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The computed data is not an array, "string" given');

$snapshot = new Snapshot(['data' => 'foo']);

$refl = new ReflectionMethod('Totem\\AbstractSnapshot', 'normalize');
Expand All @@ -89,7 +86,7 @@ public function testInvalidDataNormalizer()
/** @dataProvider normalizerProvider */
public function testNormalizer($data, $snapshotClass, $setClass = null)
{
$snapshot = new Snapshot;
$snapshot = new Snapshot();
$setClass = $setClass ?: 'stdClass';

$dataProperty = new ReflectionProperty('Totem\\AbstractSnapshot', 'data');
Expand All @@ -110,7 +107,7 @@ public function testNormalizer($data, $snapshotClass, $setClass = null)

public function normalizerProvider()
{
return [[new Snapshot, 'Totem\\Snapshot', 'Totem\\Set'],
return [[new Snapshot(), 'Totem\\Snapshot', 'Totem\\Set'],
[['foo' => 'bar'], 'Totem\\Snapshot\\ArraySnapshot'],
[(object) ['foo' => 'bar'], 'Totem\\Snapshot\\ObjectSnapshot']];
}
Expand All @@ -126,14 +123,15 @@ public function testCorrectSetClass()
{
$snapshot = new Snapshot(['data' => []]);
$snapshot->setSetClass('Totem\\Set');

self::assertInstanceOf(Snapshot::class, $snapshot);
}

/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage A Set Class should be instantiable and implement Totem\SetInterface
*/
public function testWrongSetClass()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('A Set Class should be instantiable and implement Totem\SetInterface');

$snapshot = new Snapshot(['data' => []]);
$snapshot->setSetClass('stdclass');
}
Expand Down
6 changes: 4 additions & 2 deletions test/Change/AdditionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

namespace Totem\Change;

class AdditionTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class AdditionTest extends TestCase
{
private $change;

public function setUp()
protected function setUp(): void
{
$this->change = new Addition('new');
}
Expand Down
6 changes: 4 additions & 2 deletions test/Change/ModificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

namespace Totem\Change;

class ModificationTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class ModificationTest extends TestCase
{
private $change;

public function setUp()
protected function setUp(): void
{
$this->change = new Modification('old', 'new');
}
Expand Down
6 changes: 4 additions & 2 deletions test/Change/RemovalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

namespace Totem\Change;

class RemovalTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

class RemovalTest extends TestCase
{
private $change;

public function setUp()
protected function setUp(): void
{
$this->change = new Removal('old');
}
Expand Down
Loading

0 comments on commit 410b9a5

Please sign in to comment.