createUser(); $singleMstr = factory(Master::class)->create(); $this->getJson(route('api.masters.index'), [ 'Authorization' => 'Bearer '.$user->api_token ]); $this->seeJson(['name' => $singleMstr->name]); } /** @test */ public function user_can_create_a_master() { $user = $this->createUser(); $this->postJson(route('api.masters.store'), [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ], [ 'Authorization' => 'Bearer '.$user->api_token ]); $this->seeInDatabase('masters', [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); $this->seeStatusCode(201); $this->seeJson([ 'message' => __('master.created'), 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); } /** @test */ public function user_can_get_a_master_detail() { $user = $this->createUser(); $singleMstr = factory(Master::class)->create(['name' => 'Testing 123']); $this->getJson(route('api.masters.show', $singleMstr), [ 'Authorization' => 'Bearer '.$user->api_token ]); $this->seeJson(['name' => 'Testing 123']); } /** @test */ public function user_can_update_a_master() { $user = $this->createUser(); $singleMstr = factory(Master::class)->create(['name' => 'Testing 123']); $this->patchJson(route('api.masters.update', $singleMstr), [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ], [ 'Authorization' => 'Bearer '.$user->api_token ]); $this->seeInDatabase('masters', [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); $this->seeStatusCode(200); $this->seeJson([ 'message' => __('master.updated'), 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); } /** @test */ public function user_can_delete_a_master() { $user = $this->createUser(); $singleMstr = factory(Master::class)->create(); $this->deleteJson(route('api.masters.destroy', $singleMstr), [ 'master_id' => $singleMstr->id, ], [ 'Authorization' => 'Bearer '.$user->api_token ]); $this->dontSeeInDatabase('masters', [ 'id' => $singleMstr->id, ]); $this->seeStatusCode(200); $this->seeJson([ 'message' => __('master.deleted'), ]); } }