Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 support #417

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/build
.idea
.php_cs.cache
.phpunit.result.cache
nbproject
composer.lock
docs/html
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ matrix:
- php: 7.4
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- php: 8.0
env:
- DEPENDENCIES=""
- php: 8.0
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"

cache:
directories:
Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.1",
"php": "^7.1 | ^8.0",
"marc-mabe/php-enum": "^2.3.1 || ^3.0.0 || ^4.0.0",
"prooph/common": "^4.1.0"
},
"require-dev": {
"phpspec/prophecy": "^1.10.3",
"phpunit/php-invoker": "^2.0",
"phpunit/phpunit": "^7.5.20",
"prooph/bookdown-template": "^0.2.3",
"prooph/php-cs-fixer-config": "v0.3.1",
"phpspec/prophecy-phpunit": "^2.0.0",
"psr/container": "^1.0",
"sandrokeil/interop-config": "^2.0.1",
"satooshi/php-coveralls": "^1.0"
"phpunit/phpunit": "^9.0",
"prooph/php-cs-fixer-config": "^0.4",
"satooshi/php-coveralls": "^1.0",
"prooph/bookdown-template": "^0.2.3"
},
"suggest" : {
"prooph/pdo-event-store": "For usage with MySQL or Postgres as event store",
Expand Down
47 changes: 24 additions & 23 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
timeoutForSmallTests="2"
enforceTimeLimit="true"
failOnWarning="true"
failOnRisky="true"
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
timeoutForSmallTests="2"
enforceTimeLimit="true"
failOnWarning="true"
failOnRisky="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<testsuite name="Prooph EventStore Test Suite">
<directory>./tests</directory>
</testsuite>

<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
<coverage>
<include>
<directory>./src/</directory>
</include>
</coverage>
<testsuite name="Prooph EventStore Test Suite">
<directory>./tests</directory>
</testsuite>
</phpunit>
2 changes: 2 additions & 0 deletions tests/AbstractEventStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
use ProophTest\EventStore\Mock\TestDomainEvent;
use ProophTest\EventStore\Mock\UserCreated;
use ProophTest\EventStore\Mock\UsernameChanged;
use Prophecy\PhpUnit\ProphecyTrait;

/**
* Common tests for all event store implementations
*/
abstract class AbstractEventStoreTest extends TestCase
{
use EventStoreTestStreamTrait;
use ProphecyTrait;

/**
* @var EventStore
Expand Down
2 changes: 2 additions & 0 deletions tests/ActionEventEmitterEventStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
use Prooph\EventStore\Metadata\Operator;
use Prooph\EventStore\StreamName;
use ProophTest\EventStore\Mock\UsernameChanged;
use Prophecy\PhpUnit\ProphecyTrait;

class ActionEventEmitterEventStoreTest extends ActionEventEmitterEventStoreTestCase
{
use ProphecyTrait;
use EventStoreTestStreamTrait;

/**
Expand Down
34 changes: 22 additions & 12 deletions tests/Container/InMemoryEventStoreFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@
use ProophTest\EventStore\Mock\UsernameChanged;
use Prophecy\Argument;
use Psr\Container\ContainerInterface;
use Prophecy\PhpUnit\ProphecyTrait;

class InMemoryEventStoreFactoryTest extends TestCase
{
use ProphecyTrait;

/**
* @test
*/
Expand All @@ -43,7 +46,7 @@ public function it_creates_event_store_with_default_event_emitter(): void
$config['prooph']['event_store']['default'] = [];

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->once())->method('get')->with('config')->willReturn($config);

$factory = new InMemoryEventStoreFactory();
$eventStore = $factory($containerMock);
Expand All @@ -59,7 +62,7 @@ public function it_creates_event_store_without_event_emitter(): void
$config['prooph']['event_store']['default'] = ['wrap_action_event_emitter' => false];

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->once())->method('get')->with('config')->willReturn($config);

$factory = new InMemoryEventStoreFactory();
$eventStore = $factory($containerMock);
Expand All @@ -75,7 +78,7 @@ public function it_creates_non_transactional_event_store_without_event_emitter()
$config['prooph']['event_store']['default'] = ['wrap_action_event_emitter' => false, 'transactional' => false];

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->once())->method('get')->with('config')->willReturn($config);

$factory = new InMemoryEventStoreFactory();
$eventStore = $factory($containerMock);
Expand All @@ -91,7 +94,7 @@ public function it_creates_read_only_event_store(): void
$config['prooph']['event_store']['default'] = ['wrap_action_event_emitter' => false, 'read_only' => true];

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->once())->method('get')->with('config')->willReturn($config);

$factory = new InMemoryEventStoreFactory();
$eventStore = $factory($containerMock);
Expand All @@ -107,7 +110,7 @@ public function it_creates_event_store_with_default_event_emitter_via_callstatic
$config['prooph']['event_store']['another'] = [];

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->once())->method('get')->with('config')->willReturn($config);

$type = 'another';
$eventStore = InMemoryEventStoreFactory::$type($containerMock);
Expand All @@ -123,7 +126,7 @@ public function it_creates_non_transactional_event_store_with_non_transactional_
$config['prooph']['event_store']['another'] = ['transactional' => false];

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->once())->method('get')->with('config')->willReturn($config);

$type = 'another';
$eventStore = InMemoryEventStoreFactory::$type($containerMock);
Expand All @@ -141,8 +144,10 @@ public function it_injects_custom_event_emitter(): void
$eventEmitterMock = $this->getMockForAbstractClass(ActionEventEmitter::class);

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->at(1))->method('get')->with('event_emitter')->willReturn($eventEmitterMock);
$containerMock->expects($this->any())->method('get')->willReturnMap([
['config', $config],
['event_emitter', $eventEmitterMock]
]);

$factory = new InMemoryEventStoreFactory();
$eventStore = $factory($containerMock);
Expand All @@ -152,6 +157,7 @@ public function it_injects_custom_event_emitter(): void

/**
* @test
* @group only
*/
public function it_injects_plugins(): void
{
Expand All @@ -161,8 +167,10 @@ public function it_injects_plugins(): void
$featureMock->attachToEventStore(Argument::type(TransactionalActionEventEmitterEventStore::class))->shouldBeCalled();

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->at(1))->method('get')->with('plugin')->willReturn($featureMock->reveal());
$containerMock->expects($this->any())->method('get')->willReturnMap([
['config', $config],
['plugin', $featureMock->reveal()]
]);

$factory = new InMemoryEventStoreFactory();
$eventStore = $factory($containerMock);
Expand All @@ -183,8 +191,10 @@ public function it_throws_exception_when_invalid_plugin_configured(): void
$featureMock = 'foo';

$containerMock = $this->getMockForAbstractClass(ContainerInterface::class);
$containerMock->expects($this->at(0))->method('get')->with('config')->willReturn($config);
$containerMock->expects($this->at(1))->method('get')->with('plugin')->willReturn($featureMock);
$containerMock->expects($this->any())->method('get')->willReturnMap([
['config', $config],
['plugin', $featureMock]
]);

$factory = new InMemoryEventStoreFactory();
$factory($containerMock);
Expand Down
3 changes: 3 additions & 0 deletions tests/Container/InMemoryProjectionManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
use Prooph\EventStore\InMemoryEventStore;
use Prooph\EventStore\Projection\InMemoryProjectionManager;
use Psr\Container\ContainerInterface;
use Prophecy\PhpUnit\ProphecyTrait;

class InMemoryProjectionManagerFactoryTest extends TestCase
{
use ProphecyTrait;

/**
* @test
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/Example/QuickStartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function it_provides_the_correct_example_output(): void
'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
);

$this->assertRegExp($pattern, $this->getQuickstartOutput());
$this->assertMatchesRegularExpression($pattern, $this->getQuickstartOutput());
}

private function getQuickstartOutput(): string
Expand Down
3 changes: 3 additions & 0 deletions tests/Metadata/MetadataEnricherAggregateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
use Prooph\EventStore\Metadata\MetadataEnricherAggregate;
use ProophTest\EventStore\Mock\TestDomainEvent;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;

class MetadataEnricherAggregateTest extends TestCase
{
use ProphecyTrait;

/**
* @test
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Metadata/MetadataEnricherPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
use Prooph\EventStore\StreamName;
use ProophTest\EventStore\Mock\TestDomainEvent;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;

class MetadataEnricherPluginTest extends TestCase
{
use ProphecyTrait;

/**
* @test
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Plugin/PluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
use ProophTest\EventStore\Mock\EventLoggerPlugin;
use ProophTest\EventStore\Mock\UserCreated;
use Psr\Container\ContainerInterface;
use Prophecy\PhpUnit\ProphecyTrait;

class PluginManagerTest extends ActionEventEmitterEventStoreTestCase
{
use ProphecyTrait;

/**
* @test
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/Projection/AbstractEventStoreProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,13 @@ public function it_resets_to_empty_array(): void

$state = $projection->getState();

$this->assertInternalType('array', $state);
$this->assertIsArray($state);

$projection->reset();

$state2 = $projection->getState();

$this->assertInternalType('array', $state2);
$this->assertIsArray($state2);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Projection/AbstractEventStoreQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ public function it_resets_to_empty_array(): void

$state = $query->getState();

$this->assertInternalType('array', $state);
$this->assertIsArray($state);

$query->reset();

$state2 = $query->getState();

$this->assertInternalType('array', $state2);
$this->assertIsArray($state2);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Projection/AbstractEventStoreReadModelProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,13 @@ public function it_resets_to_empty_array(): void

$state = $projection->getState();

$this->assertInternalType('array', $state);
$this->assertIsArray($state);

$projection->reset();

$state2 = $projection->getState();

$this->assertInternalType('array', $state2);
$this->assertIsArray($state2);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions tests/Projection/InMemoryEventStoreProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
use Prooph\EventStore\NonTransactionalInMemoryEventStore;
use Prooph\EventStore\Projection\InMemoryEventStoreProjector;
use Prooph\EventStore\Projection\InMemoryProjectionManager;
use Prophecy\PhpUnit\ProphecyTrait;

class InMemoryEventStoreProjectorTest extends AbstractEventStoreProjectorTest
{
use ProphecyTrait;

/**
* @var InMemoryProjectionManager
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Projection/InMemoryEventStoreQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
use Prooph\EventStore\NonTransactionalInMemoryEventStore;
use Prooph\EventStore\Projection\InMemoryEventStoreQuery;
use Prooph\EventStore\Projection\InMemoryProjectionManager;
use Prophecy\PhpUnit\ProphecyTrait;

class InMemoryEventStoreQueryTest extends AbstractEventStoreQueryTest
{
use ProphecyTrait;

/**
* @var InMemoryProjectionManager
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Projection/InMemoryEventStoreReadModelProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
use Prooph\EventStore\Projection\InMemoryEventStoreReadModelProjector;
use Prooph\EventStore\Projection\InMemoryProjectionManager;
use ProophTest\EventStore\Mock\ReadModelMock;
use Prophecy\PhpUnit\ProphecyTrait;

class InMemoryEventStoreReadModelProjectorTest extends AbstractEventStoreReadModelProjectorTest
{
use ProphecyTrait;

/**
* @var InMemoryProjectionManager
*/
Expand Down