2021-11-30 17:39:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Api\v1\Requests;
|
|
|
|
|
|
|
|
use App\Api\v1\Requests\TwoFAccountDynamicRequest;
|
|
|
|
use App\Api\v1\Requests\TwoFAccountStoreRequest;
|
2022-11-22 15:15:52 +01:00
|
|
|
use App\Api\v1\Requests\TwoFAccountUriRequest;
|
2021-11-30 17:39:33 +01:00
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
2023-08-01 11:28:27 +02:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
2024-06-26 14:29:13 +02:00
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
2021-11-30 17:39:33 +01:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
2022-12-09 10:52:17 +01:00
|
|
|
/**
|
2023-08-01 11:28:27 +02:00
|
|
|
* TwoFAccountDynamicRequestTest test class
|
2022-12-09 10:52:17 +01:00
|
|
|
*/
|
2023-08-01 11:28:27 +02:00
|
|
|
#[CoversClass(TwoFAccountDynamicRequest::class)]
|
2021-11-30 17:39:33 +01:00
|
|
|
class TwoFAccountDynamicRequestTest extends TestCase
|
|
|
|
{
|
|
|
|
use WithoutMiddleware;
|
|
|
|
|
2024-06-26 14:29:13 +02:00
|
|
|
#[Test]
|
2021-11-30 17:39:33 +01:00
|
|
|
public function test_user_is_authorized()
|
2022-11-22 15:15:52 +01:00
|
|
|
{
|
2021-11-30 17:39:33 +01:00
|
|
|
Auth::shouldReceive('check')
|
2022-12-09 10:52:17 +01:00
|
|
|
->once()
|
|
|
|
->andReturn(true);
|
2021-11-30 17:39:33 +01:00
|
|
|
|
|
|
|
$request = new TwoFAccountDynamicRequest();
|
2022-11-22 15:15:52 +01:00
|
|
|
|
2021-11-30 17:39:33 +01:00
|
|
|
$this->assertTrue($request->authorize());
|
|
|
|
}
|
|
|
|
|
2024-06-26 14:29:13 +02:00
|
|
|
#[Test]
|
2021-11-30 17:39:33 +01:00
|
|
|
public function test_returns_TwoFAccountUriRequest_rules_when_has_uri_input()
|
|
|
|
{
|
|
|
|
$twofaccountUriRequest = new TwoFAccountUriRequest();
|
2022-11-22 15:15:52 +01:00
|
|
|
$request = new TwoFAccountDynamicRequest();
|
2021-11-30 17:39:33 +01:00
|
|
|
$request->merge(['uri' => 'uristring']);
|
|
|
|
|
|
|
|
$this->assertEquals($twofaccountUriRequest->rules(), $request->rules());
|
|
|
|
}
|
|
|
|
|
2024-06-26 14:29:13 +02:00
|
|
|
#[Test]
|
2021-11-30 17:39:33 +01:00
|
|
|
public function test_returns_TwoFAccountStoreRequest_rules_otherwise()
|
|
|
|
{
|
|
|
|
$twofaccountStoreRequest = new TwoFAccountStoreRequest();
|
2022-11-22 15:15:52 +01:00
|
|
|
$request = new TwoFAccountDynamicRequest();
|
2021-11-30 17:39:33 +01:00
|
|
|
|
|
|
|
$this->assertEquals($twofaccountStoreRequest->rules(), $request->rules());
|
|
|
|
}
|
2022-11-22 15:15:52 +01:00
|
|
|
}
|