/** * @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); }
/** * Write documents * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $filename * @param array $writers */ function write($phpPowerPoint, $filename, $writers) { $result = ''; // Write documents foreach ($writers as $writer => $extension) { $result .= date('H:i:s') . " Write to {$writer} format"; if (!is_null($extension)) { $xmlWriter = IOFactory::createWriter($phpPowerPoint, $writer); $xmlWriter->save(__DIR__ . DIRECTORY_SEPARATOR . "{$filename}.{$extension}"); rename(__DIR__ . "/{$filename}.{$extension}", __DIR__ . "/results/{$filename}.{$extension}"); } else { $result .= ' ... NOT DONE!'; } $result .= EOL; } $result .= getEndingNotes($writers); return $result; }
/** * @expectedException \Exception * @expectedExceptionMessage "WriterNotExists" is not a valid writer. */ public function testWriterException() { $object = new PhpProject(); IOFactory::createWriter($object, 'WriterNotExists'); }