Skip to content

Commit

Permalink
Initial pass at some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gms8994 committed Nov 17, 2020
1 parent 5ee75eb commit 9c7ab6d
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 4 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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": "[email protected]"
},
{
"name": "Chris Bautista",
"email": "[email protected]"
Expand All @@ -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"
Expand Down
24 changes: 24 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true">
<testsuites>
<testsuite name="ApiGuard Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<php>
<env name="DB_CONNECTION" value="testing"/>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
</phpunit>
11 changes: 11 additions & 0 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Chrisbjr\ApiGuard\Tests;

class BaseTest extends TestCase
{
public function test_first()
{
$this->assertSame(1 + 1, 2);
}
}
30 changes: 30 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Chrisbjr\ApiGuard\Tests;

class TestCase extends \Orchestra\Testbench\TestCase
{
protected function getPackageProviders($app)
{
return [
\Chrisbjr\ApiGuard\Providers\ApiGuardServiceProvider::class
];
}

/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
// Setup default database to use sqlite :memory:
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
}
}

0 comments on commit 9c7ab6d

Please sign in to comment.