. */ namespace Tests\Feature; use App\Account; use App\PhoneCountry; use App\Space; use Tests\TestCase; class ApiPhoneCountryTest extends TestCase { protected $route = '/api/phone_countries'; protected $method = 'POST'; protected $routeChangePhone = '/api/accounts/me/phone'; public function testCreatePhoneByCountry() { $account = Account::factory()->withConsumedAccountCreationToken()->create(); $account->generateUserApiKey(); $frenchPhoneNumber = '+33612121212'; $dutchPhoneNumber = '+31612121212'; $this->get($this->route) ->assertStatus(200) ->assertJsonFragment([ 'code' => 'FR', 'activated' => true ]) ->assertJsonFragment([ 'code' => 'NL', 'activated' => false ]); $this->keyAuthenticated($account) ->json($this->method, $this->routeChangePhone.'/request', [ 'phone' => $frenchPhoneNumber ]) ->assertStatus(200); $this->keyAuthenticated($account) ->json($this->method, $this->routeChangePhone.'/request', [ 'phone' => $dutchPhoneNumber ]) ->assertJsonValidationErrors(['phone']); PhoneCountry::where('code', 'NL')->update(['activated' => true]); $this->get($this->route) ->assertStatus(200) ->assertJsonFragment([ 'code' => 'NL', 'activated' => true ]); $this->keyAuthenticated($account) ->json($this->method, $this->routeChangePhone.'/request', [ 'phone' => $dutchPhoneNumber ]) ->assertStatus(200); } }