Skip to content

Commit

Permalink
Merge pull request #8 from answear/support-symfony-7
Browse files Browse the repository at this point in the history
Support symfony 7
  • Loading branch information
Wiktor6 authored Oct 2, 2024
2 parents ca3e49f + 9a004f8 commit c5d58b1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 43 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
deps:
- "normal"
include:
- "deps": "low"
php-version: "8.1"
- "low"

steps:
- name: "Checkout"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"type": "symfony-bundle",
"license": "MIT",
"require": {
"php": "~8.1",
"php": "^8.2",
"ext-amqp": "*",
"symfony/amqp-messenger": "^6.0|^7.0",
"symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/http-kernel": "^6.0|^7.0",
"symfony/messenger": "^6.0|^7.0"
},
"require-dev": {
Expand Down
15 changes: 3 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="./vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
cacheDirectory=".phpunit.cache"
beStrictAboutCoverageMetadata="true"
>
<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Answear.com MessengerHeartbeatBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
9 changes: 3 additions & 6 deletions tests/Unit/Heartbeat/PCNTLHeartbeatSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

use Answear\MessengerHeartbeatBundle\Heartbeat\PCNTLHeartbeatSender;
use Answear\MessengerHeartbeatBundle\Transport\HeartbeatConnectionInterface;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class PCNTLHeartbeatSenderTest extends TestCase
{
/**
* @test
*/
#[Test]
public function registeredChecksConnectionAndHeartbeatValue(): void
{
$connection = $this->createMock(HeartbeatConnectionInterface::class);
Expand All @@ -26,9 +25,7 @@ public function registeredChecksConnectionAndHeartbeatValue(): void
$heartbeatSender->register();
}

/**
* @test
*/
#[Test]
public function errorConnectionInactive(): void
{
$this->expectException(\AMQPConnectionException::class);
Expand Down
20 changes: 8 additions & 12 deletions tests/Unit/Transport/TransportFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,25 @@
use Answear\MessengerHeartbeatBundle\Heartbeat\PCNTLHeartbeatSender;
use Answear\MessengerHeartbeatBundle\Transport\AmqpTransport;
use Answear\MessengerHeartbeatBundle\Transport\TransportFactory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;

class TransportFactoryTest extends TestCase
{
/**
* @test
*
* @dataProvider provideSupportedScheme
*/
#[Test]
#[DataProvider('provideSupportedScheme')]
public function supportsValidScheme(string $dsn): void
{
$factory = new TransportFactory($this->createMock(PCNTLHeartbeatSender::class));

$this->assertTrue($factory->supports($dsn, []));
}

/**
* @test
*
* @dataProvider provideTransportData
*/
#[Test]
#[DataProvider('provideTransportData')]
public function validTransport(string $dsn, array $options, array $expectedOptions): void
{
$factory = new TransportFactory($this->createMock(PCNTLHeartbeatSender::class));
Expand All @@ -41,13 +37,13 @@ public function validTransport(string $dsn, array $options, array $expectedOptio
$this->assertSame($expectedOptions, $this->getInnerProperty($connection, 'connectionOptions'));
}

public function provideSupportedScheme(): iterable
public static function provideSupportedScheme(): iterable
{
yield 'amqp' => ['amqp://host'];
yield 'amqps' => ['amqps://host'];
}

public function provideTransportData(): iterable
public static function provideTransportData(): iterable
{
yield 'defaultWithReadTimeout' => [
'amqp://rabbit-is-dead.elmer?read_timeout=1',
Expand Down
9 changes: 3 additions & 6 deletions tests/Unit/Transport/TransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

use Answear\MessengerHeartbeatBundle\Heartbeat\PCNTLHeartbeatSender;
use Answear\MessengerHeartbeatBundle\Transport\AmqpTransport;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Bridge\Amqp\Transport\Connection;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;

class TransportTest extends TestCase
{
/**
* @test
*/
#[Test]
public function heartbeatRegistered(): void
{
$heartbeatSender = $this->createMock(PCNTLHeartbeatSender::class);
Expand All @@ -33,9 +32,7 @@ public function heartbeatRegistered(): void
$transport->registerHeartbeatSender();
}

/**
* @test
*/
#[Test]
public function getHeartbeat(): void
{
$amqpConnection = $this->createMock(\AMQPConnection::class);
Expand Down

0 comments on commit c5d58b1

Please sign in to comment.