Changing the way we include framework files. Instead of modifying the include_path...
[isso.git] / UnitTest / InstallerTest.php
1 <?php
2
3 require_once 'PHPUnit/Framework.php';
4 require_once ISSO . '/Installer.php';
5
6 class InstallerTest extends PHPUnit_Framework_TestCase
7 {
8 private $fixture;
9 private $input;
10
11 public function setUp()
12 {
13 global $rig;
14
15 $rig = $this;
16 BSApp::Registry()->input = $this->input = BSApp::LoadModule('Input');
17 }
18
19 private function _loadClass()
20 {
21 ob_start();
22 $this->fixture = new TestInstallerFixture('InstallerTest.php');
23 $data = ob_get_contents();
24 ob_clean();
25 ob_end_clean();
26 return $data;
27 }
28
29 public function stepCheck($step)
30 {
31 $this->assertEquals($this->input->in['step'], $step);
32 }
33
34 public function testWelcome()
35 {
36 $this->input->in['step'] = 0;
37 $data = $this->_loadClass();
38 $this->assertTrue(strpos($data, 'This is a welcome page.') !== false);
39 }
40
41 public function testStep1()
42 {
43 $this->input->in['step'] = 1;
44 $data = $this->_loadClass();
45 $this->assertTrue(strpos($data, '<div class="buttonlink"><a href="InstallerTest.php?step=2">Next Step</a></div>') !== false);
46 }
47
48 public function testLastStep()
49 {
50 $this->input->in['step'] = 2;
51 $data = $this->_loadClass();
52 $this->assertTrue(strpos($data, '<div class="buttonlink">FINAL LINK</div>') !== false);
53 }
54 }
55
56 class TestInstallerFixture extends BSInstaller
57 {
58 public $rig;
59
60 protected function _pageTitle()
61 {
62 return 'Test Installer';
63 }
64
65 protected function _finalLink()
66 {
67 return 'FINAL LINK';
68 }
69
70 protected function _welcomePage()
71 {
72 echo 'This is a welcome page.';
73 }
74
75 public function step1()
76 {
77 global $rig;
78 $rig->stepCheck(1);
79 }
80
81 public function step2()
82 {
83 global $rig;
84 $rig->stepCheck(2);
85 }
86 }
87
88 ?>