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