Skip to content

Commit

Permalink
Fixes PHP Stan error.
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Jun 11, 2020
1 parent ac72a81 commit a81331a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Connector/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public function modifyOptions($options = []): array

// Combine options set globally e.g. headers with options set by individual API calls e.g. form_params.
$options = $this->options + $options;
$options['query'] = $this->query;

// This library can be standalone or as a dependency. Dependent libraries may also set their own user agent
// which will make $options['headers']['User-Agent'] an array.
Expand All @@ -96,6 +95,7 @@ public function modifyOptions($options = []): array
$options['headers']['User-Agent'] = implode(' ', array_reverse($options['headers']['User-Agent']));
}

$options['query'] = $this->query;
if (!empty($options['query']['filter']) && is_array($options['query']['filter'])) {
// Default to an AND filter.
$options['query']['filter'] = implode(',', $options['query']['filter']);
Expand Down
27 changes: 27 additions & 0 deletions tests/Endpoints/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,31 @@ public function testModifyOptions()

$this->assertEquals($expectedOptions, $actualOptions);
}

public function testVersion()
{
$versionFile = sprintf('%s/VERSION', dirname(dirname(__DIR__)));
$version = trim(file_get_contents($versionFile));

$client = $this->getMockClient();
$actualValue = $client->getVersion();

$this->assertEquals($version, $actualValue);
}

public function testMissingVersion()
{
$versionFile = sprintf('%s/VERSION', dirname(dirname(__DIR__)));
$versionFileBak = sprintf('%s.bak', $versionFile);
rename($versionFile, $versionFileBak);

try {
$client = $this->getMockClient();
$version = $client->getVersion();
} catch (\Exception $e) {
$this->assertEquals('Exception', get_class($e));
$this->assertEquals('No VERSION file', $e->getMessage());
}
rename($versionFileBak, $versionFile);
}
}

0 comments on commit a81331a

Please sign in to comment.