Skip to content

Commit

Permalink
Merge pull request #8 from worksome/feature/pest-tests
Browse files Browse the repository at this point in the history
ci: add initial Pest tests
  • Loading branch information
owenvoke authored Aug 16, 2024
2 parents b9e16d5 + decb4af commit 1294aaa
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/docs export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Tests

on:
pull_request:
push:
branches:
- master

jobs:
php-tests:
name: Testing on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.2, 8.3]
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Setup Problem Matches
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install PHP dependencies
run: composer update --no-interaction --no-progress --ansi

- name: Unit Tests
run: composer test --ansi
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
vendor
composer.lock
/build
/vendor
/.phpunit.cache
/.php-cs-fixer.cache
/composer.lock
/phpunit.xml
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"pest_2.35.0","defects":{"P\\Tests\\Feature\\FoggyTest::__pest_evaluable_it_is_deferred":7},"times":{"P\\Tests\\Feature\\FoggyTest::__pest_evaluable_it_is_deferred":0.031,"P\\Tests\\Feature\\FoggyTest::__pest_evaluable_it_registers_the_Docker_command":0.027,"P\\Tests\\Feature\\FoggyTest::__pest_evaluable_it_registers_the__db_dump__command":0.022,"P\\Tests\\Feature\\FoggyServiceProviderTest::__pest_evaluable_it_registers_the__db_dump__command":0.014}}
23 changes: 22 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,34 @@
"thecodingmachine/safe": "^2.5",
"worksome/foggy": "^0.6"
},
"require-dev": {
"orchestra/testbench": "^8.21 || ^9.0",
"pestphp/pest": "^2.33",
"pestphp/pest-plugin-laravel": "^2.2"
},
"autoload": {
"psr-4": {
"Worksome\\FoggyLaravel\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Worksome\\FoggyLaravel\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"test:unit": "vendor/bin/pest -p",
"test:coverage": "vendor/bin/pest -p --coverage",
"test": [
"@test:unit"
]
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"extra": {
"laravel": {
Expand Down
17 changes: 17 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
14 changes: 14 additions & 0 deletions tests/Feature/FoggyServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Worksome\FoggyLaravel\DatabaseDumpCommand;
use Worksome\FoggyLaravel\FoggyServiceProvider;

it('registers the `db:dump` command', function () {
$provider = new FoggyServiceProvider($this->app);

$provider->register();

$this->assertInstanceOf(DatabaseDumpCommand::class, $this->app[DatabaseDumpCommand::class]);
});
7 changes: 7 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

use Worksome\FoggyLaravel\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
18 changes: 18 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Worksome\FoggyLaravel\Tests;

use Orchestra\Testbench\TestCase as Orchestra;
use Worksome\FoggyLaravel\FoggyServiceProvider;

class TestCase extends Orchestra
{
protected function getPackageProviders($app): array
{
return [
FoggyServiceProvider::class,
];
}
}

0 comments on commit 1294aaa

Please sign in to comment.