/** * @test */ public function delete() { $headers = ['HTTP_' . ApiAuthFilter::APPLICATION_TOKEN => 'token1']; $this->client->request('DELETE', '/api/reservation/code1', [], [], $headers); $this->assertResponseOk(); $book = Book::where('asin', 'asin1')->first(); $this->assertSame(11, $book->inventory); $this->assertSame(2, Reservation::count()); $this->assertFalse(Reservation::where('reservation_code', 'code1')->exists()); }
/** * @param string $reservationCode * @return \Illuminate\Database\Eloquent\Model|null|static */ public function read($reservationCode) { return Reservation::where('reservation_code', $reservationCode)->first(); }
/** * @test */ public function cancel() { $reservation = Reservation::find(1); $user = User::find(2); $this->sut->cancel($reservation, $user); $this->assertFalse(Reservation::where('id', 1)->exists(1)); $actual = Book::find(2); $this->assertSame(4, $actual->inventory); }