Adding fixes in the unit tests for all the refactoring we did
[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 global $rig;
15
16 $rig = $this;
17 BSApp::$input = new BSInput();
18 }
19
20 private function _loadClass()
21 {
22 ob_start();
23 $this->fixture = new TestInstallerFixture('InstallerTest.php');
24 $data = ob_get_contents();
25 ob_clean();
26 ob_end_clean();
27 return $data;
28 }
29
30 public function stepCheck($step)
31 {
32 $this->assertEquals($this->input->in['step'], $step);
33 }
34
35 public function testWelcome()
36 {
37 $this->input->in['step'] = 0;
38 $data = $this->_loadClass();
39 $this->assertTrue(strpos($data, 'This is a welcome page.') !== false);
40 }
41
42 public function testStep1()
43 {
44 $this->input->in['step'] = 1;
45 $data = $this->_loadClass();
46 $this->assertTrue(strpos($data, '<div class="buttonlink"><a href="InstallerTest.php?step=2">Next Step</a></div>') !== false);
47 }
48
49 public function testLastStep()
50 {
51 $this->input->in['step'] = 2;
52 $data = $this->_loadClass();
53 $this->assertTrue(strpos($data, '<div class="buttonlink">FINAL LINK</div>') !== false);
54 }
55 }
56
57 class TestInstallerFixture extends BSInstaller
58 {
59 public $rig;
60
61 protected function _pageTitle()
62 {
63 return 'Test Installer';
64 }
65
66 protected function _finalLink()
67 {
68 return 'FINAL LINK';
69 }
70
71 protected function _welcomePage()
72 {
73 echo 'This is a welcome page.';
74 }
75
76 public function step1()
77 {
78 global $rig;
79 $rig->stepCheck(1);
80 }
81
82 public function step2()
83 {
84 global $rig;
85 $rig->stepCheck(2);
86 }
87 }
88
89 ?>