Beispiel #1
0
 public function testCreation()
 {
     $emp = new \Application\EmpItem(self::$arrayToTest);
     $this->assertEquals(1, $emp->getId());
     $this->assertEquals('some_email', $emp->getEmail());
     $this->assertEquals(1, $emp->getFirstDay());
     $this->assertEquals('some_login', $emp->getLogin());
     $this->assertEquals(12, $emp->getHourMode());
     $this->assertEquals('some_name', $emp->getName());
     $this->assertTrue($emp->isAdmin());
     return $emp;
 }
Beispiel #2
0
 private function addNewEmployee(\Core\Http $http, \Core\Application $app, \Core\Database $db, \DBMappers\EmpItem $empMapper)
 {
     $empItem = new \Application\EmpItem(array('login' => $http->post()['login'], 'email' => $http->post()['email'], 'hour_mode' => $http->post()['hour_mode'], 'first_day' => $http->post()['first_day'], 'name' => $http->post()['name'], 'is_admin' => $http->post()['is_admin_proxy']));
     $emp_err = array();
     $emp_err['login'] = $this->validateLogin($empItem->getLogin());
     $emp_err['name'] = $this->validateName($empItem->getName());
     $emp_err['email'] = $this->validateEmail($empItem->getEmail());
     $emp_err['password'] = '';
     if ($this->isEmptyValues($emp_err)) {
         $empMapper->save($empItem, $db);
         $app->setMessage('Employee ' . $empItem->getName() . ' added successfully.');
         $app->setStateRedirect(EMPLOYEE_LIST_URL);
         //error_log("\nredirect to:" . print_r(BROWSE_URL, true), 3, 'my_errors.txt');
     } else {
         $app->setStateEmployee(array('emp_edit' => array('item' => $empItem, 'edit_own' => false, 'add_new' => true), 'emp_err' => $emp_err));
     }
 }