[go: nahoru, domu]

Skip to content

Commit

Permalink
add test for opendocument_storage_zip
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/OpenDocument/trunk@282929 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
cweiske committed Jun 28, 2009
1 parent df0ee4a commit 1ff1466
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/zipstorage.phpt
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"

0 comments on commit 1ff1466

Please sign in to comment.