Exemplo n.º 1
0
 public function testDatesAndValuesShownAtIndex()
 {
     $titleToInsert = 'a project we want to see with date';
     $dateInserted = "2012-09-07";
     $p = new C3op_Projects_Project();
     $p->SetTitle($titleToInsert);
     $p->SetDateBegin($dateInserted);
     $this->projectMapper->insert($p);
     $this->inserts[$p->getId()] = array('p' => $p, 'persistence' => false);
     $titleToInsert = 'a project we want to see with date and value';
     $dateInserted = "2012-10-01";
     $value = 1234;
     $p = new C3op_Projects_Project();
     $p->SetTitle($titleToInsert);
     $p->SetDateBegin($dateInserted);
     $p->SetValue($value);
     $this->projectMapper->insert($p);
     $this->inserts[$p->getId()] = array('p' => $p, 'persistence' => false);
     $titleToInsert = 'a project we want to see just with value';
     $value = 8743000;
     $p = new C3op_Projects_Project();
     $p->SetTitle($titleToInsert);
     $p->SetDateBegin($dateInserted);
     $p->SetValue($value);
     $this->projectMapper->insert($p);
     $this->inserts[$p->getId()] = array('p' => $p, 'persistence' => false);
     //$mapperList = $this->projectMapper->getAllIds();
     $this->dispatch('/projects');
     $this->createNewControllerAndFiresAction();
     $this->assertModule('projects');
     $this->assertController('index');
     $this->assertAction('index');
     $viewVars = $this->createController->view->getVars();
     $this->assertArrayHasKey('projectsList', $viewVars);
     $projectsList = $viewVars['projectsList'];
     while (list($id, $projectData) = each($projectsList)) {
         $p = $this->projectMapper->findById($id);
         $this->assertEquals($p->GetDateBegin(), $projectData['dateBegin']);
         if ($p->GetValue() > 0) {
             $this->assertEquals($p->GetValue(), (double) $projectData['value']);
         }
     }
 }
Exemplo n.º 2
0
 public function testIfSavedDateIsShownAtFormInBrazilianStyle()
 {
     $titleToInsert = 'a project we want to check a date';
     $dateInserted = "2012-09-07";
     $p = new C3op_Projects_Project();
     $p->SetTitle($titleToInsert);
     $p->SetDateBegin($dateInserted);
     $this->projectMapper->insert($p);
     $this->inserts[$p->getId()] = array('p' => $p, 'persistence' => false);
     $this->dispatch('/projects/project/edit/?id=' . $p->getId());
     $this->editController = $this->initController();
     $this->editController->editAction();
     $viewVars = $this->editController->view->getVars();
     $form = $viewVars['form'];
     $this->assertEquals('Zend_Form_Element_Text', get_class($form->getElement('dateBegin')));
     $dateField = $form->getElement('dateBegin');
     $dateFromForm = $dateField->getValue();
     $dateArray = explode("-", $dateInserted);
     $formatedDate = $dateArray[2] . '/' . $dateArray[1] . '/' . $dateArray[0];
     $this->assertEquals($formatedDate, $dateFromForm);
 }
Exemplo n.º 3
0
 public function testThatIsPossibleToChangeABeginDate()
 {
     $titleInserted = 'HOHOHO a project inserted to try to change date';
     $dateBeginAtFirst = "25-12-2011";
     $p = new C3op_Projects_Project();
     $p->SetTitle($titleInserted);
     class_exists('C3op_Util_ValidDate') || (require APPLICATION_PATH . "/../library/C3op/Util/validDate.php");
     $dateConverter = new C3op_Util_DateConverter();
     $p->SetDateBegin($dateConverter->convertDateToMySQLFormat($dateBeginAtFirst));
     $this->projectMapper->insert($p);
     $this->inserts[$p->getId()] = array('p' => $p, 'persistence' => false);
     $id = $p->getId();
     $p2 = $this->projectMapper->findById($id);
     $newDate = "2012-05-01";
     $p2->SetDateBegin($newDate);
     $this->assertEquals($p->getDateBegin(), $newDate);
 }