Skip to content

Commit

Permalink
Further baseline reduction and qa fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteel committed May 16, 2023
1 parent 3b4c84a commit be39798
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 44 deletions.
5 changes: 5 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/test/</exclude-pattern>
</rule>

<!-- PHP 4 Constructors are not possible on PHP 8+ -->
<rule ref="Generic.NamingConventions.ConstructorName.OldStyle">
<severity>0</severity>
</rule>
</ruleset>
31 changes: 0 additions & 31 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,4 @@
<code>withHttpResponse</code>
</PossiblyUnusedMethod>
</file>
<file src="test/Smoke/TestCase.php">
<RedundantCondition>
<code>assert(is_array($configured))</code>
<code>assert(is_array($spec))</code>
<code>is_array($configured)</code>
<code>is_array($spec)</code>
<code><![CDATA[is_string($spec['url'])]]></code>
<code><![CDATA[isset($spec['url']) && is_string($spec['url'])]]></code>
<code>null</code>
</RedundantCondition>
<TypeDoesNotContainType>
<code>is_array($content)</code>
<code><![CDATA[is_string($spec['token'])]]></code>
<code><![CDATA[isset($spec['token'])]]></code>
<code><![CDATA[isset($spec['token']) && is_string($spec['token'])]]></code>
<code>null</code>
</TypeDoesNotContainType>
<UnusedPsalmSuppress>
<code>MissingFile</code>
</UnusedPsalmSuppress>
</file>
<file src="test/Unit/QueryTest.php">
<InvalidReturnStatement>
<code>$queries</code>
<code>$queries</code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[array<string, array{0: Query, 1: string}>]]></code>
<code><![CDATA[array<string, array{0: Query, 1: string}>]]></code>
</InvalidReturnType>
</file>
</files>
1 change: 0 additions & 1 deletion test/Smoke/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ protected static function compileEndPoints(): array
return $endpoints;
}

/** @psalm-suppress MissingFile */
$content = require $configPath;
if (! is_array($content)) {
return $endpoints;
Expand Down
40 changes: 28 additions & 12 deletions test/Unit/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,20 @@ public static function queryProvider(): array
/** @return array<string, array{0: Query, 1: string}> */
public static function defaultUrlProvider(): array
{
$queries = self::queryProvider();
$queries['Standard Form'][1] = 'https://example.com/api/v2?page=1&pageSize=20';
$queries['Collection'][1] = sprintf('https://example.com?q=%s&page=1&pageSize=20', urlencode('[[:d = any(document.type, ["doc-type"])]]'));
$queries['With Query'][1] = 'https://example.com/?term=something&page=1&pageSize=20';

return $queries;
return [
'Standard Form' => [
new Query(FormSpec::factory('everything', self::formData()->everything)),
'https://example.com/api/v2?page=1&pageSize=20',
],
'With Query' => [
new Query(FormSpec::factory('withQuery', self::formData()->withQuery)),
'https://example.com/?term=something&page=1&pageSize=20',
],
'Collection' => [
new Query(FormSpec::factory('collection', self::formData()->collection)),
sprintf('https://example.com?q=%s&page=1&pageSize=20', urlencode('[[:d = any(document.type, ["doc-type"])]]')),
],
];
}

/** @dataProvider defaultUrlProvider */
Expand All @@ -86,12 +94,20 @@ public function testDefaultUrl(Query $query, string $expectedUrl): void
/** @return array<string, array{0: Query, 1: string}> */
public static function queryUrlProvider(): array
{
$queries = self::queryProvider();
$queries['Standard Form'][1] = 'https://example.com/api/v2?page=1&pageSize=20&q=foo';
$queries['Collection'][1] = sprintf('https://example.com?q=%s&q=foo&page=1&pageSize=20', urlencode('[[:d = any(document.type, ["doc-type"])]]'));
$queries['With Query'][1] = 'https://example.com/?term=something&page=1&pageSize=20&q=foo';

return $queries;
return [
'Standard Form' => [
new Query(FormSpec::factory('everything', self::formData()->everything)),
'https://example.com/api/v2?page=1&pageSize=20&q=foo',
],
'With Query' => [
new Query(FormSpec::factory('withQuery', self::formData()->withQuery)),
'https://example.com/?term=something&page=1&pageSize=20&q=foo',
],
'Collection' => [
new Query(FormSpec::factory('collection', self::formData()->collection)),
sprintf('https://example.com?q=%s&q=foo&page=1&pageSize=20', urlencode('[[:d = any(document.type, ["doc-type"])]]')),
],
];
}

/** @dataProvider queryUrlProvider */
Expand Down

0 comments on commit be39798

Please sign in to comment.