Skip to content

Commit 34b6b75

Browse files
authored
[feature] add PHP 8.1 and Symfony 6.1 support (#271)
1 parent 67fdfd8 commit 34b6b75

File tree

12 files changed

+57
-33
lines changed

12 files changed

+57
-33
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ jobs:
1515
strategy:
1616
fail-fast: true
1717
matrix:
18-
php: [7.4, 8.0]
18+
php: [7.4, 8.0, 8.1]
1919
symfony: [4.4.*, 5.3.*, 5.4.*]
2020
include:
2121
- php: 8.0
2222
symfony: 6.0.*
23+
- php: 8.1
24+
symfony: 6.0.*
25+
- php: 8.1
26+
symfony: 6.1.*
2327

2428
steps:
2529
- name: Checkout code
@@ -128,4 +132,4 @@ jobs:
128132
composer-options: --prefer-dist
129133

130134
- name: Check CS
131-
run: vendor/bin/php-cs-fixer fix -v --dry-run --diff-format=udiff
135+
run: vendor/bin/php-cs-fixer fix --diff --dry-run --verbose

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
->in(__DIR__)
77
;
88

9-
return PhpCsFixer\Config::create()
9+
return (new PhpCsFixer\Config())
1010
->setRules([
1111
'@Symfony' => true,
1212
'no_superfluous_phpdoc_tags' => [

Check/SymfonyVersion.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class SymfonyVersion implements CheckInterface
2020
{
21-
const PACKAGIST_URL = 'https://packagist.org/packages/symfony/symfony.json';
22-
const VERSION_CHECK_URL = 'https://symfony.com/releases/%s.json';
21+
public const PACKAGIST_URL = 'https://packagist.org/packages/symfony/symfony.json';
22+
public const VERSION_CHECK_URL = 'https://symfony.com/releases/%s.json';
2323

2424
/**
2525
* @return ResultInterface

DependencyInjection/Compiler/AddGroupsCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class AddGroupsCompilerPass implements CompilerPassInterface
99
{
10-
const SERVICE_ID_PREFIX = 'liip_monitor.check.';
10+
public const SERVICE_ID_PREFIX = 'liip_monitor.check.';
1111

1212
public function process(ContainerBuilder $container): void
1313
{

Helper/ArrayReporter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
class ArrayReporter implements ReporterInterface
1717
{
18-
const STATUS_OK = 'OK';
19-
const STATUS_KO = 'KO';
18+
public const STATUS_OK = 'OK';
19+
public const STATUS_KO = 'KO';
2020

2121
private $globalStatus = self::STATUS_OK;
2222
private $results = [];

Tests/Check/RedisCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
final class RedisCollectionTest extends TestCase
1212
{
13-
const AUTH = 'my-super-secret-password';
13+
public const AUTH = 'my-super-secret-password';
1414

1515
/**
1616
* @test

Tests/Helper/SwiftMailerReporterTest.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Laminas\Diagnostics\Result\Success;
1212
use Laminas\Diagnostics\Result\Warning;
1313
use Liip\MonitorBundle\Helper\SwiftMailerReporter;
14-
use Prophecy\Argument;
1514

1615
/**
1716
* @author Kevin Bond <[email protected]>
@@ -23,13 +22,15 @@ class SwiftMailerReporterTest extends \PHPUnit\Framework\TestCase
2322
*/
2423
public function testSendNoEmail(ResultInterface $result, $sendOnWarning): void
2524
{
26-
$mailer = $this->prophesize('Swift_Mailer');
27-
$mailer->send()->shouldNotBeCalled();
25+
$mailer = $this->createMock('Swift_Mailer');
26+
$mailer
27+
->expects(self::never())
28+
->method('send');
2829

2930
$results = new Collection();
30-
$results[$this->prophesize(CheckInterface::class)->reveal()] = $result;
31+
$results[$this->createMock(CheckInterface::class)] = $result;
3132

32-
$reporter = new SwiftMailerReporter($mailer->reveal(), '[email protected]', '[email protected]', 'foo bar', $sendOnWarning);
33+
$reporter = new SwiftMailerReporter($mailer, '[email protected]', '[email protected]', 'foo bar', $sendOnWarning);
3334
$reporter->onFinish($results);
3435
}
3536

@@ -38,13 +39,16 @@ public function testSendNoEmail(ResultInterface $result, $sendOnWarning): void
3839
*/
3940
public function testSendEmail(ResultInterface $result, $sendOnWarning): void
4041
{
41-
$mailer = $this->prophesize('Swift_Mailer');
42-
$mailer->send(Argument::type('Swift_Message'))->shouldBeCalled();
42+
$mailer = $this->createMock('Swift_Mailer');
43+
$mailer
44+
->expects(self::once())
45+
->method('send')
46+
->with(self::isInstanceOf('Swift_Message'));
4347

4448
$results = new Collection();
45-
$results[$this->prophesize(CheckInterface::class)->reveal()] = $result;
49+
$results[$this->createMock(CheckInterface::class)] = $result;
4650

47-
$reporter = new SwiftMailerReporter($mailer->reveal(), '[email protected]', '[email protected]', 'foo bar', $sendOnWarning);
51+
$reporter = new SwiftMailerReporter($mailer, '[email protected]', '[email protected]', 'foo bar', $sendOnWarning);
4852
$reporter->onFinish($results);
4953
}
5054

Tests/Helper/SymfonyMailerReporterTest.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
use Laminas\Diagnostics\Result\Collection;
77
use Laminas\Diagnostics\Result\Failure;
88
use Liip\MonitorBundle\Helper\SymfonyMailerReporter;
9+
use PHPUnit\Framework\MockObject\MockObject;
910
use PHPUnit\Framework\TestCase;
10-
use Prophecy\Argument;
1111
use Symfony\Component\Mailer\MailerInterface;
1212
use Symfony\Component\Mime\Address;
1313
use Symfony\Component\Mime\Email;
1414

1515
class SymfonyMailerReporterTest extends TestCase
1616
{
1717
/**
18-
* @var \Prophecy\Prophecy\ObjectProphecy|MailerInterface
18+
* @var MockObject|MailerInterface
1919
*/
2020
private $mailer;
2121

@@ -25,31 +25,33 @@ protected function setUp(): void
2525
$this->markTestSkipped('Symfony Mailer not available.');
2626
}
2727

28-
$this->mailer = $this->prophesize(MailerInterface::class);
28+
$this->mailer = $this->createMock(MailerInterface::class);
2929
}
3030

3131
/**
3232
* @dataProvider getTestData
3333
*/
3434
public function testSendMail(array $recipients, string $sender, string $subject): void
3535
{
36-
$reporter = new SymfonyMailerReporter($this->mailer->reveal(), $recipients, $sender, $subject);
36+
$reporter = new SymfonyMailerReporter($this->mailer, $recipients, $sender, $subject);
3737

3838
$check = $this->prophesize(CheckInterface::class);
3939
$check->getLabel()->willReturn('Some Label');
4040

4141
$checks = new Collection();
4242
$checks[$check->reveal()] = new Failure('Something goes wrong');
4343

44-
$this->mailer->send(Argument::that(function (Email $message) use ($recipients, $sender, $subject): bool {
45-
$this->assertEquals(Address::createArray($recipients), $message->getTo(), 'Check if Recipient is sent correctly.');
46-
$this->assertEquals([Address::create($sender)], $message->getFrom(), 'Check that the from header is set correctly.');
47-
$this->assertSame($subject, $message->getSubject(), 'Check that the subject has been set.');
44+
$this->mailer
45+
->expects(self::once())
46+
->method('send')
47+
->with(self::callback(function (?Email $message) use ($recipients, $sender, $subject): bool {
48+
self::assertEquals(Address::createArray($recipients), $message->getTo(), 'Check if Recipient is sent correctly.');
49+
self::assertEquals([Address::create($sender)], $message->getFrom(), 'Check that the from header is set correctly.');
50+
self::assertSame($subject, $message->getSubject(), 'Check that the subject has been set.');
51+
self::assertSame('[Some Label] Something goes wrong', $message->getTextBody(), 'Check if the text body has been set.');
4852

49-
$this->assertSame('[Some Label] Something goes wrong', $message->getTextBody(), 'Check if the text body has been set.');
50-
51-
return true;
52-
}))->shouldBeCalled();
53+
return true;
54+
}));
5355

5456
$reporter->onFinish($checks);
5557
}

Tests/LiipMonitorBundleTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public function testBuildWithCompilerPasses(): void
4242
function ($compilerPass) use (&$compilerPasses) {
4343
$class = get_class($compilerPass);
4444
unset($compilerPasses[$class]);
45+
46+
return $this->container;
4547
}
4648
);
4749

Tests/app/config_symfony5.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# symfony 4 config (requires assets defined)
1+
# symfony 5 config (requires assets defined)
22
framework:
33
router:
44
resource: "%kernel.project_dir%/routing.yml"

0 commit comments

Comments
 (0)