Skip to content

Commit 444d3ed

Browse files
Merge pull request #62 from TheDragonCode/1.x
Added type coverage tests
2 parents 9a2ff1a + b35ccb7 commit 444d3ed

File tree

8 files changed

+41
-17
lines changed

8 files changed

+41
-17
lines changed

.github/workflows/tests.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33
on: [ push, pull_request ]
44

55
jobs:
6-
build:
6+
unit:
77
runs-on: ubuntu-latest
88

99
strategy:
@@ -30,3 +30,25 @@ jobs:
3030

3131
- name: Execute tests
3232
run: composer test
33+
34+
type:
35+
runs-on: ubuntu-latest
36+
37+
name: Type Coverage
38+
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v5
42+
43+
- name: Setup PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php }}
47+
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv
48+
coverage: xdebug
49+
50+
- name: Install dependencies
51+
run: composer update
52+
53+
- name: Execute tests
54+
run: composer lint:type

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"orchestra/testbench": "^9.0 || ^10.0",
2828
"pestphp/pest": "^3.0 || ^4.0",
2929
"pestphp/pest-plugin-laravel": "^3.0 || ^4.0",
30+
"pestphp/pest-plugin-type-coverage": "^3.0 || ^4.0",
3031
"symfony/var-dumper": "^7.3"
3132
},
3233
"minimum-stability": "stable",
@@ -69,6 +70,7 @@
6970
],
7071
"build": "@php vendor/bin/testbench workbench:build --ansi",
7172
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
73+
"lint:type": "@php vendor/bin/pest --type-coverage --compact --min=95",
7274
"migrate": "@php vendor/bin/testbench migrate:fresh --seed --ansi",
7375
"prepare": "@php vendor/bin/testbench package:discover --ansi",
7476
"style": "vendor/bin/pint --parallel --ansi",

src/Console/Commands/FeedInfoMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function getStub(): string
2121
return __DIR__ . '/../../../stubs/feed_info.stub';
2222
}
2323

24-
protected function getDefaultNamespace($rootNamespace): string
24+
protected function getDefaultNamespace($rootNamespace): string // @pest-ignore-type
2525
{
2626
return $rootNamespace . '\Feeds\Info';
2727
}

src/Console/Commands/FeedItemMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function getStub(): string
2121
return __DIR__ . '/../../../stubs/feed_item.stub';
2222
}
2323

24-
protected function getDefaultNamespace($rootNamespace): string
24+
protected function getDefaultNamespace($rootNamespace): string // @pest-ignore-type
2525
{
2626
return $rootNamespace . '\Feeds\Items';
2727
}

src/Console/Commands/FeedMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function getStub(): string
8080
return __DIR__ . '/../../../stubs/feed.stub';
8181
}
8282

83-
protected function getDefaultNamespace($rootNamespace): string
83+
protected function getDefaultNamespace($rootNamespace): string // @pest-ignore-type
8484
{
8585
return $rootNamespace . '\Feeds';
8686
}

src/Converters/ConvertToXml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected function setMixed(DOMNode $element, string $value): void
128128
$element->appendChild($fragment);
129129
}
130130

131-
protected function setItemsArray(DOMNode $parent, $value, string $key): void
131+
protected function setItemsArray(DOMNode $parent, array $value, string $key): void
132132
{
133133
$key = Str::substr($key, 1);
134134

src/Services/Filesystem.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(
2424
/**
2525
* @return resource
2626
*/
27-
public function open(string $path)
27+
public function open(string $path) // @pest-ignore-type
2828
{
2929
$path = $this->draft($path);
3030

@@ -43,7 +43,7 @@ public function open(string $path)
4343
/**
4444
* @param resource $resource
4545
*/
46-
public function append($resource, string $content, string $path): void
46+
public function append($resource, string $content, string $path): void // @pest-ignore-type
4747
{
4848
if (blank($content)) {
4949
return;
@@ -57,7 +57,7 @@ public function append($resource, string $content, string $path): void
5757
/**
5858
* @param resource $resource
5959
*/
60-
public function release($resource, string $path): void
60+
public function release($resource, string $path): void // @pest-ignore-type
6161
{
6262
$this->close($resource);
6363

@@ -74,7 +74,7 @@ public function release($resource, string $path): void
7474
/**
7575
* @param resource $resource
7676
*/
77-
public function close($resource): void
77+
public function close($resource): void // @pest-ignore-type
7878
{
7979
if (! is_resource($resource)) {
8080
return;

src/Services/Generator.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function feed(Feed $feed): void
4141
$this->setLastActivity($feed);
4242
}
4343

44-
protected function performItem($file, Feed $feed): void
44+
protected function performItem($file, Feed $feed): void // @pest-ignore-type
4545
{
4646
$feed->builder()->chunkById($feed->chunkSize(), function (Collection $models) use ($file, $feed) {
4747
$content = [];
@@ -56,12 +56,12 @@ protected function performItem($file, Feed $feed): void
5656
});
5757
}
5858

59-
protected function performHeader($file, Feed $feed): void
59+
protected function performHeader($file, Feed $feed): void // @pest-ignore-type
6060
{
6161
$this->append($file, $feed->header(), $feed->path());
6262
}
6363

64-
protected function performInfo($file, Feed $feed): void
64+
protected function performInfo($file, Feed $feed): void // @pest-ignore-type
6565
{
6666
if (blank($info = $feed->info()->toArray())) {
6767
return;
@@ -72,7 +72,7 @@ protected function performInfo($file, Feed $feed): void
7272
$this->append($file, PHP_EOL . $value, $feed->path());
7373
}
7474

75-
protected function performRoot($file, Feed $feed): void
75+
protected function performRoot($file, Feed $feed): void // @pest-ignore-type
7676
{
7777
if (! $name = $feed->root()->name) {
7878
return;
@@ -85,7 +85,7 @@ protected function performRoot($file, Feed $feed): void
8585
$this->append($file, $value, $feed->path());
8686
}
8787

88-
protected function performFooter($file, Feed $feed): void
88+
protected function performFooter($file, Feed $feed): void // @pest-ignore-type
8989
{
9090
$value = '';
9191

@@ -105,17 +105,17 @@ protected function makeRootAttributes(ElementData $item): string
105105
->implode(' ');
106106
}
107107

108-
protected function append($file, string $content, string $path): void
108+
protected function append($file, string $content, string $path): void // @pest-ignore-type
109109
{
110110
$this->filesystem->append($file, $content, $path);
111111
}
112112

113-
protected function release($file, string $path): void
113+
protected function release($file, string $path): void // @pest-ignore-type
114114
{
115115
$this->filesystem->release($file, $path);
116116
}
117117

118-
protected function openFile(string $path)
118+
protected function openFile(string $path) // @pest-ignore-type
119119
{
120120
return $this->filesystem->open($path);
121121
}

0 commit comments

Comments
 (0)