. */ namespace Tests\Feature; use App\Password; use Tests\TestCase; class ApiLocalizationTest extends TestCase { protected $route = '/api/accounts'; protected $method = 'POST'; public function testUsernameNotPhone() { $password = Password::factory()->admin()->create(); $password->account->generateApiKey(); $this->keyAuthenticated($password->account) ->withHeaders([ 'Accept-Language' => 'de', ]) ->json($this->method, $this->route, [ 'domain' => 'example.com', ]) ->assertJsonValidationErrors(['username']) ->assertJsonFragment(['username' => ['The username field is required.']]); $this->keyAuthenticated($password->account) ->withHeaders([ 'Accept-Language' => 'fr', ]) ->json($this->method, $this->route, [ 'domain' => 'example.com', ]) ->assertJsonValidationErrors(['username']) ->assertJsonFragment(['username' => ['Le champ pseudo est obligatoire.']]); } }