Skip to content

Commit

Permalink
Merge pull request #2 from SykesCottages/add-travis-ci
Browse files Browse the repository at this point in the history
Add a travis CI and code coverage stats to the readme
  • Loading branch information
richardhughes authored Jan 18, 2019
2 parents 1532cbc + 95e252d commit 2f071be
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
.idea
vendor
vendor
build
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ services:
ports:
- 29852:15672
- 48888:5672
wait:
image: waisbrot/wait
links:
- rabbitmq
- sqs
environment:
- TARGETS=rabbitmq:5672,sqs:9324
1 change: 1 addition & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ parameters:
tab_width: ~
whitelist_patterns:
- /^src/
- /^tests/
encoding: ~
ignore_patterns:
- /^vendor/
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutChangesToGlobalState="true"
>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<testsuites>
<testsuite name="All">
<directory suffix="Test.php">./tests</directory>
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Connector/RabbitMQTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
);
Expand All @@ -77,4 +77,4 @@ private function addMessageToQueue(): void
{
$this->rabbitMq->queueMessage(self::QUEUE_NAME, ['example' => 'test']);
}
}
}
2 changes: 1 addition & 1 deletion tests/Functional/Connector/SQSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ private function getMessages(string $queueUrl): array

return $message->get('Messages') ?? [];
}
}
}
2 changes: 1 addition & 1 deletion tests/Functional/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ protected function assertFunctionHasBeenCalled(): void
{
$this->assertTrue(true);
}
}
}
5 changes: 3 additions & 2 deletions tests/Functional/RabbitMQTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Connector/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ public function testQueueCanRejectMessageInQueue()

$this->queue->reject($message, $errorMessage);
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Consumer/ConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ public function testExceptionIsNotThrownWhenItHasNotBeenRequested(): void
$this->consumer->idle()
);
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Consumer/Stub/TestConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public function process(Message $message): void
$message->getBody();
$this->queue->acknowledge($message);
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Exception/InvalidMessageTypeExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public function classMessageDataProvider(): array
]
];
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Message/RabbitMQMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ public function testGetDeliveryTagReturnsWithString(): void

$this->assertSame($randomDeliveryTag, $this->rabbitMqMessage->getDeliveryTag());
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/Message/SQSMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public function testGetReceiptHandleReturnsTheCorrectString(): void
{
$this->assertSame(self::RECEIPT_HANDLE, $this->sqsMessage->getReceiptHandle());
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public function tearDown(): void
parent::tearDown();
Mockery::close();
}
}
}

0 comments on commit 2f071be

Please sign in to comment.