From 9c7ab6d62de77117e63e6944eeeb0eaae5480298 Mon Sep 17 00:00:00 2001 From: Glendon Solsberry Date: Tue, 17 Nov 2020 10:31:48 -0500 Subject: [PATCH] Initial pass at some tests --- .github/workflows/run-tests.yml | 55 +++++++++++++++++++++++++++++++++ composer.json | 14 ++++++--- phpunit.xml.dist | 24 ++++++++++++++ tests/BaseTest.php | 11 +++++++ tests/TestCase.php | 30 ++++++++++++++++++ 5 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/run-tests.yml create mode 100644 phpunit.xml.dist create mode 100644 tests/BaseTest.php create mode 100644 tests/TestCase.php diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 000000000..1d37ad336 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,55 @@ +name: run-tests + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + test: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + timeout-minutes: 15 + runs-on: ${{ matrix.os }} + strategy: + matrix: + php: [7.2, 7.3, 7.4] + dependency-version: [prefer-lowest, prefer-stable] + os: [ubuntu-latest, windows-latest] + + name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.composer/cache/files + key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + restore-keys: | + dependencies-php-${{ matrix.php }}-composer- + dependencies-php- + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: json, dom, curl, libxml, mbstring + coverage: none + + - name: Install dependencies + run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit + + - name: Send Slack notification + uses: 8398a7/action-slack@v2 + if: failure() && github.ref == 'refs/heads/master' + with: + status: ${{ job.status }} + author_name: ${{ github.actor }} + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/composer.json b/composer.json index 002926d0f..8dff8f982 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "chrisbjr/api-guard", + "name": "expanse/api-guard", "description": "A simple way of authenticating your APIs with API keys using Laravel", "keywords": [ "api", @@ -9,8 +9,12 @@ "api authentication", "laravel" ], - "homepage": "https://github.com/chrisbjr/api-guard", + "homepage": "https://github.com/expanse/api-guard", "authors": [ + { + "name": "Glen Solsberry", + "email": "gms8994@gmail.com" + }, { "name": "Chris Bautista", "email": "chrisbjr@gmail.com" @@ -27,11 +31,13 @@ "ellipsesynergie/api-response": "*" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^8.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^8.0", + "orchestra/testbench": "^4.0" }, "autoload": { "psr-4": { - "Chrisbjr\\ApiGuard\\": "src" + "Chrisbjr\\ApiGuard\\": "src", + "Chrisbjr\\ApiGuard\\Tests\\": "tests" } }, "minimum-stability": "stable" diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000000000..7c36b1050 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + ./tests/ + + + + + + + + diff --git a/tests/BaseTest.php b/tests/BaseTest.php new file mode 100644 index 000000000..4cc2adc2d --- /dev/null +++ b/tests/BaseTest.php @@ -0,0 +1,11 @@ +assertSame(1 + 1, 2); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 000000000..63ec62e57 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,30 @@ +set('database.default', 'testbench'); + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + } +}