Skip to content

Commit 5ce58d9

Browse files
Refactor linter configuration and update Composer scripts for improved code quality checks. (#260)
1 parent 82023cf commit 5ce58d9

7 files changed

Lines changed: 43 additions & 39 deletions

File tree

.github/workflows/linter.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@ on:
2424
jobs:
2525
phpcs:
2626
uses: yiisoft/yii2-actions/.github/workflows/linter.yml@master
27-
with:
28-
directories: src/ tests/

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
This extension provides the HTTP client for the [Yii framework 2.0](https://www.yiiframework.com).
1212

13-
For license information check the [LICENSE](LICENSE.md)-file.
14-
15-
Documentation is at [docs/guide/README.md](docs/guide/README.md).
16-
1713
[![Latest Stable Version](https://img.shields.io/packagist/v/yiisoft/yii2-httpclient.svg?style=for-the-badge&label=Stable&logo=packagist)](https://packagist.org/packages/yiisoft/yii2-httpclient)
1814
[![Total Downloads](https://img.shields.io/packagist/dt/yiisoft/yii2-httpclient.svg?style=for-the-badge&label=Downloads)](https://packagist.org/packages/yiisoft/yii2-httpclient)
1915
[![build](https://img.shields.io/github/actions/workflow/status/yiisoft/yii2-httpclient/build.yml?style=for-the-badge&logo=github&label=Build)](https://github.com/yiisoft/yii2-httpclient/actions?query=workflow%3Abuild)
@@ -45,7 +41,7 @@ to the require section of your composer.json.
4541

4642
## Documentation
4743

48-
- [Internals](docs/internals.md)
44+
- [the guide](docs/guide/README.md)
4945

5046
## Support the project
5147

@@ -57,3 +53,7 @@ to the require section of your composer.json.
5753
[![Follow on X](https://img.shields.io/badge/-Follow%20on%20X-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white&labelColor=000000)](https://x.com/yiiframework)
5854
[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=for-the-badge&logo=telegram)](https://t.me/yii_framework_in_english)
5955
[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=for-the-badge&logo=slack)](https://yiiframework.com/go/slack)
56+
57+
## License
58+
59+
[![License](https://img.shields.io/badge/License-BSD--3--Clause-brightgreen.svg?style=for-the-badge&logo=opensourceinitiative&logoColor=white&labelColor=555555)](LICENSE.md)

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
}
5252
},
5353
"scripts": {
54-
"cs": "./vendor/bin/phpcs -q src tests",
55-
"cs-fix": "./vendor/bin/phpcbf -q src tests",
54+
"cs": "./vendor/bin/phpcs",
55+
"cs-fix": "./vendor/bin/phpcbf",
5656
"static": "./vendor/bin/phpstan --memory-limit=-1",
5757
"tests": "./vendor/bin/phpunit"
5858
}

docs/guide/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ Additional topics
2626
-----------------
2727

2828
* [Using the HTTP client DebugPanel](topics-debug.md)
29+
30+
Contributing
31+
------------
32+
* [Internals](internals.md)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Testing
1+
# Internals
22

33
This package provides a consistent set of [Composer](https://getcomposer.org/) scripts for local validation.
44

phpcs.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<!-- generate relative paths -->
66
<arg name="basepath" value="src"/>
77

8+
<!-- directories to check -->
9+
<file>src</file>
10+
<file>tests</file>
11+
812
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
913
<exclude-pattern>/Request\.php$</exclude-pattern>
1014
<exclude-pattern>/MockTransport\.php$</exclude-pattern>

tests/TransportTestCase.php

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ private function assertResponseIsOK(Response $response): void
4040
public function testSend(): void
4141
{
4242
$client = $this->createClient();
43-
$client->baseUrl = 'https://www.php.net/';
43+
$client->baseUrl = 'https://www.yiiframework.com/';
4444
$response = $client->createRequest()
4545
->setMethod('GET')
46-
->setUrl('docs.php')
46+
->setUrl('doc/guide/2.0/en/start-installation')
4747
->send();
4848

4949
$this->assertResponseIsOK($response);
5050
$content = $response->getContent();
5151
$this->assertNotEmpty($content);
52-
$this->assertStringContainsString('<h1>Documentation</h1>', $content);
52+
$this->assertStringContainsString('The Definitive Guide to Yii 2.0', $content);
5353
}
5454

5555
/**
@@ -58,13 +58,15 @@ public function testSend(): void
5858
public function testSendPost(): void
5959
{
6060
$client = $this->createClient();
61-
$client->baseUrl = 'https://www.php.net/';
61+
$client->baseUrl = 'https://postman-echo.com/';
6262
$response = $client->createRequest()
6363
->setMethod('POST')
64-
->setUrl('search.php')
65-
->setData(['pattern' => 'curl'])
64+
->setUrl('post')
65+
->setData(['q' => 'yii'])
6666
->send();
67+
6768
$this->assertResponseIsOK($response);
69+
$this->assertNotEmpty($response->getContent());
6870
}
6971

7072
/**
@@ -73,15 +75,15 @@ public function testSendPost(): void
7375
public function testBatchSend(): void
7476
{
7577
$client = $this->createClient();
76-
$client->baseUrl = 'https://www.php.net/';
78+
$client->baseUrl = 'https://www.yiiframework.com/';
7779

7880
$requests = [];
7981
$requests['docs'] = $client->createRequest()
8082
->setMethod('GET')
81-
->setUrl('docs.php');
83+
->setUrl('doc/guide/2.0/en/start-installation');
8284
$requests['support'] = $client->createRequest()
8385
->setMethod('GET')
84-
->setUrl('support.php');
86+
->setUrl('community');
8587

8688
$responses = $client->batchSend($requests);
8789
$this->assertCount(count($requests), $responses);
@@ -93,8 +95,8 @@ public function testBatchSend(): void
9395
$this->assertInstanceOf(Response::class, $responses['docs']);
9496
$this->assertInstanceOf(Response::class, $responses['support']);
9597

96-
$this->assertStringContainsString('<h1>Documentation</h1>', $responses['docs']->getContent());
97-
$this->assertStringContainsString('Mailing Lists', $responses['support']->getContent());
98+
$this->assertStringContainsString('The Definitive Guide to Yii 2.0', $responses['docs']->getContent());
99+
$this->assertStringContainsString('Community Resources', $responses['support']->getContent());
98100
}
99101

100102
/**
@@ -103,15 +105,11 @@ public function testBatchSend(): void
103105
public function testFollowLocation(): void
104106
{
105107
$client = $this->createClient();
106-
$client->baseUrl = 'https://www.php.net/';
108+
$client->baseUrl = 'https://www.yiiframework.com/';
107109

108110
$request = $client->createRequest()
109111
->setMethod('GET')
110-
->setUrl('search.php')
111-
->setData([
112-
'show' => 'quickref',
113-
'pattern' => 'array_merge'
114-
]);
112+
->setUrl('doc/guide');
115113

116114
$response = $request->setOptions([
117115
'followLocation' => false,
@@ -147,11 +145,11 @@ public function testSendError(): void
147145
public function testSendEvents(): void
148146
{
149147
$client = $this->createClient();
150-
$client->baseUrl = 'https://www.php.net/';
148+
$client->baseUrl = 'https://www.yiiframework.com/';
151149

152150
$request = $client->createRequest()
153151
->setMethod('GET')
154-
->setUrl('docs.php');
152+
->setUrl('doc/guide/2.0/en/start-installation');
155153

156154
$beforeSendEvent = null;
157155
$request->on(Request::EVENT_BEFORE_SEND, function (RequestEvent $event) use (&$beforeSendEvent) {
@@ -180,11 +178,11 @@ public function testSendEvents(): void
180178
public function testClientSendEvents(): void
181179
{
182180
$client = $this->createClient();
183-
$client->baseUrl = 'https://www.php.net/';
181+
$client->baseUrl = 'https://www.yiiframework.com/';
184182

185183
$request = $client->createRequest()
186184
->setMethod('GET')
187-
->setUrl('docs.php');
185+
->setUrl('doc/guide/2.0/en/start-installation');
188186

189187
$beforeSendEvent = null;
190188
$client->on(Client::EVENT_BEFORE_SEND, function (RequestEvent $event) use (&$beforeSendEvent) {
@@ -214,7 +212,7 @@ public function testClientSendEvents(): void
214212
public function testBatchSendEvents(): void
215213
{
216214
$client = $this->createClient();
217-
$client->baseUrl = 'https://www.php.net';
215+
$client->baseUrl = 'https://www.yiiframework.com';
218216

219217
$beforeSendUrls = [];
220218
$client->on(Client::EVENT_BEFORE_SEND, function (RequestEvent $event) use (&$beforeSendUrls) {
@@ -229,16 +227,16 @@ public function testBatchSendEvents(): void
229227
$requests = [];
230228
$requests['docs'] = $client->createRequest()
231229
->setMethod('GET')
232-
->setUrl('docs.php');
230+
->setUrl('doc/guide/2.0/en/start-installation');
233231
$requests['support'] = $client->createRequest()
234232
->setMethod('GET')
235-
->setUrl('support.php');
233+
->setUrl('community');
236234

237235
$responses = $client->batchSend($requests);
238236

239237
$expectedUrls = [
240-
$client->baseUrl . '/docs.php',
241-
$client->baseUrl . '/support.php',
238+
$client->baseUrl . '/doc/guide/2.0/en/start-installation',
239+
$client->baseUrl . '/community',
242240
];
243241
$this->assertEquals($expectedUrls, $beforeSendUrls);
244242
$this->assertEquals($expectedUrls, $afterSendUrls);
@@ -291,10 +289,10 @@ public function testCustomSslCertificate(): void
291289
file_put_contents($privateKeyFilename, $privateKey);
292290

293291
$client = $this->createClient();
294-
$client->baseUrl = 'https://secure.php.net/';
292+
$client->baseUrl = 'https://www.yiiframework.com/';
295293
$response = $client->createRequest()
296294
->setMethod('GET')
297-
->setUrl('docs.php')
295+
->setUrl('doc/guide/2.0/en/start-installation')
298296
->setOptions([
299297
'sslLocalCert' => $publicKeyFilename,
300298
'sslLocalPk' => $privateKeyFilename,
@@ -305,6 +303,6 @@ public function testCustomSslCertificate(): void
305303
$this->assertResponseIsOK($response);
306304
$content = $response->getContent();
307305
$this->assertNotEmpty($content);
308-
$this->assertStringContainsString('<h1>Documentation</h1>', $content);
306+
$this->assertStringContainsString('The Definitive Guide to Yii 2.0', $content);
309307
}
310308
}

0 commit comments

Comments
 (0)