2009-07-07 02:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('PHPUnit/Framework.php');
|
2009-10-18 21:05:10 +00:00
|
|
|
require_once('MockPress/mockpress.php');
|
2009-11-07 17:18:53 +00:00
|
|
|
require_once('ComicPress.inc');
|
2009-11-07 18:14:33 +00:00
|
|
|
require_once('vfsStream/vfsStream.php');
|
2009-07-08 23:54:56 +00:00
|
|
|
|
|
|
|
class ComicPressTest extends PHPUnit_Framework_TestCase {
|
|
|
|
function setUp() {
|
|
|
|
_reset_wp();
|
|
|
|
$this->cp = new ComicPress();
|
2009-07-29 02:38:20 +00:00
|
|
|
|
2009-11-07 18:14:33 +00:00
|
|
|
vfsStreamWrapper::register();
|
|
|
|
vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
|
2009-07-29 02:38:20 +00:00
|
|
|
}
|
2009-11-07 18:14:33 +00:00
|
|
|
|
|
|
|
function providerTestCascadeSearch() {
|
|
|
|
$parent = vfsStream::url('root/parent/file');
|
|
|
|
$child = vfsStream::url('root/child/file');
|
|
|
|
|
|
|
|
return array(
|
|
|
|
array(array(), false, false),
|
|
|
|
array(array('child'), false, $child),
|
|
|
|
array(array('parent'), false, $parent),
|
|
|
|
array(array('child', 'parent'), false, $child),
|
|
|
|
array(array('child', 'parent'), true, $parent),
|
|
|
|
);
|
2009-08-06 02:29:54 +00:00
|
|
|
}
|
2009-11-07 18:14:33 +00:00
|
|
|
|
2009-08-06 02:29:54 +00:00
|
|
|
/**
|
2009-11-07 18:14:33 +00:00
|
|
|
* @dataProvider providerTestCascadeSearch
|
2009-08-06 02:29:54 +00:00
|
|
|
*/
|
2009-11-07 18:14:33 +00:00
|
|
|
function testCascadeSearch($create, $force_parent, $expected_result) {
|
|
|
|
mkdir(vfsStream::url('root/parent'), 0777);
|
|
|
|
mkdir(vfsStream::url('root/child'), 0777);
|
|
|
|
|
|
|
|
_set_template_directory(vfsStream::url('root/parent'));
|
|
|
|
_set_stylesheet_directory(vfsStream::url('root/child'));
|
|
|
|
|
|
|
|
foreach ($create as $type) {
|
|
|
|
file_put_contents(vfsStream::url("root/${type}/file"), 'file');
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = $this->cp->cascade_search('file', $force_parent);
|
|
|
|
$this->assertTrue($result === $expected_result);
|
2009-08-06 02:29:54 +00:00
|
|
|
}
|
2009-11-07 18:47:08 +00:00
|
|
|
|
|
|
|
function providerTestCategorySearch() {
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerTestCategorySearch
|
|
|
|
*/
|
|
|
|
function testCategorySearch() {
|
|
|
|
mkdir(vfsStream::url('root/style/site/comic/chapter-1/part-1'), 0777, true);
|
|
|
|
|
|
|
|
}
|
2009-07-07 02:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|