diff --git a/.gitignore b/.gitignore index 25c202a..0bafb8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ coverage .idea -vendor \ No newline at end of file +vendor +build \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d2e63c2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +language: php + +php: + - '7.2' + - '7.3' + - nightly + +services: + - docker + +before_install: + - docker-compose up -d + - docker-compose -f docker-compose.yml run wait + +before_script: + - mkdir -p build/logs + - ls -al + +install: + - travis_retry composer install --no-interaction + - wget -c -nc --retry-connrefused --tries=0 https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar + - chmod +x php-coveralls.phar + - php php-coveralls.phar --version + +script: + - ./vendor/bin/grumphp run + +after_success: + - travis_retry php php-coveralls.phar -v + - bash <(curl -s https://codecov.io/bash) + +cache: + directories: + - vendor + - $HOME/.cache/composer \ No newline at end of file diff --git a/README.md b/README.md index f648126..00cd15d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Qu +[![Build Status](https://travis-ci.org/SykesCottages/Qu.svg?branch=master)](https://travis-ci.org/SykesCottages/Qu) +[![Coverage Status](https://coveralls.io/repos/github/SykesCottages/Qu/badge.svg?branch=master)](https://coveralls.io/github/SykesCottages/Qu?branch=master) + This package has been designed to switch out queue providers using a Queue & Consumer interface. You can use this package with RabbitMQ & SQS to seamlessly switch between the two. diff --git a/docker-compose.yml b/docker-compose.yml index 1d65cec..5bf9025 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,3 +11,10 @@ services: ports: - 29852:15672 - 48888:5672 + wait: + image: waisbrot/wait + links: + - rabbitmq + - sqs + environment: + - TARGETS=rabbitmq:5672,sqs:9324 \ No newline at end of file diff --git a/grumphp.yml b/grumphp.yml index b73c9e1..34da404 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -12,6 +12,7 @@ parameters: tab_width: ~ whitelist_patterns: - /^src/ + - /^tests/ encoding: ~ ignore_patterns: - /^vendor/ diff --git a/phpunit.xml b/phpunit.xml index 5ee1d4d..ada6d4c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -12,6 +12,9 @@ beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutChangesToGlobalState="true" > + + + ./tests diff --git a/tests/Functional/Connector/RabbitMQTest.php b/tests/Functional/Connector/RabbitMQTest.php index 3234922..c3efbcc 100644 --- a/tests/Functional/Connector/RabbitMQTest.php +++ b/tests/Functional/Connector/RabbitMQTest.php @@ -63,11 +63,11 @@ public function testWeCanCallTheCallbackFunctionWhenWeHaveAMessage(): void $this->rabbitMq->consume( self::QUEUE_NAME, - function (Message $message){ + function (Message $message) { $this->assertFunctionHasBeenCalled(); $this->assertInstanceOf(RabbitMQMessage::class, $message); }, - function() { + function () { $this->assertFunctionIsNotCalled(); } ); @@ -77,4 +77,4 @@ private function addMessageToQueue(): void { $this->rabbitMq->queueMessage(self::QUEUE_NAME, ['example' => 'test']); } -} \ No newline at end of file +} diff --git a/tests/Functional/Connector/SQSTest.php b/tests/Functional/Connector/SQSTest.php index 19a1a7d..8300d71 100644 --- a/tests/Functional/Connector/SQSTest.php +++ b/tests/Functional/Connector/SQSTest.php @@ -132,4 +132,4 @@ private function getMessages(string $queueUrl): array return $message->get('Messages') ?? []; } -} \ No newline at end of file +} diff --git a/tests/Functional/FunctionalTestCase.php b/tests/Functional/FunctionalTestCase.php index 26408a5..9bc6497 100644 --- a/tests/Functional/FunctionalTestCase.php +++ b/tests/Functional/FunctionalTestCase.php @@ -21,4 +21,4 @@ protected function assertFunctionHasBeenCalled(): void { $this->assertTrue(true); } -} \ No newline at end of file +} diff --git a/tests/Functional/RabbitMQTestCase.php b/tests/Functional/RabbitMQTestCase.php index f273194..7d3504f 100644 --- a/tests/Functional/RabbitMQTestCase.php +++ b/tests/Functional/RabbitMQTestCase.php @@ -56,8 +56,9 @@ protected function consumeOneMessage(string $queueName, string $callbackFunction false, function (AMQPMessage $message) use ($queueName, $callbackFunctionName) { $this->rabbitMq->{$callbackFunctionName}($queueName, new RabbitMQMessage($message)); - }); + } + ); $this->channel->wait(); } -} \ No newline at end of file +} diff --git a/tests/Unit/Connector/QueueTest.php b/tests/Unit/Connector/QueueTest.php index 4e14050..081cf01 100644 --- a/tests/Unit/Connector/QueueTest.php +++ b/tests/Unit/Connector/QueueTest.php @@ -90,4 +90,4 @@ public function testQueueCanRejectMessageInQueue() $this->queue->reject($message, $errorMessage); } -} \ No newline at end of file +} diff --git a/tests/Unit/Consumer/ConsumerTest.php b/tests/Unit/Consumer/ConsumerTest.php index a7dbf24..1a723b3 100644 --- a/tests/Unit/Consumer/ConsumerTest.php +++ b/tests/Unit/Consumer/ConsumerTest.php @@ -67,4 +67,4 @@ public function testExceptionIsNotThrownWhenItHasNotBeenRequested(): void $this->consumer->idle() ); } -} \ No newline at end of file +} diff --git a/tests/Unit/Consumer/Stub/TestConsumer.php b/tests/Unit/Consumer/Stub/TestConsumer.php index d5dc115..cbee7e9 100644 --- a/tests/Unit/Consumer/Stub/TestConsumer.php +++ b/tests/Unit/Consumer/Stub/TestConsumer.php @@ -14,4 +14,4 @@ public function process(Message $message): void $message->getBody(); $this->queue->acknowledge($message); } -} \ No newline at end of file +} diff --git a/tests/Unit/Exception/InvalidMessageTypeExceptionTest.php b/tests/Unit/Exception/InvalidMessageTypeExceptionTest.php index 4c9c436..9edaeba 100644 --- a/tests/Unit/Exception/InvalidMessageTypeExceptionTest.php +++ b/tests/Unit/Exception/InvalidMessageTypeExceptionTest.php @@ -43,4 +43,4 @@ public function classMessageDataProvider(): array ] ]; } -} \ No newline at end of file +} diff --git a/tests/Unit/Message/RabbitMQMessageTest.php b/tests/Unit/Message/RabbitMQMessageTest.php index 7989364..81f7fe0 100644 --- a/tests/Unit/Message/RabbitMQMessageTest.php +++ b/tests/Unit/Message/RabbitMQMessageTest.php @@ -76,4 +76,4 @@ public function testGetDeliveryTagReturnsWithString(): void $this->assertSame($randomDeliveryTag, $this->rabbitMqMessage->getDeliveryTag()); } -} \ No newline at end of file +} diff --git a/tests/Unit/Message/SQSMessageTest.php b/tests/Unit/Message/SQSMessageTest.php index 06c58fa..52c46af 100644 --- a/tests/Unit/Message/SQSMessageTest.php +++ b/tests/Unit/Message/SQSMessageTest.php @@ -43,4 +43,4 @@ public function testGetReceiptHandleReturnsTheCorrectString(): void { $this->assertSame(self::RECEIPT_HANDLE, $this->sqsMessage->getReceiptHandle()); } -} \ No newline at end of file +} diff --git a/tests/Unit/UnitTestCase.php b/tests/Unit/UnitTestCase.php index 2caa783..e107a82 100644 --- a/tests/Unit/UnitTestCase.php +++ b/tests/Unit/UnitTestCase.php @@ -18,4 +18,4 @@ public function tearDown(): void parent::tearDown(); Mockery::close(); } -} \ No newline at end of file +}