Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Oct 15, 2023
1 parent 08c3a1c commit 1c601b7
Show file tree
Hide file tree
Showing 18 changed files with 204 additions and 200 deletions.
29 changes: 0 additions & 29 deletions .php_cs

This file was deleted.

32 changes: 26 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@
},
"autoload-dev": {
"psr-4": {
"Laravie\\Authen\\Tests\\": "tests/"
"Laravie\\Authen\\Tests\\": "tests/",
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
},
"require": {
"php": "^7.3 || ^8.0",
"illuminate/auth": "^8.75 || ^9.45 || ^10.0"
"php": "^8.0",
"illuminate/auth": "^9.45 || ^10.23"
},
"require-dev": {
"nunomaduro/larastan": "^1.0.1 || ^2.0",
"orchestra/testbench": "^6.25.1 || ^7.19 || ^8.0",
"nunomaduro/larastan": "^2.3",
"orchestra/testbench": "^7.33 || ^8.14",
"phpunit/phpunit": "^9.6"
},
"config": {
Expand All @@ -37,7 +40,24 @@
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi"
"post-autoload-dump": [
"@clear",
"@prepare",
"@php ./vendor/bin/testbench package:discover --ansi"
],
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": "@php vendor/bin/testbench workbench:build --ansi",
"serve": [
"@build",
"@php vendor/bin/testbench serve"
],
"lint": [
"@php vendor/bin/phpstan analyse"
],
"test": [
"@php vendor/bin/phpunit"
]
},
"minimum-stability": "dev"
}
20 changes: 20 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
providers:
- Laravie\Authen\AuthenServiceProvider
- Workbench\App\Providers\AuthServiceProvider

migrations:
- workbench/database/migrations

seeders:
- Workbench\Database\Seeders\DatabaseSeeder

workbench:
start: '/'
install: true
discovers:
web: true
api: false
commands: false
build: []
assets: []
sync: []
2 changes: 1 addition & 1 deletion tests/AuthenticateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\Facades\Auth;
use Laravie\Authen\Authen;
use Laravie\Authen\Tests\Factories\UserFactory;
use Workbench\Database\Factories\UserFactory;

class AuthenticateTest extends TestCase
{
Expand Down
65 changes: 0 additions & 65 deletions tests/Factories/UserFactory.php

This file was deleted.

37 changes: 8 additions & 29 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@

namespace Laravie\Authen\Tests;

use Orchestra\Testbench\TestCase as BaseTestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
use Orchestra\Testbench\Concerns\WithWorkbench;

abstract class TestCase extends BaseTestCase
abstract class TestCase extends \Orchestra\Testbench\TestCase
{
/**
* Get package providers.
*
* @param \Illuminate\Foundation\Application $app
* @return array
*/
protected function getPackageProviders($app)
{
return [
\Laravie\Authen\AuthenServiceProvider::class,
\Laravie\Authen\Tests\Fixtures\AuthServiceProvider::class,
];
}
use RefreshDatabase;
use WithLaravelMigrations;
use WithWorkbench;

/**
* Define environment setup.
Expand All @@ -33,21 +25,8 @@ protected function defineEnvironment($app)
$config->set([
'auth.providers.users' => [
'driver' => 'authen',
'model' => \Laravie\Authen\Tests\Fixtures\User::class,
'model' => \Workbench\App\Models\User::class,
],
]);
}

/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadMigrationsFrom([
'--database' => 'testing',
'--path' => realpath(__DIR__.'/migrations'),
]);
}
}
36 changes: 0 additions & 36 deletions tests/migrations/2014_10_12_000000_create_users_table.php

This file was deleted.

This file was deleted.

Empty file added workbench/app/Models/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion tests/Fixtures/User.php → workbench/app/Models/User.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Laravie\Authen\Tests\Fixtures;
namespace Workbench\App\Models;

use Illuminate\Foundation\Auth\User as Eloquent;
use Laravie\Authen\AuthenUser;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Laravie\Authen\Tests\Fixtures;
namespace Workbench\App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravie\Authen\BootAuthenProvider;
Expand Down
46 changes: 46 additions & 0 deletions workbench/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Workbench\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Workbench\App\Models\User;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Workbench\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),
'username' => $this->faker->unique()->userName(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}

/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('username')->unique()->after('name');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('username');
});
}
};
Loading

0 comments on commit 1c601b7

Please sign in to comment.