Repair unit tests, make XHTMLCompiler_Directory call the PHP wrapper.
[xhtml-compiler.git] / tests / XHTMLCompiler / PageTest.php
blob243de7d736f1e0e0080d243228b5d1b56ed5f2c5
1 <?php
3 class XHTMLCompiler_PageTest extends XHTMLCompilerHarness
6 function setUp() {
7 parent::setUp();
8 // this is our "virtual filesystem", pay close attention!
9 $this->xc->setReturnValue('getConf',
10 array(
11 '' => 0,
12 'subdir' => 1, // recursion allowed
13 'flatdir' => 0, // recursion not allowed
15 array('allowed_dirs')
17 $this->php->setReturnValue('realpath', '/home/user', array('.'));
18 $this->php->setReturnValue('realpath', '/home/user', array(''));
19 $this->php->setReturnValue('realpath', '/home/user/subdir', array('subdir'));
20 $this->php->setReturnValue('realpath', '/home/user/flatdir', array('flatdir'));
23 function testConstruct() {
24 $this->php->setReturnValue('isFile', true, array('index.xhtml'));
25 $this->php->setReturnValue('isDir', true, array('.'));
26 $page = new XHTMLCompiler_Page('index.html');
27 $this->assertEqual($page->getPathStem(), 'index');
30 function testConstructUnusualFilename() {
31 $this->php->setReturnValue('isFile', true, array('@.xhtml'));
32 $this->php->setReturnValue('isDir', true, array('.'));
33 $page = new XHTMLCompiler_Page('@.html');
34 $this->assertEqual($page->getPathStem(), '@');
37 function testConstructUnusualDirectory() {
38 $this->php->setReturnValue('realpath', '/home/user/subdir/@', array('subdir/@'));
39 $this->php->setReturnValue('isFile', true, array('subdir/@/index.xhtml'));
40 $this->php->setReturnValue('isDir', true, array('subdir/@'));
41 $page = new XHTMLCompiler_Page('subdir/@/index.html');
42 $this->assertEqual($page->getPathStem(), 'subdir/@/index');
45 function testConstructInRecursiveDirectory() {
46 $this->php->setReturnValue('realpath', '/home/user/subdir/foo', array('subdir/foo'));
47 $this->php->setReturnValue('isFile', true, array('subdir/foo/index.xhtml'));
48 $this->php->setReturnValue('isDir', true, array('subdir/foo'));
49 $page = new XHTMLCompiler_Page('subdir/foo/index.html');
50 $this->assertEqual($page->getPathStem(), 'subdir/foo/index');
53 function testBadConstructDueToExtension() {
54 $this->expectException();
55 $page = new XHTMLCompiler_Page('main.php');
58 function testBadConstructDueToBadDirectory() {
59 $this->expectException();
60 $this->php->setReturnValue('realpath', '/home/user/notallowed', array('notallowed'));
61 $page = new XHTMLCompiler_Page('notallowed/main.html');
64 function testBadConstructDueToImaginaryDirectory() {
65 $this->expectException();
66 $this->php->setReturnValue('realpath', false, array('notallowed'));
67 $page = new XHTMLCompiler_Page('notallowed/main.html');
70 function testBadConstructDueToImaginaryDirectoryInRecursiveDirectory() {
71 $this->expectException();
72 $this->php->setReturnValue('realpath', false, array('subdir/null'));
73 $page = new XHTMLCompiler_Page('subdir/null/main.html');
76 function testBadConstructDueToNonRecursiveDirectory() {
77 $this->expectException();
78 $this->php->setReturnValue('realpath', '/home/user/flatdir/foobar', array('flatdir/foobar'));
79 $page = new XHTMLCompiler_Page('flatdir/foobar/main.html');
82 function testBadConstructDueToNoSrcFile() {
83 $this->expectException();
84 $this->php->setReturnValue('isFile', false, array('index.xhtml'));
85 $page = new XHTMLCompiler_Page('index.html');
88 function testBadConstructSharedPrefixWithGoodFolder() {
89 $this->expectException();
90 $this->php->setReturnValue('isFile', true, array('subdirectory/index.xhtml'));
91 $this->php->setReturnValue('realpath', '/home/user/subdirectory', array('subdirectory'));
92 $page = new XHTMLCompiler_Page('subdirectory/index.html');