. */ namespace Tests\Feature; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Password; class AccountApiKeyTest extends TestCase { use RefreshDatabase; protected $route = '/api/accounts/me/api_key'; protected $method = 'GET'; public function testRefresh() { $password = Password::factory()->create(); $response0 = $this->generateFirstResponse($password); $response1 = $this->generateSecondResponse($password, $response0) ->get($this->route); // Get the API Key using the DIGEST method $password->account->refresh(); $response1->assertStatus(200) ->assertSee($password->account->apiKey->key) ->assertPlainCookie('x-api-key', $password->account->apiKey->key); // Get it again using the key authenticated method $response2 = $this->keyAuthenticated($password->account) ->get($this->route); $password->account->refresh(); $response2->assertStatus(200) ->assertSee($password->account->apiKey->key) ->assertPlainCookie('x-api-key', $password->account->apiKey->key); } }