diff --git a/tests/MultiFormSessionTest.php b/tests/MultiFormSessionTest.php deleted file mode 100644 index 96edc2b..0000000 --- a/tests/MultiFormSessionTest.php +++ /dev/null @@ -1,42 +0,0 @@ -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); - } - } - -} diff --git a/tests/MultiFormTest.php b/tests/MultiFormTest.php index 88acca8..cb89c6f 100644 --- a/tests/MultiFormTest.php +++ b/tests/MultiFormTest.php @@ -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 { ); } -} - +} \ No newline at end of file