public function setUp()
 {
     parent::setUp();
     config(['auth.model' => \plunner\Planner::class]);
     config(['jwt.user' => \plunner\Planner::class]);
     $this->company = \plunner\Company::findOrFail(1);
     $this->planner = $this->company->groups()->has('planner')->with('planner')->firstOrFail()->Planner;
 }
示例#2
0
 public function testIndex()
 {
     config(['auth.model' => \plunner\Company::class]);
     config(['jwt.user' => \plunner\Company::class]);
     $company = \plunner\Company::findOrFail(1);
     $response = $this->actingAs($company)->json('GET', '/companies/example');
     $response->seeStatusCode(200);
 }
 public function setUp()
 {
     parent::setUp();
     config(['auth.model' => \plunner\Employee::class]);
     config(['jwt.user' => \plunner\Employee::class]);
     $this->company = \plunner\Company::findOrFail(1);
     $this->employee = $this->company->employees()->has('groups')->with('groups')->firstOrFail();
 }
示例#4
0
 public function setUp()
 {
     parent::setUp();
     config(['auth.model' => \plunner\Planner::class]);
     config(['jwt.user' => \plunner\Planner::class]);
     $this->company = \plunner\Company::findOrFail(1);
     $this->employee = $this->company->employees()->has('groups')->with('groups')->firstOrFail();
     $this->group = $this->employee->groups->first();
     $this->planner = $this->group->planner;
     $this->data = ['title' => 'Test meeting', 'description' => 'Errare humanum est!', 'duration' => 120];
 }
示例#5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //
     //TODO insert a timeout
     //TODO try...catch with destruct
     $companyId = $this->argument('companyId');
     if (is_numeric($companyId)) {
         $this->makeForeground(Company::findOrFail($companyId));
     } else {
         $this->syncAll();
     }
 }
 public function testSameGroupDataDifferentCompanies()
 {
     $company1 = $this->company;
     $company2 = \plunner\Company::findOrFail(2);
     //insert in company1
     $company2->groups()->create($this->data);
     //insert user in company2
     $response = $this->actingAs($company1)->json('POST', '/companies/groups/', $this->data);
     $response->assertResponseOk();
     //duplicated in company2
     $response = $this->actingAs($company1)->json('POST', '/companies/groups/', $this->data);
     $response->seeStatusCode(422);
 }
 public function setUp()
 {
     parent::setUp();
     config(['auth.model' => Planner::class]);
     config(['jwt.user' => Planner::class]);
     $this->company = Company::findOrFail(1);
     $this->employee = $this->company->employees()->with('groups')->first();
     $this->group = $this->employee->groups->first();
     $this->planner = $this->group->planner;
     $this->meeting = $this->group->meetings()->has('timeslots')->with('group')->first();
     $this->data = ['time_start' => '2015-12-17 12:00:00', 'time_end' => '2015-12-17 14:00:00'];
     $this->meeting->timeslots()->create($this->data);
     $this->timeslot = $this->meeting->timeslots()->with('meeting')->firstOrFail();
 }
 public function testUpdate()
 {
     $company = \plunner\Company::findOrFail(1);
     $data = ['name' => 'test', 'password' => 'testest', 'password_confirmation' => 'testest'];
     //correct request
     $response = $this->actingAs($company)->json('PUT', '/companies/company/', $data);
     $response->assertResponseOk();
     $data2 = $data;
     unset($data2['password']);
     unset($data2['password_confirmation']);
     $response->seeJson($data2);
     //no correct request
     unset($data['password_confirmation']);
     $response = $this->actingAs($company)->json('PUT', '/companies/company/', $data);
     $response->seeStatusCode(422);
 }
示例#9
0
 public function testUpdate()
 {
     $company = \plunner\Company::findOrFail(1);
     $employee = $company->employees->first();
     $data = ['name' => 'test', 'email' => '*****@*****.**', 'password' => 'testest', 'password_confirmation' => 'testest'];
     //correct request
     $response = $this->actingAs($company)->json('PUT', '/companies/employees/' . $employee->id, $data);
     $response->assertResponseOk();
     $data2 = $data;
     unset($data2['password']);
     unset($data2['password_confirmation']);
     $response->seeJson($data2);
     //duplicate employee
     $response = $this->actingAs($company)->json('PUT', '/companies/employees/' . $employee->id, $data);
     $response->seeStatusCode(422);
     //a no my employee
     $employee2 = \plunner\Employee::where('company_id', '<>', $company->id)->firstOrFail();
     $data['email'] = '*****@*****.**';
     //this since we are acting as original company -> see how requests work
     $response = $this->actingAs($company)->json('PUT', '/companies/employees/' . $employee2->id, $data);
     $response->seeStatusCode(403);
     $data['email'] = '*****@*****.**';
     //force field
     $data['email'] = '*****@*****.**';
     $data['company_id'] = 2;
     $response = $this->actingAs($company)->json('PUT', '/companies/employees/' . $employee->id, $data);
     $response->assertResponseOk();
     $data2 = $data;
     unset($data2['password']);
     unset($data2['password_confirmation']);
     $json = $response->response->content();
     $json = json_decode($json, true);
     $this->assertNotEquals($data['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($data2['company_id']);
     $response->SeeJson($data2);
 }
 public function testDelete404()
 {
     $company = \plunner\Company::findOrFail(1);
     $group = $company->groups()->first();
     $ids = [];
     $employees = $group->employees;
     foreach ($employees as $employee) {
         $ids[] = $employee->id;
     }
     $employee = $company->employees()->create(['name' => 'ttt', 'email' => '*****@*****.**', 'password' => bcrypt('ttt')]);
     $response = $this->actingAs($company)->json('DELETE', '/companies/groups/' . $group->id . '/employees/' . $employee->id);
     $response->seeStatusCode(404);
 }