You've already forked Php-Template
chore: add deployment configurations and tests for logger and dispatcher
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 4m18s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 4m30s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 4m21s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 4m35s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 4m21s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 3m13s
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 4m18s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 4m30s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 4m21s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 4m35s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 4m21s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 3m13s
This commit is contained in:
49
tests/Attributes/Guards/JwtTest.php
Normal file
49
tests/Attributes/Guards/JwtTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\Tests\Attributes\Guards;
|
||||
|
||||
use Siteworxpro\App\Attributes\Guards\Jwt;
|
||||
use Siteworxpro\App\Services\Facades\Config;
|
||||
use Siteworxpro\Tests\Unit;
|
||||
|
||||
class JwtTest extends Unit
|
||||
{
|
||||
public function testGetsClassFromConfig(): void
|
||||
{
|
||||
Config::set('jwt.issuer', 'default-issuer');
|
||||
Config::set('jwt.audience', 'default-audience');
|
||||
|
||||
$reflection = new \ReflectionClass(TestClass::class);
|
||||
$attributes = $reflection->getAttributes(Jwt::class);
|
||||
$this->assertCount(1, $attributes);
|
||||
|
||||
/** @var Jwt $instance */
|
||||
$instance = $attributes[0]->newInstance();
|
||||
$this->assertEquals('default-audience', $instance->getAudience());
|
||||
$this->assertEquals('default-issuer', $instance->getIssuer());
|
||||
}
|
||||
|
||||
public function testGetsClassFromCustom(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(TestClassSpecific::class);
|
||||
$attributes = $reflection->getAttributes(Jwt::class);
|
||||
$this->assertCount(1, $attributes);
|
||||
|
||||
/** @var Jwt $instance */
|
||||
$instance = $attributes[0]->newInstance();
|
||||
$this->assertEquals('custom-audience', $instance->getAudience());
|
||||
$this->assertEquals('custom-issuer', $instance->getIssuer());
|
||||
}
|
||||
}
|
||||
|
||||
#[Jwt]
|
||||
class TestClass // @codingStandardsIgnoreLine
|
||||
{
|
||||
}
|
||||
|
||||
#[Jwt('custom-issuer', 'custom-audience')]
|
||||
class TestClassSpecific // @codingStandardsIgnoreLine
|
||||
{
|
||||
}
|
||||
43
tests/Attributes/Guards/ScopeTest.php
Normal file
43
tests/Attributes/Guards/ScopeTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\Tests\Attributes\Guards;
|
||||
|
||||
use Siteworxpro\App\Attributes\Guards\Scope;
|
||||
use Siteworxpro\Tests\Unit;
|
||||
|
||||
class ScopeTest extends Unit
|
||||
{
|
||||
public function testGetsClassSingle(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(TestClassSingle::class);
|
||||
$attributes = $reflection->getAttributes(Scope::class);
|
||||
$this->assertCount(1, $attributes);
|
||||
|
||||
/** @var Scope $instance */
|
||||
$instance = $attributes[0]->newInstance();
|
||||
$this->assertEquals(['read:users'], $instance->getScopes());
|
||||
}
|
||||
|
||||
public function testGetsClassFromCustom(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(TestClassMultiple::class);
|
||||
$attributes = $reflection->getAttributes(Scope::class);
|
||||
$this->assertCount(1, $attributes);
|
||||
|
||||
/** @var Scope $instance */
|
||||
$instance = $attributes[0]->newInstance();
|
||||
$this->assertEquals(['read:users', 'write:users'], $instance->getScopes());
|
||||
}
|
||||
}
|
||||
|
||||
#[Scope(['read:users', 'write:users'])]
|
||||
class TestClassMultiple // @codingStandardsIgnoreLine
|
||||
{
|
||||
}
|
||||
|
||||
#[Scope(['read:users'])]
|
||||
class TestClassSingle // @codingStandardsIgnoreLine
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user