Skip to content

Commit 11f6086

Browse files
Merge pull request #68 from TheDragonCode/1.x
Added coverage test
2 parents 5aa5ea1 + 728cc5c commit 11f6086

29 files changed

+384
-21
lines changed

.github/workflows/tests.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Execute tests
3232
run: composer test
3333

34-
type:
34+
type_coverage:
3535
runs-on: ubuntu-latest
3636

3737
name: Type Coverage
@@ -51,4 +51,26 @@ jobs:
5151
run: composer update
5252

5353
- name: Execute tests
54-
run: composer lint:type-coverage
54+
run: composer test:type-coverage
55+
56+
coverage:
57+
runs-on: ubuntu-latest
58+
59+
name: Coverage
60+
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v5
64+
65+
- name: Setup PHP
66+
uses: shivammathur/setup-php@v2
67+
with:
68+
php-version: ${{ matrix.php }}
69+
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv
70+
coverage: xdebug
71+
72+
- name: Install dependencies
73+
run: composer update
74+
75+
- name: Execute tests
76+
run: composer test:coverage

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@
7070
],
7171
"build": "@php vendor/bin/testbench workbench:build --ansi",
7272
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
73-
"lint:type-coverage": "@php vendor/bin/pest --type-coverage --compact --min=95",
7473
"migrate": "@php vendor/bin/testbench migrate:fresh --seed --ansi",
7574
"prepare": "@php vendor/bin/testbench package:discover --ansi",
7675
"style": "vendor/bin/pint --parallel --ansi",
7776
"test": "@php vendor/bin/pest --parallel --colors=always",
77+
"test:coverage": "@php vendor/bin/pest --colors=always --coverage --compact --parallel --min=95",
78+
"test:type-coverage": "@php vendor/bin/pest --type-coverage --compact --min=95",
7879
"test:update": "@php vendor/bin/pest --colors=always --update-snapshots"
7980
}
8081
}

src/Commands/FeedGenerateCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ protected function feedable(FeedQuery $feeds): array
4949
protected function messageYellow(string $message): string
5050
{
5151
if ($this->option('no-ansi')) {
52+
// @codeCoverageIgnoreStart
5253
return $message;
54+
// @codeCoverageIgnoreEnd
5355
}
5456

5557
return $this->yellow($message);

src/Exceptions/OpenFeedException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
use RuntimeException;
88

9+
// @codeCoverageIgnoreStart
910
class OpenFeedException extends RuntimeException
1011
{
1112
public function __construct(string $path)
1213
{
1314
parent::__construct("Unable to open file for writing: [$path]");
1415
}
1516
}
17+
// @codeCoverageIgnoreEnd

src/Exceptions/WriteFeedException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
use RuntimeException;
88

9+
// @codeCoverageIgnoreStart
910
class WriteFeedException extends RuntimeException
1011
{
1112
public function __construct(string $path)
1213
{
1314
parent::__construct("Failed to write to the feed: [$path].");
1415
}
1516
}
17+
// @codeCoverageIgnoreEnd

src/Helpers/ClassExistsHelper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
use function class_exists;
88

9+
// @codeCoverageIgnoreStart
910
class ClassExistsHelper
1011
{
1112
public function exists(string $class): bool
1213
{
1314
return class_exists($class);
1415
}
1516
}
17+
// @codeCoverageIgnoreEnd

src/LaravelFeedServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ public function register(): void
1919

2020
public function boot(): void
2121
{
22+
// @codeCoverageIgnoreStart
2223
if (! $this->app->runningInConsole()) {
2324
return;
2425
}
26+
// @codeCoverageIgnoreEnd
2527

2628
$this->registerCommands();
2729
$this->publishConfig();

src/Services/FilesystemService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function open(string $path) // @pest-ignore-type
3434
$resource = fopen($path, 'ab');
3535

3636
if ($resource === false) {
37+
// @codeCoverageIgnoreStart
3738
throw new OpenFeedException($path);
39+
// @codeCoverageIgnoreEnd
3840
}
3941

4042
return $resource;
@@ -50,7 +52,9 @@ public function append($resource, string $content, string $path): void // @pest-
5052
}
5153

5254
if (fwrite($resource, $content) === false) {
55+
// @codeCoverageIgnoreStart
5356
throw new WriteFeedException($path);
57+
// @codeCoverageIgnoreEnd
5458
}
5559
}
5660

@@ -77,7 +81,9 @@ public function release($resource, string $path): void // @pest-ignore-type
7781
public function close($resource): void // @pest-ignore-type
7882
{
7983
if (! is_resource($resource)) {
84+
// @codeCoverageIgnoreStart
8085
return;
86+
// @codeCoverageIgnoreEnd
8187
}
8288

8389
fclose($resource);
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<FullFeed>
3-
<news><record_title>[NEWS]:Some 1</record_title><record_content>Some content 1</record_content><extra>Some extra data</extra><with_attributes><Good_guy my-key-1="my value 1" my-key-2="my value 2"><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name><![CDATA[<h1>Sauron</h1>]]></name><weapon>Evil Eye</weapon></Bad_guy></with_attributes></news>
4-
<news><record_title>[NEWS]:Some 2</record_title><record_content>Some content 2</record_content><extra>Some extra data</extra><with_attributes><Good_guy my-key-1="my value 1" my-key-2="my value 2"><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name><![CDATA[<h1>Sauron</h1>]]></name><weapon>Evil Eye</weapon></Bad_guy></with_attributes></news>
5-
<news><record_title>[NEWS]:Some 3</record_title><record_content>Some content 3</record_content><extra>Some extra data</extra><with_attributes><Good_guy my-key-1="my value 1" my-key-2="my value 2"><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name><![CDATA[<h1>Sauron</h1>]]></name><weapon>Evil Eye</weapon></Bad_guy></with_attributes></news>
3+
<news><record_title>[NEWS]:Some 1</record_title><record_content>Some content 1</record_content><extra>Some extra data</extra><with_attributes><Good_guy my-key-1="my value 1" my-key-2="my value 2"><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name><![CDATA[<h1>Sauron</h1>]]></name><weapon>Evil Eye</weapon></Bad_guy></with_attributes><with_mixed><first>line</first>
4+
<second>line with <a href="https://example.com">some</a> html/xml tag</second>
5+
<third>line with &amp; symbol</third></with_mixed></news>
6+
<news><record_title>[NEWS]:Some 2</record_title><record_content>Some content 2</record_content><extra>Some extra data</extra><with_attributes><Good_guy my-key-1="my value 1" my-key-2="my value 2"><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name><![CDATA[<h1>Sauron</h1>]]></name><weapon>Evil Eye</weapon></Bad_guy></with_attributes><with_mixed><first>line</first>
7+
<second>line with <a href="https://example.com">some</a> html/xml tag</second>
8+
<third>line with &amp; symbol</third></with_mixed></news>
9+
<news><record_title>[NEWS]:Some 3</record_title><record_content>Some content 3</record_content><extra>Some extra data</extra><with_attributes><Good_guy my-key-1="my value 1" my-key-2="my value 2"><name>Luke Skywalker</name><weapon>Lightsaber</weapon></Good_guy><Bad_guy><name><![CDATA[<h1>Sauron</h1>]]></name><weapon>Evil Eye</weapon></Bad_guy></with_attributes><with_mixed><first>line</first>
10+
<second>line with <a href="https://example.com">some</a> html/xml tag</second>
11+
<third>line with &amp; symbol</third></with_mixed></news>
612
</FullFeed>

tests/.pest/snapshots/Feature/Feeds/FullTest/export_with_data_set____true__.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<weapon>Evil Eye</weapon>
1515
</Bad_guy>
1616
</with_attributes>
17+
<with_mixed><first>line</first>
18+
<second>line with <a href="https://example.com">some</a> html/xml tag</second>
19+
<third>line with &amp; symbol</third></with_mixed>
1720
</news>
1821
<news>
1922
<record_title>[NEWS]:Some 2</record_title>
@@ -29,6 +32,9 @@
2932
<weapon>Evil Eye</weapon>
3033
</Bad_guy>
3134
</with_attributes>
35+
<with_mixed><first>line</first>
36+
<second>line with <a href="https://example.com">some</a> html/xml tag</second>
37+
<third>line with &amp; symbol</third></with_mixed>
3238
</news>
3339
<news>
3440
<record_title>[NEWS]:Some 3</record_title>
@@ -44,5 +50,8 @@
4450
<weapon>Evil Eye</weapon>
4551
</Bad_guy>
4652
</with_attributes>
53+
<with_mixed><first>line</first>
54+
<second>line with <a href="https://example.com">some</a> html/xml tag</second>
55+
<third>line with &amp; symbol</third></with_mixed>
4756
</news>
4857
</FullFeed>

0 commit comments

Comments
 (0)