assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->getPhpPresentation()); } /** * @expectedException \Exception * @expectedExceptionMessage No PhpPresentation assigned. */ public function testEmptyConstruct() { $object = new Serialized(); $object->getPhpPresentation(); } /** * @expectedException \Exception * @expectedExceptionMessage Filename is empty. */ public function testSaveEmpty() { $object = new Serialized(new PhpPresentation()); $object->save(''); } /** * @expectedException \Exception * @expectedExceptionMessage No PhpPresentation assigned. */ public function testSaveNoObject() { $object = new Serialized(); $object->save('file.phpppt'); } public function testSave() { $oPhpPresentation = new PhpPresentation(); $oSlide = $oPhpPresentation->getActiveSlide(); $oImage = $oSlide->createDrawingShape(); $oImage->setPath(PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'PhpPresentationLogo.png'); $object = new Serialized($oPhpPresentation); $file = tempnam(sys_get_temp_dir(), 'PhpPresentation_Serialized'); $this->assertFileExists($file, $object->save($file)); } /** * @expectedException \Exception * @expectedExceptionMessage Could not open */ public function testSaveNotExistingDir() { $oPhpPresentation = new PhpPresentation(); $oSlide = $oPhpPresentation->getActiveSlide(); $oImage = $oSlide->createDrawingShape(); $oImage->setPath(PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'PhpPresentationLogo.png'); $object = new Serialized($oPhpPresentation); $file = tempnam(sys_get_temp_dir(), 'PhpPresentation_Serialized'); $this->assertFileExists($file, $object->save($file.DIRECTORY_SEPARATOR.'test'.DIRECTORY_SEPARATOR.'test')); } public function testSaveOverwriting() { $oPhpPresentation = new PhpPresentation(); $oSlide = $oPhpPresentation->getActiveSlide(); $oImage = $oSlide->createDrawingShape(); $oImage->setPath(PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'PhpPresentationLogo.png'); $object = new Serialized($oPhpPresentation); $file = tempnam(sys_get_temp_dir(), 'PhpPresentation_Serialized'); file_put_contents($file, rand(1, 100)); $this->assertFileExists($file, $object->save($file)); } }