<?php
require_once 'PHPUnit/Framework.php';
require_once ISSO . '/Installer.php';
require_once ISSO . '/Input.php';
class InstallerTest extends PHPUnit_Framework_TestCase
{
private $fixture;
private $input;
public function setUp()
{
$this->input = BSApp::$input = new BSInput();
TestInstallerFixture::$rig = $this;
}
private function _loadClass()
{
ob_start();
$this->fixture = new TestInstallerFixture('InstallerTest.php');
$data = ob_get_contents();
ob_clean();
ob_end_clean();
return $data;
}
public function stepCheck($step)
{
$this->assertEquals($this->input->in['step'], $step);
}
public function testWelcome()
{
$this->input->in['step'] = 0;
$data = $this->_loadClass();
$this->assertTrue(strpos($data, 'This is a welcome page.') !== false);
}
public function testStep1()
{
$this->input->in['step'] = 1;
$data = $this->_loadClass();
$this->assertTrue(strpos($data, '<div class="buttonlink"><a href="InstallerTest.php?step=2">Next Step</a></div>') !== false);
}
public function testLastStep()
{
$this->input->in['step'] = 2;
$data = $this->_loadClass();
$this->assertTrue(strpos($data, '<div class="buttonlink">FINAL LINK</div>') !== false);
}
}
class TestInstallerFixture extends BSInstaller
{
public static $rig;
protected function _pageTitle()
{
return 'Test Installer';
}
protected function _finalLink()
{
return 'FINAL LINK';
}
protected function _welcomePage()
{
echo 'This is a welcome page.';
}
public function step1()
{
self::$rig->stepCheck(1);
}
public function step2()
{
self::$rig->stepCheck(2);
}
}
?>