Skip to content
Merged

V1.0 #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ jobs:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '8.0'
php-version: '8.1'
extensions: mbstring, dom, fileinfo
coverage: xdebug #optional
- uses: getong/mariadb-action@v1.1
with:
host port: 3308 # Optional, default value is 3306. The port of host
mariadb version: '10.3' # Optional, default value is "latest". The version of the MariaDB
mysql database: 'testbench' # Optional, default value is "test". The specified database which will be create
mysql user: 'default' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
mysql password: 'secret' # Required if "mysql user" exists. The password for the "mysql user"
- name: Redis Server in GitHub Actions
uses: supercharge/redis-github-action@1.1.0
with:
Expand All @@ -27,11 +34,4 @@ jobs:
- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Run test & coverage
run: vendor/bin/pest --coverage --min=85
# - name: Test & publish code coverage
# uses: paambaati/codeclimate-action@v2.6.0
# env:
# CC_TEST_REPORTER_ID: fe3081a529c6c268974ebebb2f0137c3b3f6351cdc8a2712d8eb86ec78f7bf22
# with:
# coverageCommand: vendor/bin/phpunit --coverage-clover build/logs/clover.xml
# debug: false
run: vendor/bin/pest --coverage --ci --min=85
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"laravel/sanctum": "^2.11",
"seatplus/web": "^0.9"
"seatplus/web": "^1.0"
},
"require-dev": {
"nunomaduro/collision": "^5.3",
"orchestra/testbench": "^6.15",
"pestphp/pest-plugin-laravel": "^1.1"
"nunomaduro/collision": "^6.1",
"orchestra/testbench": "^7.1",
"pestphp/pest-plugin-laravel": "^1.2"
},
"autoload": {
"psr-4": {
Expand All @@ -41,7 +41,10 @@
"test-coverage": "XDEBUG_MODE=coverage ./vendor/bin/pest --coverage"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"extra": {
"laravel": {
Expand Down
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
</coverage>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF" />
<env name="DB_HOST" value="127.0.0.1" />
<env name="DB_PORT" value="3308" />
<env name="DB_DATABASE" value="testbench" />
<env name="DB_USERNAME" value="default" />
<env name="DB_PASSWORD" value="secret" />
</php>
<logging>
<junit outputFile="build/report.junit.xml"/>
Expand Down
3 changes: 1 addition & 2 deletions tests/Integration/ApiUser.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Inertia\Testing\Assert;
use function Pest\Laravel\actingAs;
use Seatplus\Auth\Models\Permissions\Permission;
use Seatplus\Auth\Models\User;
Expand All @@ -21,7 +20,7 @@

it('user can access api view', function () {
$response = actingAs($this->test_user)->get(route('api.index'))
->assertInertia(fn (Assert $page) => $page
->assertInertia(fn (\Inertia\Testing\AssertableInertia $page) => $page
->component('Api/Index'));
});

Expand Down
6 changes: 5 additions & 1 deletion tests/Integration/Endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
});

test('/api/v1/users/1', function () {
$this->get('api/v1/users/1')->assertOk();
expect(\Seatplus\Auth\Models\User::all())->toHaveCount(1);
$user_id = \Seatplus\Auth\Models\User::first()->id;

$this->get("api/v1/users/$user_id")->assertOk();
});

test('/api/v1/characters/{character_id}/skills', function () {
Expand All @@ -37,6 +40,7 @@
test('/api/v1/characters/{character_id}/corporationhistory', function () {
\Seatplus\Eveapi\Models\Character\CorporationHistory::factory()
->create([
'start_date' => faker()->dateTime,
'character_id' => $this->test_character->character_id,
]);

Expand Down
5 changes: 5 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ function using($test): TestCase
{
return $test;
}

function faker()
{
return \Faker\Factory::create();
}
2 changes: 1 addition & 1 deletion tests/Stubs/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Orchestra\Testbench\Http\Middleware\RedirectIfAuthenticated;
use Seatplus\Web\Http\Middleware\Authenticate;

class Kernel extends \Orchestra\Testbench\Http\Kernel
class Kernel extends \Orchestra\Testbench\Foundation\Http\Kernel
{
/**
* The application's route middleware.
Expand Down
6 changes: 6 additions & 0 deletions tests/Stubs/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"/js/app.js": "/js/app.js",
"/js/manifest.js": "/js/manifest.js",
"/css/app.css": "/css/app.css",
"/js/vendor.js": "/js/vendor.js"
}
19 changes: 6 additions & 13 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Seatplus\Api\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Queue;
use Inertia\Inertia;
Expand All @@ -19,6 +20,8 @@

class TestCase extends Orchestra
{
use LazilyRefreshDatabase;

protected function setUp(): void
{
parent::setUp();
Expand All @@ -43,7 +46,7 @@ protected function setUp(): void

$this->test_character = $this->test_user->characters->first();

$this->app->instance('path.public', __DIR__ .'/../vendor/seatplus/web/src/public');
$this->app->instance('path.public', __DIR__ .'/Stubs');

Permission::findOrCreate('superuser');
}
Expand All @@ -62,20 +65,10 @@ protected function getPackageProviders($app)

public function getEnvironmentSetUp($app)
{
config()->set('database.default', 'testing');

// Use memory SQLite, cleans it self up
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
config()->set('database.default', 'mysql');

config(['app.debug' => true]);

//$app['router']->aliasMiddleware('auth', Authenticate::class);

// Use test User model for users provider
$app['config']->set('auth.providers.users.model', User::class);

Expand Down Expand Up @@ -109,6 +102,6 @@ private function setupDatabase($app)
{
// Path to our migrations to load
//$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
$this->artisan('migrate', ['--database' => 'testbench']);
$this->artisan('migrate');
}
}