Ejemplo n.º 1
0
 public function testUpdate()
 {
     $group = $this->company->groups()->firstOrFail();
     //correct request
     $response = $this->actingAs($this->company)->json('PUT', '/companies/groups/' . $group->id, $this->data);
     $response->assertResponseOk();
     $data2 = $this->data;
     $response->seeJson($data2);
     //dame data OK normal update
     $response = $this->actingAs($this->company)->json('PUT', '/companies/groups/' . $group->id, $this->data);
     $response->assertResponseOk();
     $data2 = $this->data;
     $response->seeJson($data2);
     //duplicate group
     $response = $this->actingAs($this->company)->json('PUT', '/companies/groups/' . ($group->id + 1), $this->data);
     $response->seeStatusCode(422);
     //a no my group
     $group2 = \plunner\Group::where('company_id', '<>', $this->company->id)->firstOrFail();
     $data2 = $this->data;
     $data2['name'] = 'Testers2';
     //this since we are acting as original company -> see how requests work
     $response = $this->actingAs($this->company)->json('PUT', '/companies/groups/' . $group2->id, $data2);
     $response->seeStatusCode(403);
     //force field
     $data2 = $this->data;
     $data2['name'] = 'Testers2';
     $data2['company_id'] = 2;
     $response = $this->actingAs($this->company)->json('PUT', '/companies/groups/' . $group->id, $data2);
     $response->assertResponseOk();
     $data3 = $data2;
     $json = $response->response->content();
     $json = json_decode($json, true);
     $this->assertNotEquals($data2['company_id'], $json['company_id']);
     //this for travis problem due to consider 1 as number instead of string
     $this->assertEquals(1, $json['company_id']);
     unset($data3['company_id']);
     $response->SeeJson($data3);
 }
Ejemplo n.º 2
0
 public function testDeleteGroupNotMine()
 {
     $company = \plunner\Company::findOrFail(1);
     $group = \plunner\Group::where('company_id', '<>', $company->id)->firstOrFail();
     $employee = $group->employees()->first();
     $response = $this->actingAs($company)->json('DELETE', '/companies/groups/' . $group->id . '/employees/' . $employee->id);
     $response->seeStatusCode(403);
 }
Ejemplo n.º 3
0
 public function testShowGroupNotManagedByMe()
 {
     $group = \plunner\Group::where('planner_id', '<>', $this->planner->id)->first();
     if (!$group) {
         $employee = $this->company->employees()->create(['name' => 'test', 'email' => '*****@*****.**', 'password' => 'testest', 'password_confirmation' => 'testest']);
         $group = $this->company->Groups()->create(['name' => 'Testers', 'description' => 'Group for testing stuff', 'planner_id' => $employee->id]);
     }
     $response = $this->actingAs($this->planner)->json('GET', '/employees/planners/groups/' . $group->id);
     $response->seeStatusCode(403);
 }
Ejemplo n.º 4
0
 public function testUpdateOtherGroupsMeeting()
 {
     $other_group = \plunner\Group::where('planner_id', '<>', $this->planner->id)->first();
     $other_groups_meeting_id = $other_group->meetings()->first()->id;
     $test_data = $this->getUpdateData();
     $response = $this->actingAs($this->planner)->json('PUT', 'employees/planners/groups/' . $other_group->id . '/meetings/' . $other_groups_meeting_id, $test_data);
     $response->seeStatusCode(403);
 }