Ejemplo n.º 1
0
 public function testNewAccountCreation()
 {
     $tester = $this->getDatabaseTester();
     $tester->onSetUp();
     $project = new C3op_Projects_Project();
     $project->setTitle("more other project");
     $xml_dataset = new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/fixture/projects_after_inclusion.xml');
     PHPUnit_Extensions_Database_TestCase::assertDataSetsEqual($xml_dataset, $tester->getConnection()->createDataSet());
     $tester->onTearDown();
 }
Ejemplo n.º 2
0
 public function testUserCanUseAccentedCharactersWhenEditing()
 {
     $project = new C3op_Projects_Project();
     $project->SetTitle("some title");
     $this->projectMapper->insert($project);
     $id = $project->GetId();
     $form = new C3op_Form_ProjectEdit();
     $formData = array('id' => $id, 'title' => 'I scream, you scream, we still scream to icecream and úÀÇÃêã é or ç?!?!?...;- yeah!', 'dateBegin' => '', 'value' => '', 'submit' => true);
     $form->process($formData);
 }
Ejemplo n.º 3
0
 public function GetAllActionsSubordinatedTo(C3op_Projects_Action $action, C3op_Projects_ActionMapper $actionMapper, C3op_Projects_Project $project, C3op_Projects_ProjectMapper $projectMapper)
 {
     echo "<hr>entering getallactionssubordinatedto<br>";
     echo "action " . $action->GetId() . " - " . $action->GetTitle() . "<br>";
     echo "project " . $project->GetId() . "<br>";
     $allActionsBelowMe = array();
     $actionsIdJustBelowMe = $actionMapper->getActionsSubordinatedTo($action);
     while (list(, $actionId) = each($actionsIdJustBelowMe)) {
         $thisAction = $actionMapper->findById($actionId);
         $actionsJustBelowMe = $this->GetAllActionsSubordinatedTo($thisAction, $actionMapper, $project, $projectMapper);
         $allActionsBelowMe[] = array("action" => $thisAction, "actionsBelow" => $actionsJustBelowMe);
     }
     echo "returning from getallactionssubordinatedto<br>";
     echo "action " . $action->GetId() . " - " . $action->GetTitle() . "<br>";
     echo "project " . $project->GetId() . "<br>";
     print_r($allActionsBelowMe);
     echo "count allactionsbelowme " . count($allActionsBelowMe) . "<br><hr><br>";
     return $allActionsBelowMe;
 }
Ejemplo n.º 4
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']);
         }
     }
 }
Ejemplo n.º 5
0
 public function process($data)
 {
     if ($this->isValid($data) !== true) {
         throw new C3op_Form_ProjectCreateException('Invalid data!');
     } else {
         $db = Zend_Registry::get('db');
         $projectMapper = new C3op_Projects_ProjectMapper($db);
         $project = new C3op_Projects_Project();
         $project->SetTitle($this->title->GetValue());
         $project->SetClient($this->client->GetValue());
         $project->SetOurResponsible($this->ourResponsible->GetValue());
         $project->SetResponsibleAtClient($this->responsibleAtClient->GetValue());
         $beginDate = $this->beginDate->GetValue();
         $dateValidator = new C3op_Util_ValidDate();
         if ($dateValidator->isValid($beginDate)) {
             $converter = new C3op_Util_DateConverter();
             $dateForMysql = $converter->convertDateToMySQLFormat($beginDate);
             $project->SetBeginDate($dateForMysql);
         }
         $finishDate = $this->finishDate->GetValue();
         $dateValidator = new C3op_Util_ValidDate();
         if ($dateValidator->isValid($finishDate)) {
             $converter = new C3op_Util_DateConverter();
             $dateForMysql = $converter->convertDateToMySQLFormat($finishDate);
             $project->SetFinishDate($dateForMysql);
         }
         $project->SetValue($this->value->GetValue());
         $project->SetStatus($this->status->GetValue());
         $project->SetContractNature($this->contractNature->GetValue());
         $project->SetAreaActivity($this->areaActivity->GetValue());
         $project->SetOverhead($this->overhead->GetValue());
         $project->SetManagementFee($this->managementFee->GetValue());
         $project->SetObject($this->object->GetValue());
         $project->SetSummary($this->summary->GetValue());
         $project->SetObservation($this->observation->GetValue());
         $projectMapper->insert($project);
     }
 }
Ejemplo n.º 6
0
 public function getAllUnacknowledgededActions(C3op_Projects_Project $p, C3op_Projects_ActionMapper $actionMapper)
 {
     $result = array();
     foreach ($this->db->query(sprintf('SELECT a.id
                 FROM projects_actions a
                 INNER JOIN projects_actions_dates d
                 ON a.id = d.action
                 WHERE a.status = %d AND a.project = %d ORDER BY d.real_begin_date', C3op_Projects_ActionStatusConstants::STATUS_IN_EXECUTION, $p->GetId())) as $row) {
         $action = $actionMapper->findById($row['id']);
         $obj = new C3op_Projects_ActionStartMode($action, $actionMapper);
         if ($obj->isUnacknowledged()) {
             $result[] = $row['id'];
         }
     }
     return $result;
 }
Ejemplo n.º 7
0
 private function manageTreeLink(C3op_Projects_Project $project)
 {
     $linkTree = '/projects/project/tree/?id=' . $project->GetId();
     return $linkTree;
 }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
 public function testThatIsNotPossibleToUpdateAProjectBeforeInsertingIt()
 {
     $p = new C3op_Projects_Project();
     $p->SetTitle('no id project');
     $this->setExpectedException('C3op_Projects_ProjectMapperException');
     $this->projectMapper->update($p);
 }