. */ namespace Tests\Feature; use App\Account; use Tests\TestCase; class AccountBlockingTest extends TestCase { protected $route = '/api/accounts'; protected $method = 'POST'; public function testBlocking() { $account = Account::factory()->withConsumedAccountCreationToken()->create(); $account->generateApiKey(); config()->set('app.blocking_amount_events_authorized_during_period', 2); $this->keyAuthenticated($account) ->json($this->method, $this->route . '/me/phone/request', [ 'phone' => '+33612312312' ])->assertStatus(200); $this->keyAuthenticated($account) ->json($this->method, $this->route . '/me/email/request', [ 'email' => 'foo@bar.com' ])->assertStatus(403); } public function testAdminBlocking() { $account = Account::factory()->create(); $account->generateApiKey(); $admin = Account::factory()->admin()->create(); $admin->generateApiKey(); $this->keyAuthenticated($account) ->get($this->route . '/me')->assertStatus(200); $this->keyAuthenticated($admin) ->json($this->method, $this->route . '/' . $account->id .'/block') ->assertStatus(200); $this->keyAuthenticated($account) ->get($this->route . '/me')->assertStatus(403); $this->keyAuthenticated($admin) ->json($this->method, $this->route . '/' . $account->id .'/unblock') ->assertStatus(200); $this->keyAuthenticated($account) ->get($this->route . '/me')->assertStatus(200); } }