Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passport keys in passport tests #3

Merged
merged 2 commits into from
Feb 25, 2024
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to `one-app` will be documented in this file.

## v1.0.2 - 2024-02-25

### What's Changed

* add basic testing workflow by @inmanturbo in https://github.com/envor/one-app/pull/2

**Full Changelog**: https://github.com/envor/one-app/compare/v1.0.1...v1.0.2

## v1.0.1 - 2024-02-25

### What's Changed
Expand Down
68 changes: 68 additions & 0 deletions passport/stubs/tests/Feature/Pest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

use Envor\Datastore\Datastore;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan;
use Tests\TestCase;

/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
| need to change it using the "uses()" function to bind a different classes or traits.
|
*/

uses(TestCase::class, RefreshDatabase::class)
->beforeEach(function () {

Datastore::fake();

config(['database.platform' => 'testing_platform']);
config(['database.default' => 'testing_app']);

config(['database.connections.sqlite.database' => ':memory:']);

config(['database.connections.testing_platform' => config('database.connections.sqlite')]);

config(['database.connections.testing_app' => config('database.connections.sqlite')]);

Artisan::call('migrate:fresh --database=testing_platform --path=database/migrations/platform');

Artisan::call('passport:keys', ['--length' => 4096]);
})
->in('Feature');

/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/

expect()->extend('toBeOne', function () {
return $this->toBe(1);
});

/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/

function something()
{
// ..
}