Skip to content

Commit

Permalink
Merge pull request #31 from pauci/phpunit-10
Browse files Browse the repository at this point in the history
feat: Upgrade to phpunit 10
  • Loading branch information
pauci authored Apr 26, 2023
2 parents ebe77a9 + bf926bb commit 58dcd30
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:

strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2']
php-versions: ['8.1', '8.2']

services:
redis:
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
run: composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader

- name: Run unit tests
run: ./vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml --coverage-text
run: ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-text

- name: Publish coverage report to Codecov
uses: codecov/codecov-action@v1
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"sort-packages": true
},
"require": {
"php": "^8.0 || ^8.1 || ^8.2",
"php": "^8.1 || ^8.2",
"ext-json": "*",
"psr/clock": "^1.0",
"psr/container": "^1.0 || ^2.0",
Expand All @@ -30,7 +30,7 @@
"guzzlehttp/guzzle": "^7.2",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.1",
"squizlabs/php_codesniffer": "^3.7",
"symfony/cache": "^6.0",
"symfony/serializer": "^6.0"
Expand Down
13 changes: 7 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<coverage/>
<testsuites>
<testsuite name="cqrs">
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

abstract class AbstractOrmTransactionManager implements TransactionManagerInterface
{
protected EntityManagerInterface $entityManager;

public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
public function __construct(
protected EntityManagerInterface $entityManager,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function getSubscribedEvents(): array
*/
public function preFlush(PreFlushEventArgs $event): void
{
$entityManager = $event->getEntityManager();
$entityManager = $event->getObjectManager();
$uow = $entityManager->getUnitOfWork();

foreach ($uow->getIdentityMap() as $class => $entities) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Domain/Model/AbstractAggregateRootTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public function testRegisterEvent(): void
{
$event = new SomeEvent();

$aggregateRoot = new AggregateRootUnderTest(4);
$aggregateRoot = new SomeAggregateRoot(4);
$aggregateRoot->raise($event);

$eventMessages = $aggregateRoot->getUncommittedEvents();

self::assertCount(1, $eventMessages);
self::assertInstanceOf(GenericDomainEventMessage::class, $eventMessages[0]);
self::assertEquals(AggregateRootUnderTest::class, $eventMessages[0]->getAggregateType());
self::assertEquals(SomeAggregateRoot::class, $eventMessages[0]->getAggregateType());
self::assertEquals(4, $eventMessages[0]->getAggregateId());
self::assertSame($event, $eventMessages[0]->getPayload());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @phpstan-template Id
*/
class AggregateRootUnderTest extends AbstractAggregateRoot
class SomeAggregateRoot extends AbstractAggregateRoot
{
/**
* @phpstan-var Id
Expand Down
6 changes: 3 additions & 3 deletions tests/EventHandling/Publisher/SimpleIdentityMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace CQRSTest\EventHandling\Publisher;

use CQRS\EventHandling\Publisher\SimpleIdentityMap;
use CQRSTest\Domain\Model\AggregateRootUnderTest;
use CQRSTest\Domain\Model\SomeAggregateRoot;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;

Expand All @@ -15,10 +15,10 @@ public function test(): void
{
$identityMap = new SimpleIdentityMap();

$ar1 = new AggregateRootUnderTest(Uuid::uuid4());
$ar1 = new SomeAggregateRoot(Uuid::uuid4());
$identityMap->add($ar1);

$ar2 = new AggregateRootUnderTest(new \stdClass());
$ar2 = new SomeAggregateRoot(new \stdClass());
$identityMap->add($ar2);
$identityMap->add($ar2); // Add same object twice

Expand Down

0 comments on commit 58dcd30

Please sign in to comment.