Skip to content

Commit

Permalink
Fixing CI and Specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedkhan847 committed Dec 27, 2023
1 parent ac5a275 commit ba5fd89
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
11 changes: 5 additions & 6 deletions pkg/gps/GpsConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(), [
Expand All @@ -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');
Expand Down Expand Up @@ -124,7 +123,7 @@ private function defaultConfig(): array
{
return [
'lazy' => true,
'serilalizeToJson' => true
'serilalizeToJson' => true,
];
}
}
12 changes: 2 additions & 10 deletions pkg/gps/GpsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions pkg/gps/Tests/GpsConnectionFactoryConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public function testThrowIfDsnCouldNotBeParsed()

/**
* @dataProvider provideConfigs
*
* @param mixed $config
* @param mixed $expectedConfig
*/
public function testShouldParseConfigurationAsExpected($config, $expectedConfig)
{
Expand Down
10 changes: 10 additions & 0 deletions pkg/gps/Tests/GpsConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion pkg/gps/Tests/GpsMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testCouldBeUnserializedFromJson()

$json = json_encode($message);

//guard
// guard
$this->assertNotEmpty($json);

$unserializedMessage = GpsMessage::jsonUnserialize($json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ protected function createContext()

/**
* @param GpsContext $context
* @param mixed $queueName
*/
protected function createQueue(Context $context, $queueName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ protected function createContext()

/**
* @param GpsContext $context
* @param mixed $queueName
*/
protected function createQueue(Context $context, $queueName)
{
Expand Down

0 comments on commit ba5fd89

Please sign in to comment.