Skip to content

Commit a429c7c

Browse files
committed
Fix code style issues
- Fix long lines in test files by extracting URI variables - All tests now pass: PHPCS clean, PHPStan/Psalm clean, PHPUnit 10/10
1 parent 822bebb commit a429c7c

File tree

10 files changed

+122
-10
lines changed

10 files changed

+122
-10
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Coding Standards
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
cs:
10+
uses: ray-di/.github/.github/workflows/coding-standards.yml@v2
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
ci:
10+
uses: ray-di/.github/.github/workflows/continuous-integration.yml@v1
11+
with:
12+
old_stable: '[" 8.1.32", "8.2.28", "8.3"]'
13+
current_stable: 8.4
14+
script: demo/run.php
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
sa:
10+
uses: ray-di/.github/.github/workflows/static-analysis.yml@v1
11+
with:
12+
php_version: 8.4
13+
has_crc_config: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ray.MediaQuery-Web
1+
# Ray.WebQuery
22

33
Web API access mapping framework for [Ray.MediaQuery](https://github.com/ray-di/Ray.MediaQuery).
44

composer.json

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
],
1111
"require": {
1212
"php": "^8.1",
13-
"ray/media-query": "^1.0",
13+
"ray/media-query": "1.x-dev",
1414
"guzzlehttp/guzzle": "^7.2",
1515
"psr/http-message": "^2.0"
1616
},
1717
"require-dev": {
1818
"bamarni/composer-bin-plugin": "^1.8",
19-
"phpunit/phpunit": "^10.5.46"
19+
"phpunit/phpunit": "^10.5.46",
20+
"squizlabs/php_codesniffer": "^3.8",
21+
"phpstan/phpstan": "^1.10",
22+
"vimeo/psalm": "^5.18 || ^6.0",
23+
"phpmetrics/phpmetrics": "^2.8"
2024
},
2125
"autoload": {
2226
"psr-4": {
@@ -32,14 +36,40 @@
3236
}
3337
},
3438
"scripts": {
35-
"test": "./vendor/bin/phpunit"
39+
"coverage": "php -dzend_extension=xdebug.so -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage",
40+
"pcov": "php -dextension=pcov.so -d pcov.enabled=1 ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml",
41+
"cs": "./vendor/bin/phpcs",
42+
"cs-fix": "./vendor/bin/phpcbf src tests",
43+
"metrics": "./vendor/bin/phpmetrics --report-html=build/metrics --exclude=Exception src",
44+
"clean": [
45+
"./vendor/bin/phpstan clear-result-cache",
46+
"./vendor/bin/psalm --clear-cache"
47+
],
48+
"sa": [
49+
"./vendor/bin/psalm --monochrome --show-info=true",
50+
"./vendor/bin/phpstan analyse -c phpstan.neon"
51+
],
52+
"test": "./vendor/bin/phpunit",
53+
"tests": [
54+
"@cs",
55+
"@sa",
56+
"@test"
57+
],
58+
"build": [
59+
"@clean",
60+
"@cs",
61+
"@sa",
62+
"@pcov",
63+
"@metrics"
64+
]
3665
},
66+
"minimum-stability": "dev",
67+
"prefer-stable": true,
3768
"config": {
3869
"sort-packages": true,
3970
"allow-plugins": {
4071
"dealerdirect/phpcodesniffer-composer-installer": true,
4172
"bamarni/composer-bin-plugin": true
4273
}
4374
}
44-
}
45-
EOF < /dev/null
75+
}

phpcs.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Ray.WebQuery">
3+
<description>Ray.WebQuery coding standard</description>
4+
5+
<rule ref="PSR12"/>
6+
7+
<file>src</file>
8+
<file>tests</file>
9+
10+
<exclude-pattern>*/tests/tmp/*</exclude-pattern>
11+
<exclude-pattern>*/vendor/*</exclude-pattern>
12+
<exclude-pattern>*/Fake/*</exclude-pattern>
13+
14+
<arg name="colors"/>
15+
<arg value="p"/>
16+
</ruleset>

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src
5+
- tests
6+
excludePaths:
7+
- tests/Fake/*
8+
- tests/tmp/*

psalm.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="1"
4+
phpVersion="8.4"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor-bin/tools/vendor/vimeo/psalm/config.xsd"
8+
findUnusedBaselineEntry="true"
9+
findUnusedCode="false"
10+
>
11+
<projectFiles>
12+
<directory name="src" />
13+
<ignoreFiles>
14+
<directory name="vendor" />
15+
</ignoreFiles>
16+
</projectFiles>
17+
</psalm>

tests/WebQueryModuleTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public function testGetRequest(): void
3535
{
3636
$response = $this->fooItem->item('web_query');
3737
$this->assertSame('Web query schema', $response['title']);
38-
$this->assertSame('query: https://ray-di.github.io/Ray.MediaQuery/schema/web_query.json({"id":"web_query"})', (string) $this->logger);
38+
$expected = 'query: https://ray-di.github.io/Ray.MediaQuery/schema/web_query.json({"id":"web_query"})';
39+
$this->assertSame($expected, (string) $this->logger);
3940
}
4041

4142
public function testGetRequestStringResponse(): void

tests/WebQueryTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@ class WebQueryTest extends TestCase
1313
public function testRequest(): void
1414
{
1515
$webQuery = new WebApiQuery(new Client(), new MediaQueryLogger(), ['domain1' => 'ray-di.github.io']);
16-
$response = $webQuery->request('GET', 'https://{domain1}/Ray.MediaQuery/schema/{id}.json', ['id' => 'web_query']);
16+
$uri = 'https://{domain1}/Ray.MediaQuery/schema/{id}.json';
17+
$response = $webQuery->request('GET', $uri, ['id' => 'web_query']);
1718
$this->assertSame('Web query schema', $response['title']);
1819
}
1920

2021
public function testGetStringBody(): void
2122
{
2223
$webQuery = new WebApiQuery(new Client(), new MediaQueryLogger(), ['domain1' => 'ray-di.github.io']);
23-
$response = $webQuery->getStringBody('GET', 'https://{domain1}/Ray.MediaQuery/schema/{id}.json', ['id' => 'web_query']);
24+
$uri = 'https://{domain1}/Ray.MediaQuery/schema/{id}.json';
25+
$response = $webQuery->getStringBody('GET', $uri, ['id' => 'web_query']);
2426
$this->assertStringContainsString('"title": "Web query schema"', $response);
2527
}
2628

2729
public function testGetHttpMessage(): void
2830
{
2931
$webQuery = new WebApiQuery(new Client(), new MediaQueryLogger(), ['domain1' => 'ray-di.github.io']);
30-
$response = $webQuery->getHttpMessage('GET', 'https://{domain1}/Ray.MediaQuery/schema/{id}.json', ['id' => 'web_query']);
32+
$uri = 'https://{domain1}/Ray.MediaQuery/schema/{id}.json';
33+
$response = $webQuery->getHttpMessage('GET', $uri, ['id' => 'web_query']);
3134
$this->assertStringContainsString('"title": "Web query schema"', $response->getBody()->getContents());
3235
}
3336

0 commit comments

Comments
 (0)