Skip to content

PHP 8.0 & Symfony 5.2 #16

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ jobs:
- php-version: 7.4
symfony-version: 4.4.*
- php-version: 7.4
symfony-version: 5.1.*
symfony-version: 5.2.*
- php-version: 8.0
symfony-version: 4.4.*
- php-version: 8.0
symfony-version: 5.2.*

steps:
- name: "Checkout"
Expand Down Expand Up @@ -50,8 +54,8 @@ jobs:
strategy:
matrix:
include:
- php-version: 7.4
symfony-version: 5.1.*
- php-version: 8.0
symfony-version: 5.2.*

steps:
- name: "Checkout"
Expand Down Expand Up @@ -84,8 +88,8 @@ jobs:
strategy:
matrix:
include:
- php-version: 7.4
symfony-version: 5.1.*
- php-version: 8.0
symfony-version: 5.2.*

steps:
- name: "Checkout"
Expand Down Expand Up @@ -118,8 +122,8 @@ jobs:
strategy:
matrix:
include:
- php-version: 7.4
symfony-version: 5.1.*
- php-version: 8.0
symfony-version: 5.2.*

steps:
- name: "Checkout"
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"require": {
"php": "^7.4",
"php": "^7.4|^8.0",
"ext-json": "*",
"composer-runtime-api": "^2.0",
"box/spout": "^3.0",
Expand All @@ -18,17 +18,19 @@
"doctrine/persistence": "^2.0",
"psr/container": "^1.0",
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.0",
"symfony/console": "^4.4|^5.0",
"symfony/framework-bundle": "^4.4|^5.0",
"symfony/messenger": "^4.4|^5.0",
"symfony/serializer": "^4.4|^5.0",
"symfony/validator": "^4.4|^5.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^9.4",
"squizlabs/php_codesniffer": "^3.5",
"symfony/filesystem": "^4.4|^5.0",
"symplify/monorepo-builder": "^8.2"
},
"replace": {
Expand Down
35 changes: 17 additions & 18 deletions src/batch/tests/Launcher/SimpleJobLauncherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use Yokai\Batch\BatchStatus;
use Yokai\Batch\Factory\JobExecutionFactory;
use Yokai\Batch\Factory\UniqidJobExecutionIdGenerator;
use Yokai\Batch\Job\JobInterface;
Expand Down Expand Up @@ -58,15 +59,10 @@ public function testLaunch(): void

public function testLaunchJobCatchException(): void
{
$jobExecutionAssertions = Argument::allOf(
Argument::type(JobExecution::class),
Argument::which('getJobName', 'export')
);
/** @var ObjectProphecy|JobInterface $job */
$job = $this->prophesize(JobInterface::class);
$job->execute($jobExecutionAssertions)
->shouldBeCalledTimes(1)
->willThrow(new \Exception());
$job->execute(Argument::any())
->willThrow(new \Exception('Triggered for test purpose'));

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

$launcher = new SimpleJobLauncher($jobRegistry, $jobExecutionFactory, $jobExecutionStorage->reveal(), null);
$launcher->launch('export');
$execution = $launcher->launch('export');

self::assertSame('export', $execution->getJobName());
self::assertTrue($execution->getStatus()->is(BatchStatus::FAILED));
self::assertSame(\Exception::class, $execution->getFailures()[0]->getClass());
self::assertSame('Triggered for test purpose', $execution->getFailures()[0]->getMessage());
}

public function testLaunchJobCatchFatal(): void
{
$jobExecutionAssertions = Argument::allOf(
Argument::type(JobExecution::class),
Argument::which('getJobName', 'export')
);
/** @var ObjectProphecy|JobInterface $job */
$job = $this->prophesize(JobInterface::class);
$job->execute($jobExecutionAssertions)
->shouldBeCalledTimes(1)
->will(function (): void {
$var = 10 / 0;
});
$job->execute(Argument::any())
->willThrow(new \DivisionByZeroError('Triggered for test purpose'));

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

$launcher = new SimpleJobLauncher($jobRegistry, $jobExecutionFactory, $jobExecutionStorage->reveal(), null);
$launcher->launch('export');
$execution = $launcher->launch('export');

self::assertSame('export', $execution->getJobName());
self::assertTrue($execution->getStatus()->is(BatchStatus::FAILED));
self::assertSame(\DivisionByZeroError::class, $execution->getFailures()[0]->getClass());
self::assertSame('Triggered for test purpose', $execution->getFailures()[0]->getMessage());
}
}