diff --git a/.gitattributes b/.gitattributes index 83f5ea0..fcb5009 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..da24d53 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.gitignore b/.gitignore index 7579f74..8a96a39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ -vendor -composer.lock +/build +/vendor +/.phpunit.cache +/.php-cs-fixer.cache +/composer.lock +/phpunit.xml diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..e048099 --- /dev/null +++ b/.phpunit.cache/test-results @@ -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}} \ No newline at end of file diff --git a/composer.json b/composer.json index e668325..f66694f 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..8d77cf6 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,17 @@ + + + + + tests + + + + + src + + + diff --git a/tests/Feature/FoggyServiceProviderTest.php b/tests/Feature/FoggyServiceProviderTest.php new file mode 100644 index 0000000..9bc3a59 --- /dev/null +++ b/tests/Feature/FoggyServiceProviderTest.php @@ -0,0 +1,14 @@ +app); + + $provider->register(); + + $this->assertInstanceOf(DatabaseDumpCommand::class, $this->app[DatabaseDumpCommand::class]); +}); diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..33e332c --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,7 @@ +in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..d556a77 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,18 @@ +