diff --git a/pkg/gps/GpsConnectionFactory.php b/pkg/gps/GpsConnectionFactory.php index c803c9de5..9b59923d3 100644 --- a/pkg/gps/GpsConnectionFactory.php +++ b/pkg/gps/GpsConnectionFactory.php @@ -77,7 +77,9 @@ public function createContext(): Context if ($this->config['lazy']) { return new GpsContext(function () { return $this->establishConnection(); - }); + }, [ + 'serilalizeToJson' => $this->config['serilalizeToJson'], + ]); } return new GpsContext($this->establishConnection(), [ @@ -90,10 +92,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if ('gps' !== $dsn->getSchemeProtocol()) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "gps"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "gps"', $dsn->getSchemeProtocol())); } $emulatorHost = $dsn->getString('emulatorHost'); @@ -124,7 +123,7 @@ private function defaultConfig(): array { return [ 'lazy' => true, - 'serilalizeToJson' => true + 'serilalizeToJson' => true, ]; } } diff --git a/pkg/gps/GpsContext.php b/pkg/gps/GpsContext.php index fad96cfe6..ab88cc0c3 100644 --- a/pkg/gps/GpsContext.php +++ b/pkg/gps/GpsContext.php @@ -52,11 +52,7 @@ public function __construct($client, array $options = []) } elseif (is_callable($client)) { $this->clientFactory = $client; } else { - throw new \InvalidArgumentException(sprintf( - 'The $client argument must be either %s or callable that returns %s once called.', - PubSubClient::class, - PubSubClient::class - )); + throw new \InvalidArgumentException(sprintf('The $client argument must be either %s or callable that returns %s once called.', PubSubClient::class, PubSubClient::class)); } } @@ -148,11 +144,7 @@ public function getClient(): PubSubClient if (false == $this->client) { $client = call_user_func($this->clientFactory); if (false == $client instanceof PubSubClient) { - throw new \LogicException(sprintf( - 'The factory must return instance of %s. It returned %s', - PubSubClient::class, - is_object($client) ? get_class($client) : gettype($client) - )); + throw new \LogicException(sprintf('The factory must return instance of %s. It returned %s', PubSubClient::class, is_object($client) ? get_class($client) : gettype($client))); } $this->client = $client; diff --git a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php index 3329e562b..8f843668a 100644 --- a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php +++ b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed() /** * @dataProvider provideConfigs - * - * @param mixed $config - * @param mixed $expectedConfig */ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { diff --git a/pkg/gps/Tests/GpsConsumerTest.php b/pkg/gps/Tests/GpsConsumerTest.php index 4c7fce163..a11bcd7ff 100644 --- a/pkg/gps/Tests/GpsConsumerTest.php +++ b/pkg/gps/Tests/GpsConsumerTest.php @@ -131,6 +131,11 @@ public function testShouldReceiveMessageNoWait() ->willReturn($client) ; + $context + ->expects($this->once()) + ->method('getOptions') + ->willReturn(['serilalizeToJson' => true]); + $consumer = new GpsConsumer($context, new GpsQueue('queue-name')); $message = $consumer->receiveNoWait(); @@ -171,6 +176,11 @@ public function testShouldReceiveMessage() ->willReturn($client) ; + $context + ->expects($this->once()) + ->method('getOptions') + ->willReturn(['serilalizeToJson' => true]); + $consumer = new GpsConsumer($context, new GpsQueue('queue-name')); $message = $consumer->receive(12345); diff --git a/pkg/gps/Tests/GpsMessageTest.php b/pkg/gps/Tests/GpsMessageTest.php index a43a22315..8182333cc 100644 --- a/pkg/gps/Tests/GpsMessageTest.php +++ b/pkg/gps/Tests/GpsMessageTest.php @@ -29,7 +29,7 @@ public function testCouldBeUnserializedFromJson() $json = json_encode($message); - //guard + // guard $this->assertNotEmpty($json); $unserializedMessage = GpsMessage::jsonUnserialize($json); diff --git a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php index 30485b072..4bcaf357b 100644 --- a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php @@ -23,7 +23,6 @@ protected function createContext() /** * @param GpsContext $context - * @param mixed $queueName */ protected function createQueue(Context $context, $queueName) { diff --git a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php index 240c71a3b..3a96bb533 100644 --- a/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -23,7 +23,6 @@ protected function createContext() /** * @param GpsContext $context - * @param mixed $queueName */ protected function createQueue(Context $context, $queueName) {