Skip to content

Commit

Permalink
(feat): test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonvanWijhe committed Jun 11, 2024
1 parent 2014ae2 commit 0e608c4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: run-tests
name: Unit Tests with coverage

on:
pull_request:
Expand Down Expand Up @@ -36,8 +36,9 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, xdebug
coverage: xdebug
tools: composer:v2
env:
COMPOSER_TOKEN: ${{ secrets.YARD_BOT_PAT }}

Expand All @@ -55,4 +56,9 @@ jobs:
run: composer show -D

- name: Execute tests
run: vendor/bin/pest --ci
run: vendor/bin/pest --coverage-clover=coverage.xml

- name: Coverage Report as Comment (Clover)
uses: lucassabreu/comment-coverage-clover@main
with:
file: coverage.xml
7 changes: 7 additions & 0 deletions tests/Console/ExampleCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

it('can retrieve a random inspirational quote', function () {
$this->artisan('example')
->expectsOutput('For every Sage there is an Acorn.')
->assertExitCode(0);
});
7 changes: 5 additions & 2 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

declare(strict_types=1);

it('can run tests', function () {
$this->assertTrue(true);
it('can retrieve a random inspirational quote', function () {
$quote = app()->make('Example')->getQuote();

expect($quote)->toBeString();
expect($quote)->tobe('For every Sage there is an Acorn.');
});
9 changes: 9 additions & 0 deletions tests/Facades/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Yard\SkeletonPackage\Facades\Example;

it('can retrieve a random inspirational quote', function () {
$quote = Example::getQuote();

expect($quote)->tobe('For every Sage there is an Acorn.');
});
12 changes: 12 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@

class TestCase extends Orchestra
{
/**
* Get package providers.
*
* @param \Illuminate\Foundation\Application $app
* @return array<int, class-string<\Illuminate\Support\ServiceProvider>>
*/
protected function getPackageProviders($app)
{
return [
'Yard\SkeletonPackage\ExampleServiceProvider',
];
}
}

0 comments on commit 0e608c4

Please sign in to comment.