-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Architecture and command test.
- Loading branch information
Showing
12 changed files
with
132 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ phpstan.neon | |
testbench.yaml | ||
vendor | ||
node_modules | ||
pest-coverage-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Console\Command; | ||
use Raiolanetworks\OAuth\Tests\Models\TestUser; | ||
|
||
it('run the install command', function () { | ||
$tempFilePath = base_path('.env'); | ||
file_put_contents($tempFilePath, 'OAUTH_BASE_URL="https://test"'); | ||
|
||
$this->artisan('oauth:install') | ||
->expectsQuestion('Model name Authenticatable:', TestUser::class) | ||
->expectsQuestion('Main guard name:', 'web') | ||
->expectsQuestion('Login route:', '/login') | ||
->expectsQuestion('Oauth base url:', 'https://asgard.your.company') | ||
->expectsQuestion('Oauth client ID:', 'CLIENTID') | ||
->expectsQuestion('Oauth client secret key:', 'SECRETKEY') | ||
->expectsQuestion('Oauth name admin group:', 'admin_group') | ||
->expectsQuestion('OAuth mode. Options: login only with username and password, only with OAuth or both:', 'BOTH') | ||
->assertExitCode(Command::SUCCESS); | ||
|
||
unlink($tempFilePath); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Raiolanetworks\OAuth\Tests\Models; | ||
|
||
use Illuminate\Contracts\Auth\Authenticatable; | ||
|
||
class TestUser implements Authenticatable | ||
{ | ||
public function getAuthIdentifierName(): string | ||
{ | ||
return 'id'; | ||
} | ||
|
||
public function getAuthIdentifier(): int | ||
{ | ||
return 1; | ||
} | ||
|
||
public function getAuthPasswordName(): string | ||
{ | ||
return 'password'; | ||
} | ||
|
||
public function getAuthPassword(): string | ||
{ | ||
return 'password'; | ||
} | ||
|
||
public function getRememberToken(): ?string | ||
{ | ||
return null; | ||
} | ||
|
||
public function setRememberToken($value): void {} | ||
|
||
public function getRememberTokenName(): string | ||
{ | ||
return 'remember_token'; | ||
} | ||
|
||
public function getTable(): string | ||
{ | ||
return 'test_users'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
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::create('test_users', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('email'); | ||
$table->string('password'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('test_users'); | ||
} | ||
}; |