mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 11:05:49 +02:00
MINOR Test step traversal in MultiFormTest
MINOR Removed MultiFormSessionTest and integrated with MultiFormTest
This commit is contained in:
parent
1e434e5acf
commit
c944adb7ba
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -19,6 +19,8 @@
|
|||||||
*/
|
*/
|
||||||
class MultiFormTest extends FunctionalTest {
|
class MultiFormTest extends FunctionalTest {
|
||||||
|
|
||||||
|
public static $fixture_file = 'multiform/tests/MultiFormTest.yml';
|
||||||
|
|
||||||
protected $controller;
|
protected $controller;
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
@ -33,6 +35,19 @@ class MultiFormTest extends FunctionalTest {
|
|||||||
$this->assertEquals('MultiFormTest_StepOne', $this->form->getStartStep());
|
$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() {
|
function testSecondStep() {
|
||||||
$this->assertEquals('MultiFormTest_StepTwo', $this->form->getCurrentStep()->getNextStep());
|
$this->assertEquals('MultiFormTest_StepTwo', $this->form->getCurrentStep()->getNextStep());
|
||||||
}
|
}
|
||||||
@ -46,16 +61,22 @@ class MultiFormTest extends FunctionalTest {
|
|||||||
$this->assertEquals(3, $this->form->getAllStepsLinear()->Count());
|
$this->assertEquals(3, $this->form->getAllStepsLinear()->Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNextStepAction() {
|
function testStepTraversal() {
|
||||||
$this->get($this->controller->class);
|
$this->get($this->controller->class);
|
||||||
$response = $this->submitForm('MultiFormTest_Form', 'action_next', array(
|
|
||||||
|
$actionNextResponse = $this->submitForm('MultiFormTest_Form', 'action_next', array(
|
||||||
'FirstName' => 'Joe',
|
'FirstName' => 'Joe',
|
||||||
'Surname' => 'Bloggs',
|
'Surname' => 'Bloggs',
|
||||||
'Email' => 'joe@bloggs.com'
|
'Email' => 'joe@bloggs.com'
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $actionNextResponse->getStatusCode());
|
||||||
$this->assertNotNull($response->getBody());
|
$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 {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user