MINOR Test step traversal in MultiFormTest

MINOR Removed MultiFormSessionTest and integrated with MultiFormTest
This commit is contained in:
Sean Harvey 2009-07-20 22:36:32 +00:00
parent 1e434e5acf
commit c944adb7ba
2 changed files with 26 additions and 48 deletions

View File

@ -1,42 +0,0 @@
<?php
/**
* Tests for {@link MultiFormSessionTest}
*
* @package multiform
* @subpackage tests
*/
class MultiFormSessionTest extends SapphireTest {
/**
* Set up the instance of MultiFormSession, writing
* a record to the database for this test. We persist
* the object in our tests by assigning $this->session
*/
function setUp() {
parent::setUp();
$this->session = new MultiFormSession();
$this->session->write();
}
/**
* Test generation of a new session.
*/
function testSessionGeneration() {
$this->assertTrue($this->session->ID != 0);
$this->assertTrue($this->session->ID > 0);
}
/**
* Test that a MemberID was set on MultiFormSession if
* a member is logged in.
*/
function testMemberLogging() {
$session = new MultiFormSession();
$session->write();
if($memberID = Member::currentUserID()) {
$this->assertEquals($memberID, $session->SubmitterID);
}
}
}

View File

@ -19,6 +19,8 @@
*/
class MultiFormTest extends FunctionalTest {
public static $fixture_file = 'multiform/tests/MultiFormTest.yml';
protected $controller;
function setUp() {
@ -33,6 +35,19 @@ class MultiFormTest extends FunctionalTest {
$this->assertEquals('MultiFormTest_StepOne', $this->form->getStartStep());
}
function testSessionGeneration() {
$this->assertTrue($this->form->session->ID > 0);
}
function testMemberLogging() {
$this->session()->inst_set('loggedInAs', 1);
$session = $this->form->session;
$session->write();
$this->assertEquals(1, $session->SubmitterID);
}
function testSecondStep() {
$this->assertEquals('MultiFormTest_StepTwo', $this->form->getCurrentStep()->getNextStep());
}
@ -46,16 +61,22 @@ class MultiFormTest extends FunctionalTest {
$this->assertEquals(3, $this->form->getAllStepsLinear()->Count());
}
function testNextStepAction() {
function testStepTraversal() {
$this->get($this->controller->class);
$response = $this->submitForm('MultiFormTest_Form', 'action_next', array(
$actionNextResponse = $this->submitForm('MultiFormTest_Form', 'action_next', array(
'FirstName' => 'Joe',
'Surname' => 'Bloggs',
'Email' => 'joe@bloggs.com'
));
$this->assertEquals(200, $response->getStatusCode());
$this->assertNotNull($response->getBody());
$this->assertEquals(200, $actionNextResponse->getStatusCode());
$this->assertNotNull($actionNextResponse->getBody());
$actionPrevResponse = $this->submitForm('MultiFormTest_Form', 'action_prev');
$this->assertEquals(200, $actionPrevResponse->getStatusCode());
$this->assertNotNull($actionPrevResponse->getBody());
}
}
@ -115,5 +136,4 @@ class MultiFormTest_StepThree extends MultiFormStep implements TestOnly {
);
}
}
}