Skip to content

Commit

Permalink
update framework version
Browse files Browse the repository at this point in the history
  • Loading branch information
mmasiukevich committed Jan 2, 2020
1 parent fc7ad21 commit 07098a7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 73 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ php:
- 7.3
- 7.4snapshot

matrix:
allow_failures:
- php: 7.4snapshot
addons:
apt:
packages:
- rabbitmq-server

cache:
directories:
Expand All @@ -23,11 +24,10 @@ install:
- composer show

script:
- ./vendor/bin/phpunit --configuration ./phpunit.xml --coverage-clover=coverage.clover
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then ./vendor/bin/psalm --config=psalm.xml; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then ./vendor/bin/phpstan analyse src --level 7; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then ./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run; fi
- ./vendor/bin/phpunit --configuration ./phpunit.xml --coverage-clover=coverage.clover --debug
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then ./vendor/bin/psalm --config=psalm.xml; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then ./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run; fi

after_script:
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then wget -c -nc --retry-connrefused --tries=0 https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then wget -c -nc --retry-connrefused --tries=0 https://scrutinizer-ci.com/ocular.phar; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
2 changes: 1 addition & 1 deletion bin/consumer
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Loop::run(

yield $kernel->createQueue(
$mainQueue,
QueueBind::create($mainExchange, (string) \getenv('TRANSPORT_ROUTING_KEY'))
new QueueBind($mainExchange, (string) \getenv('TRANSPORT_ROUTING_KEY'))
);

yield $kernel->run($mainQueue);
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"require": {
"php": ">=7.3",
"ext-json": "*",
"php-service-bus/service-bus": "v3.3.*",
"php-service-bus/module-phpinnacle-transport": "v3.3.*"
"php-service-bus/service-bus": "v4.0.*",
"php-service-bus/module-phpinnacle-transport": "v4.0.*"
},
"require-dev": {
"php-service-bus/code-style-config": "v0.1.*",
"phpunit/phpunit": "v8.3.*",
"vimeo/psalm": "v3.4.*",
"php-service-bus/code-style-config": "v1.2.*",
"phpunit/phpunit": "v8.4.*",
"vimeo/psalm": "v3.7.*",
"phpstan/phpstan": "v0.11.*"
},
"config": {
Expand Down
10 changes: 2 additions & 8 deletions docker/application/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM php:7.3-cli-alpine
FROM php:7.4-cli-alpine

RUN set -xe \
&& apk update \
&& apk add libpq postgresql-dev libevent-dev autoconf zlib-dev g++ libtool make libzip-dev git \
&& apk add oniguruma-dev libpq postgresql-dev libevent-dev autoconf zlib-dev g++ libtool make libzip-dev git \
# Iconv fix
&& apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv \
&& docker-php-ext-install \
Expand Down Expand Up @@ -40,10 +40,4 @@ RUN echo "f80bbb8ea85346bf6082727fdf58857c59649da2" \
&& make install \
&& echo "extension=buffer.so" > /usr/local/etc/php/conf.d/buffer.ini

# Composer install
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& chmod +x /usr/local/bin/composer \
&& composer global require hirak/prestissimo \
&& composer clear-cache

COPY ./tools/* /tools/
19 changes: 9 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.4/phpunit.xsd"
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="false"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
beStrictAboutTestsThatDoNotTestAnything="false">
stopOnFailure="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="TEST_POSTGRES_DSN" value="pgsql://postgres:123456789@localhost:5432/test"/>
<env name="TRANSPORT_CONNECTION_DSN" value="amqp://guest:guest@localhost:5672"/>
<env name="DATABASE_CONNECTION_DSN" value="sqlite:///:memory:"/>
</php>

<testsuites>
<testsuite name="Application testing">
<testsuite name="Service bus skeleton">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
useDocblockPropertyTypes="true"
allowPhpStormGenerics="true"
requireVoidReturnType="true"
strictBinaryOperands="true"
ignoreInternalFunctionFalseReturn="false"
ignoreInternalFunctionNullReturn="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
20 changes: 5 additions & 15 deletions src/PingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace App;

use Amp\Promise;
use ServiceBus\Context\KernelContext;
use ServiceBus\Common\Context\ServiceBusContext;
use ServiceBus\Services\Annotations\CommandHandler;
use ServiceBus\Services\Annotations\EventListener;

Expand All @@ -25,27 +25,17 @@ final class PingService
{
/**
* @CommandHandler()
*
* @param Ping $command
* @param KernelContext $context
*
* @return Promise
*/
public function handle(Ping $command, KernelContext $context): Promise
public function handle(Ping $command, ServiceBusContext $context): Promise
{
return $context->delivery(new Pong());
}

/**
* @EventListener()
*
* @param Pong $event
* @param KernelContext $context
*
* @return void
* @EventListener(description="Pong message received")
*/
public function whenPong(Pong $event, KernelContext $context): void
public function whenPong(Pong $event, ServiceBusContext $context): void
{
$context->logContextMessage('Pong message received');

}
}
27 changes: 2 additions & 25 deletions tools/ToolsPublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,18 @@ final class ToolsPublisher
private $encoder;

/**
* @param string $envPath
*
* @throws \Symfony\Component\Dotenv\Exception\FormatException
* @throws \Symfony\Component\Dotenv\Exception\PathException
*/
public function __construct(string $envPath)
{
(new Dotenv())->load($envPath);
(new Dotenv(true))->load($envPath);

$this->encoder = new SymfonyMessageSerializer();
}

/**
* Send message to queue.
*
* @param object $message
* @param string|null $traceId
* @param string|null $topic
* @param string|null $routingKey
*
* @throws \ServiceBus\MessageSerializer\Exceptions\EncodeMessageFailed
* @throws \ServiceBus\Transport\Common\Exceptions\InvalidConnectionParameters
* @throws \ServiceBus\Transport\Common\Exceptions\SendMessageFailed
* @throws \Throwable
*
* @return void
*
*/
public function sendMessage(object $message, string $traceId = null, ?string $topic = null, ?string $routingKey = null): void
{
Expand All @@ -67,7 +52,7 @@ public function sendMessage(object $message, string $traceId = null, ?string $to
/** @noinspection PhpUnhandledExceptionInspection */
wait(
$this->transport()->send(
OutboundPackage::create(
new OutboundPackage(
$this->encoder->encode($message),
[Transport::SERVICE_BUS_TRACE_HEADER => $traceId ?? uuid()],
new AmqpTransportLevelDestination($topic, $routingKey),
Expand All @@ -77,14 +62,6 @@ public function sendMessage(object $message, string $traceId = null, ?string $to
);
}

/**
* @noinspection PhpDocMissingThrowsInspection
*
* @throws \ServiceBus\Transport\Common\Exceptions\InvalidConnectionParameters
*
* @return Transport
*
*/
private function transport(): Transport
{
if (null === $this->transport)
Expand Down

0 comments on commit 07098a7

Please sign in to comment.