*/ private array $episode = []; private readonly string $apiUrl; public function __construct(?string $name = null) { parent::__construct($name); $this->episode = FakeSinglePodcastApiSeeder::episode(); $this->episode['created_at'] = []; $this->episode['updated_at'] = []; $this->apiUrl = config(RestApi::class) ->gateway; } public function testList(): void { $result = $this->call('get', $this->apiUrl . 'episodes'); $result->assertStatus(200); $result->assertHeader('Content-Type', 'application/json; charset=UTF-8'); $result->assertJSONFragment([ 0 => $this->episode, ]); } public function testView(): void { $result = $this->call('get', $this->apiUrl . 'episodes/1'); $result->assertStatus(200); $result->assertHeader('Content-Type', 'application/json; charset=UTF-8'); $result->assertJSONFragment($this->episode); } public function testViewNotFound(): void { $result = $this->call('get', $this->apiUrl . 'episodes/2'); $result->assertStatus(404); $result->assertJSONExact( [ 'status' => 404, 'error' => 404, 'messages' => [ 'error' => 'Episode not found', ], ] ); $result->assertHeader('Content-Type', 'application/json; charset=UTF-8'); } /* * Refreshing database to fetch empty array of episodes */ public function testListEmpty(): void { $this->regressDatabase(); $this->migrateDatabase(); $result = $this->call('get', $this->apiUrl . 'episodes'); $result->assertStatus(200); $result->assertHeader('Content-Type', 'application/json; charset=UTF-8'); $result->assertJSONExact([]); $this->seed($this->seed); } }