Esempio n. 1
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Could not open file
  */
 public function testSaveException()
 {
     $fileOutput = tempnam(sys_get_temp_dir(), 'PHPPROJECT');
     file_put_contents($fileOutput, 'AA');
     chmod($fileOutput, 044);
     $oPHPProject = new PhpProject();
     $oTask1 = $oPHPProject->createTask();
     $oTask1->setName('Task1Test');
     $xmlWriter = IOFactory::createWriter($oPHPProject, 'MsProjectMPX');
     $xmlWriter->save($fileOutput);
 }
Esempio n. 2
0
 /**
  * @return multitype:Ambigous <number, unknown>
  */
 private function sanitizeProject()
 {
     // Info Project
     $minDate = 0;
     // Browse all tasks
     $arrTasks = $this->phpProject->getAllTasks();
     foreach ($arrTasks as $oTask) {
         if ($oTask->getTaskCount() == 0) {
             $this->sanitizeTask($oTask);
         } else {
             $this->sanitizeTaskParent($oTask);
         }
         $tStartDate = $oTask->getStartDate();
         if ($minDate == 0 || $tStartDate < $minDate) {
             $minDate = $tStartDate;
         }
     }
     // Browse all Resources
     $numResource = 0;
     foreach ($this->phpProject->getAllResources() as $oResource) {
         $oResource->setIndex($numResource);
         $numResource++;
     }
     return array('date_start' => (int) $minDate);
 }
Esempio n. 3
0
 /**
  * Resource Assignment
  * @param array $record
  */
 private function readRecord75(array $record)
 {
     // 0 : Record
     // 1 : ID
     $idResource = null;
     if (isset($record[1]) && !empty($record[1])) {
         $idResource = $record[1];
     }
     // 2 : Units
     // 3 : Work
     // 4 : Planned Work
     // 5 : Actual Work
     // 6 : Overtime Work
     // 7 : Cost
     // 8 : Planned Cost
     // 9 : Actual Cost
     // 10 : Start*
     // 11 : Finish*
     // 12 : Delay
     // 13 : Resource Unique ID
     if (!is_null($idResource) && $this->oPreviousTask instanceof Task) {
         $oResource = $this->phpProject->getResourceFromIndex($idResource);
         if (!is_null($oResource)) {
             $this->oPreviousTask->addResource($oResource);
         }
     }
 }
Esempio n. 4
0
 /**
  * Node "Allocation"
  * @param XMLReader $oXML
  * @param \DOMElement $domNode
  */
 private function readNodeAllocation(\DOMElement $domNode)
 {
     // Attributes
     $idTask = $domNode->getAttribute('task-id');
     $idResource = $domNode->getAttribute('resource-id');
     $oResource = $this->phpProject->getResourceFromIndex($idResource);
     $oTask = $this->phpProject->getTaskFromIndex($idTask);
     if ($oResource instanceof Resource && $oTask instanceof Task) {
         $oTask->addResource($oResource);
     }
 }
Esempio n. 5
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Active task index is out of bounds.
  */
 public function testTaskSetActiveException()
 {
     $object = new PhpProject();
     $object->setActiveTaskIndex(10);
 }