-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for opendocument_storage_zip
git-svn-id: http://svn.php.net/repository/pear/packages/OpenDocument/trunk@282929 c90b9560-bf6c-de11-be94-00142212c4b1
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--TEST-- | ||
Test Zip storage functionality | ||
--FILE-- | ||
<?php | ||
require_once 'OpenDocument/Storage/Zip.php'; | ||
$zip = new OpenDocument_Storage_Zip(); | ||
$zip->create('text'); | ||
$doms = array( | ||
'content' => $zip->getContentDom(), | ||
'meta' => $zip->getMetaDom(), | ||
'settings' => $zip->getSettingsDom(), | ||
'styles' => $zip->getStylesDom() | ||
); | ||
|
||
foreach ($doms as $type => $dom) { | ||
$root = $dom->firstChild; | ||
$root->appendChild( | ||
$dom->createElement('test', $type . '-unittest') | ||
); | ||
} | ||
$zip->setContentDom($doms['content']); | ||
$zip->setMetaDom($doms['meta']); | ||
$zip->setSettingsDom($doms['settings']); | ||
$zip->setStylesDom($doms['styles']); | ||
|
||
$name = sys_get_temp_dir() . '/opendocumentunittest-zip'; | ||
$zip->save($name); | ||
unset($zip, $dom, $root); | ||
|
||
var_dump(file_exists($name)); | ||
|
||
$zip = new OpenDocument_Storage_Zip(); | ||
$zip->open($name); | ||
$cont = $zip->getContentDom(); | ||
var_dump( | ||
$cont->firstChild->lastChild->tagName, | ||
$cont->firstChild->lastChild->nodeValue, | ||
$zip->getMetaDom()->firstChild->lastChild->nodeValue, | ||
$zip->getSettingsDom()->firstChild->lastChild->nodeValue, | ||
$zip->getStylesDom()->firstChild->lastChild->nodeValue | ||
); | ||
?> | ||
--CLEAN-- | ||
<?php | ||
unlink(sys_get_temp_dir() . '/opendocumentunittest-zip'); | ||
?> | ||
--EXPECT-- | ||
bool(true) | ||
string(4) "test" | ||
string(16) "content-unittest" | ||
string(13) "meta-unittest" | ||
string(17) "settings-unittest" | ||
string(15) "styles-unittest" |