Add swiftmailer external.
[xhtml-compiler.git] / tests / XHTMLCompiler / PageTest.php
blob415f1bb8be6dccc808de6dabaf05507534b92fae
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', array(''));
20 $this->php->setReturnValue('realpath', '/home/user/subdir', array('subdir'));
21 $this->php->setReturnValue('realpath', '/home/user/flatdir', array('flatdir'));
24 function testConstruct() {
25 $this->php->setReturnValue('isFile', true, array('index.xhtml'));
26 $this->php->setReturnValue('isDir', true, array('.'));
27 $this->php->setReturnValue('realpath', '/home/user/index.html', array('index.html'));
28 $page = new XHTMLCompiler_Page('index.html');
29 $this->assertEqual($page->getPathStem(), 'index');
32 function testConstructUnusualFilename() {
33 $this->php->setReturnValue('isFile', true, array('@.xhtml'));
34 $this->php->setReturnValue('isDir', true, array('.'));
35 $page = new XHTMLCompiler_Page('@.html');
36 $this->assertEqual($page->getPathStem(), '@');
39 function testConstructUnusualDirectory() {
40 $this->php->setReturnValue('realpath', '/home/user/subdir/@', array('subdir/@'));
41 $this->php->setReturnValue('isFile', true, array('subdir/@/index.xhtml'));
42 $this->php->setReturnValue('isDir', true, array('subdir/@'));
43 $page = new XHTMLCompiler_Page('subdir/@/index.html');
44 $this->assertEqual($page->getPathStem(), 'subdir/@/index');
47 function testConstructInRecursiveDirectory() {
48 $this->php->setReturnValue('realpath', '/home/user/subdir/foo', array('subdir/foo'));
49 $this->php->setReturnValue('isFile', true, array('subdir/foo/index.xhtml'));
50 $this->php->setReturnValue('isDir', true, array('subdir/foo'));
51 $page = new XHTMLCompiler_Page('subdir/foo/index.html');
52 $this->assertEqual($page->getPathStem(), 'subdir/foo/index');
55 function testBadConstructDueToExtension() {
56 $this->expectException();
57 $page = new XHTMLCompiler_Page('main.php');
60 function testBadConstructDueToBadDirectory() {
61 $this->expectException();
62 $this->php->setReturnValue('realpath', '/home/user/notallowed', array('notallowed'));
63 $page = new XHTMLCompiler_Page('notallowed/main.html');
66 function testBadConstructDueToImaginaryDirectory() {
67 $this->expectException();
68 $this->php->setReturnValue('realpath', false, array('notallowed'));
69 $page = new XHTMLCompiler_Page('notallowed/main.html');
72 function testBadConstructDueToImaginaryDirectoryInRecursiveDirectory() {
73 $this->expectException();
74 $this->php->setReturnValue('realpath', false, array('subdir/null'));
75 $page = new XHTMLCompiler_Page('subdir/null/main.html');
78 function testBadConstructDueToNonRecursiveDirectory() {
79 $this->expectException();
80 $this->php->setReturnValue('realpath', '/home/user/flatdir/foobar', array('flatdir/foobar'));
81 $page = new XHTMLCompiler_Page('flatdir/foobar/main.html');
84 function testBadConstructDueToNoSrcFile() {
85 $this->expectException();
86 $this->php->setReturnValue('isFile', false, array('index.xhtml'));
87 $page = new XHTMLCompiler_Page('index.html');
90 function testBadConstructSharedPrefixWithGoodFolder() {
91 $this->expectException();
92 $this->php->setReturnValue('isFile', true, array('subdirectory/index.xhtml'));
93 $this->php->setReturnValue('realpath', '/home/user/subdirectory', array('subdirectory'));
94 $page = new XHTMLCompiler_Page('subdirectory/index.html');