getJson('/tracker') ->assertOk() ->assertJson(['exists' => false]); } public function test_show_returns_the_tracker_once_created(): void { Tracker::factory()->create(['count' => 9]); $this->getJson('/tracker') ->assertOk() ->assertJson([ 'exists' => true, 'tracker' => ['count' => 9], ]); } public function test_a_tracker_can_be_created_without_a_label_or_unit(): void { $this->postJson('/tracker', [])->assertCreated(); $tracker = Tracker::first(); $this->assertSame('Counter', $tracker->label); $this->assertSame('units', $tracker->unit); $this->assertSame(0, $tracker->count); } public function test_a_new_counter_starts_at_zero(): void { $this->postJson('/tracker', []); $this->getJson('/tracker') ->assertOk() ->assertJson(['tracker' => ['count' => 0]]); } public function test_creating_a_second_tracker_conflicts(): void { $this->postJson('/tracker', [])->assertCreated(); $this->postJson('/tracker', [])->assertStatus(409); $this->assertSame(1, Tracker::count()); } }