public function test_store_by_post() { $student = factory(Student::class)->create(); $assignor = BilletAssignor::first(); if (is_null($assignor)) { $assignor = factory(BilletAssignor::class)->create(); } $billet = ['amount' => 50, 'student_id' => $student->id, 'refer' => 201615, 'due_date' => date('Y-m-d')]; $this->post('api/v1/billet/', $billet); $this->seeStatusCode(200); $this->seeJsonContains(['amount' => 50, 'payer' => $student->getPayer(), 'recipient' => $assignor->getRecipient()]); $actual = json_decode($this->response->getContent()); $payer = json_decode($actual->payer); $recipient = json_decode($actual->recipient); $this->assertEquals($student->cpf_responsible, $payer->documento); $this->assertEquals($assignor->cnpj, $recipient->documento); $this->assertInstanceOf(Billet::class, $this->response->original); $this->seeInDatabase('billets', ['id' => $this->response->original->id]); }