Skip to content

Commit

Permalink
Updated CI (#14)
Browse files Browse the repository at this point in the history
* Better locking of Symfony versions in CI

* Symfony <=4.3 compatibility in unit tests
  • Loading branch information
DamienHarper authored Dec 10, 2020
1 parent 66dfc7e commit 56b1492
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ jobs:
coverage: pcov

- name: Configure Symfony
run: composer config extra.symfony.require "${{ matrix.symfony }}"
run: |
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer config extra.symfony.require "${{ matrix.symfony }}"
- name: Get Composer Cache Directory
id: composer-cache
Expand All @@ -83,7 +85,16 @@ jobs:
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ matrix.php }}-composer-

- name: Update project dependencies
- name: Update project dependencies (3.4.*)
if: matrix.symfony == '3.4.*'
run: SYMFONY_REQUIRE="^3.4" composer update --no-progress --ansi --prefer-stable

- name: Update project dependencies (4.4.*)
if: matrix.symfony == '4.4.*'
run: SYMFONY_REQUIRE="^4.4" composer update --no-progress --ansi --prefer-stable

- name: Update project dependencies (5.*)
if: matrix.symfony == '5.*'
run: composer update --no-progress --ansi --prefer-stable

- name: Validate composer
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"symfony": {
"require": "3.4.*"
}
}
}
17 changes: 15 additions & 2 deletions tests/EventSubscriber/AuditEventSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public function testOnAuditEvent(): void
$dispatcher = $auditor->getEventDispatcher();
$subscriber = new AuditEventSubscriber($auditor);
$dispatcher->addSubscriber($subscriber);
$dispatcher->dispatch(new LifecycleEvent($payload));

if ($auditor->isPre43Dispatcher()) {
// Symfony 3.x
$dispatcher->dispatch(LifecycleEvent::class, new LifecycleEvent($payload));
} else {
// Symfony >= 4.x
$dispatcher->dispatch(new LifecycleEvent($payload));
}

self::assertArrayHasKey(LifecycleEvent::class, AuditEventSubscriber::getSubscribedEvents());
}
Expand Down Expand Up @@ -69,7 +76,13 @@ public function testCustomAuditEventSubscriber(): void
$subscriber = new CustomAuditEventSubscriber($auditor);
$dispatcher->addSubscriber($subscriber);

$dispatcher->dispatch(new LifecycleEvent($payload));
if ($auditor->isPre43Dispatcher()) {
// Symfony 3.x
$dispatcher->dispatch(LifecycleEvent::class, new LifecycleEvent($payload));
} else {
// Symfony >= 4.x
$dispatcher->dispatch(new LifecycleEvent($payload));
}

self::assertArrayHasKey(LifecycleEvent::class, CustomAuditEventSubscriber::getSubscribedEvents());
}
Expand Down

0 comments on commit 56b1492

Please sign in to comment.