File tree Expand file tree Collapse file tree 6 files changed +123
-6
lines changed Expand file tree Collapse file tree 6 files changed +123
-6
lines changed Original file line number Diff line number Diff line change 1
- /vendor /
1
+ .phpunit.cache
2
+ .phpunit.result.cache
3
+ .pint.cache.json
2
4
/.idea
3
5
/composer.lock
4
6
/tests /_coverage
5
- .phpunit.result.cache
6
- .pint.cache.json
7
+ /vendor /
8
+ build
9
+ coverage
10
+ phpunit.xml
Original file line number Diff line number Diff line change 34
34
},
35
35
"require-dev" : {
36
36
"laravel/framework" : " ^10.0" ,
37
- "laravel/pint" : " ^1.10"
37
+ "laravel/pint" : " ^1.10" ,
38
+ "orchestra/testbench" : " ^8.8" ,
39
+ "pestphp/pest" : " ^2.20" ,
40
+ "pestphp/pest-plugin-arch" : " ^2.0" ,
41
+ "pestphp/pest-plugin-laravel" : " ^2.0"
38
42
},
39
43
"autoload" : {
40
44
"psr-4" : {
41
45
"Onlime\\ LaravelHttpClientGlobalLogger\\ " : " src/"
42
46
}
43
47
},
48
+ "autoload-dev" : {
49
+ "psr-4" : {
50
+ "Onlime\\ LaravelHttpClientGlobalLogger\\ Tests\\ " : " tests/"
51
+ }
52
+ },
53
+ "scripts" : {
54
+ "test" : " vendor/bin/pest" ,
55
+ "test-coverage" : " vendor/bin/pest --coverage" ,
56
+ "format" : " vendor/bin/pint"
57
+ },
44
58
"config" : {
45
- "sort-packages" : true
59
+ "sort-packages" : true ,
60
+ "allow-plugins" : {
61
+ "pestphp/pest-plugin" : true
62
+ }
46
63
},
47
64
"extra" : {
48
65
"laravel" : {
53
70
},
54
71
"minimum-stability" : " stable" ,
55
72
"prefer-stable" : true
56
- }
73
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <phpunit
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/10.2/phpunit.xsd"
5
+ backupGlobals =" false"
6
+ bootstrap =" vendor/autoload.php"
7
+ colors =" true"
8
+ processIsolation =" false"
9
+ stopOnFailure =" false"
10
+ executionOrder =" random"
11
+ failOnWarning =" true"
12
+ failOnRisky =" true"
13
+ failOnEmptyTestSuite =" true"
14
+ beStrictAboutOutputDuringTests =" true"
15
+ cacheDirectory =" .phpunit.cache"
16
+ backupStaticProperties =" false"
17
+ >
18
+ <testsuites >
19
+ <testsuite name =" VendorName Test Suite" >
20
+ <directory >tests</directory >
21
+ </testsuite >
22
+ </testsuites >
23
+ <coverage >
24
+ <report >
25
+ <html outputDirectory =" build/coverage" />
26
+ <text outputFile =" build/coverage.txt" />
27
+ <clover outputFile =" build/logs/clover.xml" />
28
+ </report >
29
+ </coverage >
30
+ <logging >
31
+ <junit outputFile =" build/report.junit.xml" />
32
+ </logging >
33
+ <source >
34
+ <include >
35
+ <directory suffix =" .php" >./src</directory >
36
+ </include >
37
+ </source >
38
+ </phpunit >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Illuminate \Support \Facades \Http ;
4
+ use Illuminate \Support \Facades \Log ;
5
+ use Onlime \LaravelHttpClientGlobalLogger \HttpClientLogger ;
6
+ use Psr \Http \Message \RequestInterface ;
7
+ use Psr \Log \LoggerInterface ;
8
+
9
+ it ('can add a global request middleware to log the requests ' , function () {
10
+ Http::globalRequestMiddleware (
11
+ fn (RequestInterface $ psrRequest ) => $ psrRequest ->withHeader ('X-Test ' , 'test ' )
12
+ );
13
+
14
+ HttpClientLogger::addRequestMiddleware ();
15
+
16
+ $ logger = Mockery::mock (LoggerInterface::class);
17
+
18
+ Log::shouldReceive ('channel ' )->with ('http-client ' )->andReturn ($ logger );
19
+
20
+ $ logger ->shouldReceive ('info ' )->withArgs (function ($ message ) {
21
+ expect ($ message )
22
+ ->toContain ('REQUEST: GET https://example.com ' )
23
+ ->and ($ message )
24
+ ->toContain ('X-Test: test ' );
25
+
26
+ return true ;
27
+ })->once ()->andReturnSelf ();
28
+
29
+ $ logger ->shouldReceive ('info ' )->withArgs (function ($ message ) {
30
+ expect ($ message )
31
+ ->toContain ('RESPONSE: HTTP/1.1 200 OK ' );
32
+
33
+ return true ;
34
+ })->once ()->andReturnSelf ();
35
+
36
+ Http::fake ()->get ('https://example.com ' );
37
+ });
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Onlime \LaravelHttpClientGlobalLogger \Tests \TestCase ;
4
+
5
+ uses (TestCase::class)->in (__DIR__ );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Onlime \LaravelHttpClientGlobalLogger \Tests ;
4
+
5
+ use Onlime \LaravelHttpClientGlobalLogger \Providers \ServiceProvider ;
6
+ use Orchestra \Testbench \TestCase as Orchestra ;
7
+
8
+ class TestCase extends Orchestra
9
+ {
10
+ protected function getPackageProviders ($ app )
11
+ {
12
+ return [
13
+ ServiceProvider::class,
14
+ ];
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments