Skip to content

Commit 1d32b6f

Browse files
authored
PHP 8.0 & Symfony 5.2 (#16)
* Merge monorepo composer.json * Allow PHP 8.0 & Symfony 5.2
1 parent bbdf16d commit 1d32b6f

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ jobs:
1717
- php-version: 7.4
1818
symfony-version: 4.4.*
1919
- php-version: 7.4
20-
symfony-version: 5.1.*
20+
symfony-version: 5.2.*
21+
- php-version: 8.0
22+
symfony-version: 4.4.*
23+
- php-version: 8.0
24+
symfony-version: 5.2.*
2125

2226
steps:
2327
- name: "Checkout"
@@ -50,8 +54,8 @@ jobs:
5054
strategy:
5155
matrix:
5256
include:
53-
- php-version: 7.4
54-
symfony-version: 5.1.*
57+
- php-version: 8.0
58+
symfony-version: 5.2.*
5559

5660
steps:
5761
- name: "Checkout"
@@ -84,8 +88,8 @@ jobs:
8488
strategy:
8589
matrix:
8690
include:
87-
- php-version: 7.4
88-
symfony-version: 5.1.*
91+
- php-version: 8.0
92+
symfony-version: 5.2.*
8993

9094
steps:
9195
- name: "Checkout"
@@ -118,8 +122,8 @@ jobs:
118122
strategy:
119123
matrix:
120124
include:
121-
- php-version: 7.4
122-
symfony-version: 5.1.*
125+
- php-version: 8.0
126+
symfony-version: 5.2.*
123127

124128
steps:
125129
- name: "Checkout"

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require": {
12-
"php": "^7.4",
12+
"php": "^7.4|^8.0",
1313
"ext-json": "*",
1414
"composer-runtime-api": "^2.0",
1515
"box/spout": "^3.0",
@@ -18,17 +18,19 @@
1818
"doctrine/persistence": "^2.0",
1919
"psr/container": "^1.0",
2020
"psr/event-dispatcher": "^1.0",
21+
"psr/log": "^1.0",
2122
"symfony/console": "^4.4|^5.0",
2223
"symfony/framework-bundle": "^4.4|^5.0",
2324
"symfony/messenger": "^4.4|^5.0",
2425
"symfony/serializer": "^4.4|^5.0",
2526
"symfony/validator": "^4.4|^5.0"
2627
},
2728
"require-dev": {
28-
"phpstan/phpstan": "^0.12",
2929
"phpspec/prophecy-phpunit": "^2.0",
30+
"phpstan/phpstan": "^0.12",
3031
"phpunit/phpunit": "^9.4",
3132
"squizlabs/php_codesniffer": "^3.5",
33+
"symfony/filesystem": "^4.4|^5.0",
3234
"symplify/monorepo-builder": "^8.2"
3335
},
3436
"replace": {

src/batch/tests/Launcher/SimpleJobLauncherTest.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Prophecy\PhpUnit\ProphecyTrait;
1010
use Prophecy\Prophecy\ObjectProphecy;
1111
use Psr\Container\ContainerInterface;
12+
use Yokai\Batch\BatchStatus;
1213
use Yokai\Batch\Factory\JobExecutionFactory;
1314
use Yokai\Batch\Factory\UniqidJobExecutionIdGenerator;
1415
use Yokai\Batch\Job\JobInterface;
@@ -58,15 +59,10 @@ public function testLaunch(): void
5859

5960
public function testLaunchJobCatchException(): void
6061
{
61-
$jobExecutionAssertions = Argument::allOf(
62-
Argument::type(JobExecution::class),
63-
Argument::which('getJobName', 'export')
64-
);
6562
/** @var ObjectProphecy|JobInterface $job */
6663
$job = $this->prophesize(JobInterface::class);
67-
$job->execute($jobExecutionAssertions)
68-
->shouldBeCalledTimes(1)
69-
->willThrow(new \Exception());
64+
$job->execute(Argument::any())
65+
->willThrow(new \Exception('Triggered for test purpose'));
7066

7167
/** @var ContainerInterface|ObjectProphecy $container */
7268
$container = $this->prophesize(ContainerInterface::class);
@@ -78,22 +74,20 @@ public function testLaunchJobCatchException(): void
7874
$jobExecutionStorage = $this->prophesize(JobExecutionStorageInterface::class);
7975

8076
$launcher = new SimpleJobLauncher($jobRegistry, $jobExecutionFactory, $jobExecutionStorage->reveal(), null);
81-
$launcher->launch('export');
77+
$execution = $launcher->launch('export');
78+
79+
self::assertSame('export', $execution->getJobName());
80+
self::assertTrue($execution->getStatus()->is(BatchStatus::FAILED));
81+
self::assertSame(\Exception::class, $execution->getFailures()[0]->getClass());
82+
self::assertSame('Triggered for test purpose', $execution->getFailures()[0]->getMessage());
8283
}
8384

8485
public function testLaunchJobCatchFatal(): void
8586
{
86-
$jobExecutionAssertions = Argument::allOf(
87-
Argument::type(JobExecution::class),
88-
Argument::which('getJobName', 'export')
89-
);
9087
/** @var ObjectProphecy|JobInterface $job */
9188
$job = $this->prophesize(JobInterface::class);
92-
$job->execute($jobExecutionAssertions)
93-
->shouldBeCalledTimes(1)
94-
->will(function (): void {
95-
$var = 10 / 0;
96-
});
89+
$job->execute(Argument::any())
90+
->willThrow(new \DivisionByZeroError('Triggered for test purpose'));
9791

9892
/** @var ContainerInterface|ObjectProphecy $container */
9993
$container = $this->prophesize(ContainerInterface::class);
@@ -105,6 +99,11 @@ public function testLaunchJobCatchFatal(): void
10599
$jobExecutionStorage = $this->prophesize(JobExecutionStorageInterface::class);
106100

107101
$launcher = new SimpleJobLauncher($jobRegistry, $jobExecutionFactory, $jobExecutionStorage->reveal(), null);
108-
$launcher->launch('export');
102+
$execution = $launcher->launch('export');
103+
104+
self::assertSame('export', $execution->getJobName());
105+
self::assertTrue($execution->getStatus()->is(BatchStatus::FAILED));
106+
self::assertSame(\DivisionByZeroError::class, $execution->getFailures()[0]->getClass());
107+
self::assertSame('Triggered for test purpose', $execution->getFailures()[0]->getMessage());
109108
}
110109
}

0 commit comments

Comments
 (0)