Skip to content

Commit b5a89b1

Browse files
authored
Test PhpNetReleasesTest::all() in unit tests (#52)
1 parent 91bf06b commit b5a89b1

File tree

7 files changed

+36
-83
lines changed

7 files changed

+36
-83
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ jobs:
2828
- uses: ramsey/composer-install@v3
2929

3030
- run: composer pest:unit -- --coverage-clover coverage-unit.xml --ci --bail --stop-on-incomplete --fail-on-all-issues
31-
- run: composer pest:feature -- --coverage-clover coverage-feature.xml --ci --bail --stop-on-incomplete --fail-on-all-issues
3231

3332
- uses: actions/upload-artifact@v4
3433
with:
3534
name: coverage
36-
path: |
37-
coverage-unit.xml
38-
coverage-feature.xml
35+
path: coverage-unit.xml
3936

4037
e2e:
4138
needs: pest
@@ -70,10 +67,3 @@ jobs:
7067
disable_search: true
7168
files: coverage-unit.xml
7269
flags: unit
73-
- uses: codecov/codecov-action@v5
74-
with:
75-
use_oidc: true
76-
fail_ci_if_error: true
77-
disable_search: true
78-
files: coverage-feature.xml
79-
flags: feature

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
],
7676
"pest": "pest",
7777
"pest:e2e": "XDEBUG_MODE=off pest --group=e2e",
78-
"pest:feature": "pest --group=feature",
7978
"pest:unit": "pest --group=unit"
8079
}
8180
}

tests/Feature/Releases/PhpNetReleasesTest.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/Feature/TestCase.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/Pest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
declare(strict_types=1);
44

55
use Tests\E2E\TestCase as E2ETestCase;
6-
use Tests\Feature\TestCase as FeatureTestCase;
76
use Tests\Unit\TestCase as UnitTestCase;
87

98
/*
@@ -16,9 +15,6 @@
1615
pest()->group('e2e')
1716
->in('E2E');
1817

19-
pest()->group('feature')
20-
->in('Feature');
21-
2218
pest()->group('unit')
2319
->in('Unit');
2420

@@ -36,9 +32,6 @@
3632
pest()->extend(E2ETestCase::class)
3733
->in('E2E');
3834

39-
pest()->extend(FeatureTestCase::class)
40-
->in('Feature');
41-
4235
pest()->extend(UnitTestCase::class)
4336
->in('Unit');
4437

tests/TestCase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ abstract class TestCase extends BaseTestCase
1010

1111
protected const string ALL_VERSIONS_FILE = __DIR__.'/../resources/all-versions.json';
1212

13+
protected const array RELEASES_JSONS = [
14+
self::DATA_DIR.'/releases-5.json',
15+
self::DATA_DIR.'/releases-7.json',
16+
self::DATA_DIR.'/releases-8.json',
17+
];
18+
1319
/**
1420
* @return string[]
1521
*/

tests/Unit/Releases/PhpNetReleasesTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
namespace Tests\Unit\Releases;
66

7+
use GuzzleHttp\Client as Http;
8+
use GuzzleHttp\Handler\MockHandler;
9+
use GuzzleHttp\HandlerStack;
10+
use GuzzleHttp\Psr7\Response;
711
use TypistTech\PhpMatrix\Releases\PhpNetReleases;
812
use TypistTech\PhpMatrix\Releases\ReleasesInterface;
913

@@ -15,4 +19,29 @@
1519

1620
expect($releases)->toBeInstanceOf(ReleasesInterface::class);
1721
});
22+
23+
describe('::all()', static function (): void {
24+
it('fetches all versions', function () {
25+
$mock = new MockHandler;
26+
foreach ($this::RELEASES_JSONS as $json) {
27+
$body = file_get_contents($json);
28+
$mock->append(
29+
new Response(202, [], $body),
30+
);
31+
}
32+
$handlerStack = HandlerStack::create($mock);
33+
$http = new Http(['handler' => $handlerStack]);
34+
35+
$releases = new PhpNetReleases($http);
36+
37+
$actual = $releases->all();
38+
39+
expect($actual)->each->toBeString();
40+
41+
$expected = $this->allVersions();
42+
43+
expect($actual)->toContain(...$expected);
44+
expect($expected)->toContain(...$actual);
45+
});
46+
});
1847
});

0 commit comments

Comments
 (0)