Skip to content

Commit

Permalink
upgrade to PHPUnit 8 (#384)
Browse files Browse the repository at this point in the history
* Feature/phpunit8 (#1)

 - PHPUnit ^8.0 ready
 - php 7.4 ready
 - code sniffer fixes

* Feature/phpunit8 (#2)

php 7.4, phpunit 8.0

* rollback to phpunit ^6.0

* rollback to phpunit 6

* back to phpunit 8

Co-authored-by: rppgorecki <rppgorecki@gmail.com>
  • Loading branch information
othillo and rppgorecki committed Feb 13, 2020
1 parent 50ba75b commit 7587a35
Show file tree
Hide file tree
Showing 27 changed files with 42 additions and 34 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"beberlei/assert": "~3.0",
"broadway/uuid-generator": "~0.4.0",
"php": ">=7.1"
"php": ">=7.2"
},
"authors": [
{
Expand Down Expand Up @@ -36,7 +36,7 @@
],
"require-dev": {
"monolog/monolog": "~1.8",
"phpunit/phpunit": "^6.0",
"phpunit/phpunit": "^8.0",
"ramsey/uuid": "^3.0",
"friendsofphp/php-cs-fixer": "^2.1",
"malukenho/docheader": "^0.1.7"
Expand Down
2 changes: 1 addition & 1 deletion examples/event-sourced-child-entity/PartsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PartsCommandHandlerTest extends Broadway\CommandHandling\Testing\CommandHa
{
private $generator;

public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->generator = new Broadway\UuidGenerator\Rfc4122\Version4Generator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InvitationCommandHandlerTest extends Broadway\CommandHandling\Testing\Comm
{
private $generator;

public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->generator = new Broadway\UuidGenerator\Rfc4122\Version4Generator();
Expand Down
2 changes: 1 addition & 1 deletion examples/event-sourced-domain-with-tests/InvitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InvitesTest extends Broadway\EventSourcing\Testing\AggregateRootScenarioTe
{
private $generator;

public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->generator = new Broadway\UuidGenerator\Rfc4122\Version4Generator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class JobSeekersCommandHandlerTest extends Broadway\CommandHandling\Testing\Comm
{
private $generator;

public function setUp()
protected function setUp(): void
{
parent::setUp();
$this->generator = new Broadway\UuidGenerator\Rfc4122\Version4Generator();
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class CommandHandlerScenarioTestCase extends TestCase
*/
protected $scenario;

public function setUp()
protected function setUp(): void
{
$this->scenario = $this->createScenario();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class AggregateRootScenarioTestCase extends TestCase
*/
protected $scenario;

public function setUp()
protected function setUp(): void
{
$this->scenario = $this->createScenario();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class EventStoreManagementTest extends TestCase
*/
protected $now;

protected function setUp()
protected function setUp(): void
{
$this->now = DateTime::now();
$this->eventStore = $this->createEventStore();
Expand Down
7 changes: 6 additions & 1 deletion src/Broadway/EventStore/Testing/EventStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ public function it_throws_an_exception_when_an_id_cannot_be_converted_to_a_strin
'Yolntbyaac' //You only live nine times because you are a cat
);

$this->expectException(Error::class);
if (PHP_VERSION_ID > 70400) {
$this->expectException(\Throwable::class);
} else {
$this->expectException(Error::class);
}

$this->expectExceptionMessage(sprintf(
'Object of class %s could not be converted to string',
IdentityThatCannotBeConvertedToAString::class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class ProjectorScenarioTestCase extends TestCase
*/
protected $scenario;

public function setUp()
protected function setUp(): void
{
$this->scenario = $this->createScenario();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Broadway/ReadModel/Testing/RepositoryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class RepositoryTestCase extends TestCase
*/
protected $repository;

protected function setUp()
protected function setUp(): void
{
$this->repository = $this->createRepository();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Broadway/Auditing/CommandLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CommandLoggerTest extends TestCase
*/
private $commandSerializer;

protected function setUp()
protected function setUp(): void
{
$this->logger = new TraceableLogger();

Expand Down
2 changes: 1 addition & 1 deletion test/Broadway/Auditing/NullByteCommandSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NullByteCommandSerializerTest extends TestCase
*/
private $command;

protected function setUp()
protected function setUp(): void
{
$this->commandSerializer = new NullByteCommandSerializer();
$this->command = new MyCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

use Broadway\EventDispatcher\EventDispatcher;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class EventDispatchingCommandBusTest extends TestCase
{
/**
* @var CommandBus|\PHPUnit_Framework_MockObject_MockObject
* @var CommandBus|MockObject
*/
private $baseCommandBus;

Expand All @@ -30,7 +31,7 @@ class EventDispatchingCommandBusTest extends TestCase
private $command;

/**
* @var EventDispatcher|\PHPUnit_Framework_MockObject_MockObject
* @var EventDispatcher|MockObject
*/
private $eventDispatcher;

Expand All @@ -40,11 +41,11 @@ class EventDispatchingCommandBusTest extends TestCase
private $eventDispatchingCommandBus;

/**
* @var CommandHandler|\PHPUnit_Framework_MockObject_MockObject
* @var CommandHandler|MockObject
*/
private $subscriber;

protected function setUp()
protected function setUp(): void
{
$this->eventDispatcher = $this->createMock(EventDispatcher::class);
$this->baseCommandBus = $this->createMock(CommandBus::class);
Expand Down
5 changes: 3 additions & 2 deletions test/Broadway/CommandHandling/SimpleCommandBusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Broadway\CommandHandling;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class SimpleCommandBusTest extends TestCase
Expand All @@ -22,7 +23,7 @@ class SimpleCommandBusTest extends TestCase
*/
private $commandBus;

protected function setUp()
protected function setUp(): void
{
$this->commandBus = new SimpleCommandBus();
}
Expand Down Expand Up @@ -103,7 +104,7 @@ public function it_should_still_handle_commands_after_exception()
$this->commandBus->dispatch($command2);
}

private function createCommandHandlerMock(array $expectedCommand): \PHPUnit_Framework_MockObject_MockObject
private function createCommandHandlerMock(array $expectedCommand): MockObject
{
$mock = $this->createMock(CommandHandler::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TraceableCommandBusTest extends TestCase
*/
private $commandBus;

protected function setUp()
protected function setUp(): void
{
$this->commandBus = new TraceableCommandBus();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Broadway/EventDispatcher/EventDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EventDispatcherTest extends TestCase
*/
private $listener2;

protected function setUp()
protected function setUp(): void
{
$this->dispatcher = new CallableEventDispatcher();
$this->listener1 = new TracableEventListener();
Expand Down
5 changes: 3 additions & 2 deletions test/Broadway/EventHandling/SimpleEventBusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Broadway\Domain\DomainEventStream;
use Broadway\Domain\DomainMessage;
use Broadway\Domain\Metadata;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class SimpleEventBusTest extends TestCase
Expand All @@ -25,7 +26,7 @@ class SimpleEventBusTest extends TestCase
*/
private $eventBus;

protected function setUp()
protected function setUp(): void
{
$this->eventBus = new SimpleEventBus();
}
Expand Down Expand Up @@ -144,7 +145,7 @@ public function it_should_still_publish_events_after_exception()
$this->eventBus->publish($domainEventStream2);
}

private function createEventListenerMock(): \PHPUnit_Framework_MockObject_MockObject
private function createEventListenerMock(): MockObject
{
return $this->createMock(EventListener::class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class AbstractEventSourcingRepositoryTest extends TestCase
/** @var EventSourcingRepository */
protected $repository;

protected function setUp()
protected function setUp(): void
{
$this->eventStore = new TraceableEventStore(new InMemoryEventStore());
$this->eventStore->trace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class ReflectionAggregateFactoryTest extends TestCase
*/
private $factory;

protected function setUp()
protected function setUp(): void
{
$this->factory = new ReflectionAggregateFactory();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BlacklistConcurrencyConflictResolverTest extends ConcurrencyConflictResolv
/** @var BlacklistConcurrencyConflictResolver */
private $conflictResolver;

protected function setUp()
protected function setUp(): void
{
$this->conflictResolver = new BlacklistConcurrencyConflictResolver();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class WhitelistConcurrencyConflictResolverTest extends ConcurrencyConflictResolv
/** @var WhitelistConcurrencyConflictResolver */
private $conflictResolver;

protected function setUp()
protected function setUp(): void
{
$this->conflictResolver = new WhitelistConcurrencyConflictResolver();
}
Expand Down
5 changes: 3 additions & 2 deletions test/Broadway/EventStore/ConflictResolvingEventStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
use Broadway\Domain\DomainMessage;
use Broadway\EventStore\ConcurrencyConflictResolver\ConcurrencyConflictResolver;
use Broadway\EventStore\Testing\EventStoreTest;
use PHPUnit\Framework\MockObject\MockObject;
use Prophecy\Argument;

class ConflictResolvingEventStoreTest extends EventStoreTest
{
/** @var ConcurrencyConflictResolver|\PHPUnit_Framework_MockObject_MockObject */
/** @var ConcurrencyConflictResolver|MockObject */
protected $concurrencyResolver;

protected function setUp()
protected function setUp(): void
{
$this->concurrencyResolver = $this->prophesize(ConcurrencyConflictResolver::class);
$this->concurrencyResolver
Expand Down
2 changes: 1 addition & 1 deletion test/Broadway/EventStore/InMemoryEventStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class InMemoryEventStoreTest extends EventStoreTest
{
protected function setUp()
protected function setUp(): void
{
$this->eventStore = new InMemoryEventStore();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Broadway/Serializer/ReflectionSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ReflectionSerializerTest extends TestCase
*/
private $serializer;

protected function setUp()
protected function setUp(): void
{
$this->serializer = new ReflectionSerializer();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Broadway/Serializer/SimpleInterfaceSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SimpleInterfaceSerializerTest extends TestCase
*/
private $serializer;

protected function setUp()
protected function setUp(): void
{
$this->serializer = new SimpleInterfaceSerializer();
}
Expand Down

0 comments on commit 7587a35

Please sign in to comment.