comicpress-core/test/ComicPressTest.php

49 lines
1.3 KiB
PHP
Raw Normal View History

<?php
require_once('PHPUnit/Framework.php');
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');
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
}
}
?>