Merge pull request #35 from spekulatius/remove-trailing-spaces

remove trailing spaces in the codebase
This commit is contained in:
Daniel Hensby 2015-11-02 20:54:53 +00:00
commit 262d31166b
6 changed files with 164 additions and 164 deletions

View File

@ -5,7 +5,7 @@
* to the database directly by a {@link MultiFormStep}.
* Only needed for objects which aren't stored in the session,
* which is the default.
*
*
* This decorator also augments get() requests to the datalayer
* by automatically filtering out temporary objects.
* You can override this filter by putting the following statement
@ -15,27 +15,27 @@
* @package multiform
*/
class MultiFormObjectDecorator extends DataExtension {
private static $db = array(
'MultiFormIsTemporary' => 'Boolean',
);
private static $has_one = array(
'MultiFormSession' => 'MultiFormSession',
);
public function augmentSQL(SQLSelect $query) {
// If you're querying by ID, ignore the sub-site - this is a bit ugly...
if(
strpos($query->where[0], ".`ID` = ") === false
&& strpos($query->where[0], ".ID = ") === false
strpos($query->where[0], ".`ID` = ") === false
&& strpos($query->where[0], ".ID = ") === false
&& strpos($query->where[0], "ID = ") !== 0
&& !$this->wantsTemporary($query)
) {
$query->where[] = "\"{$query->from[0]}\".\"MultiFormIsTemporary\" = 0";
$query->where[] = "\"{$query->from[0]}\".\"MultiFormIsTemporary\" = 0";
}
}
/**
* Determines if the current query is supposed
* to be exempt from the automatic filtering out

View File

@ -4,18 +4,18 @@
* MultiForm manages the loading of single form steps, and acts as a state
* machine that connects to a {@link MultiFormSession} object as a persistence
* layer.
*
*
* CAUTION: If you're using controller permission control,
* you have to allow the following methods:
*
* <code>
* private static $allowed_actions = array('next','prev');
* </code>
*
* </code>
*
* @package multiform
*/
abstract class MultiForm extends Form {
/**
* A session object stored in the database, to identify and store
* data for this MultiForm instance.
@ -23,13 +23,13 @@ abstract class MultiForm extends Form {
* @var MultiFormSession
*/
protected $session;
/**
* The current encrypted MultiFormSession identification.
* @var string
*/
protected $currentSessionHash;
/**
* Defines which subclass of {@link MultiFormStep} should be the first
* step in the multi-step process.
@ -37,7 +37,7 @@ abstract class MultiForm extends Form {
* @var string Classname of a {@link MultiFormStep} subclass
*/
public static $start_step;
/**
* Set the casting for these fields.
*
@ -48,7 +48,7 @@ abstract class MultiForm extends Form {
'TotalStepCount' => 'Int',
'CompletedPercent' => 'Float'
);
/**
* These fields are ignored when saving the raw form data into session.
* This ensures only field data is saved, and nothing else that's useless
@ -62,15 +62,15 @@ abstract class MultiForm extends Form {
'MultiFormSessionID',
'SecurityID'
);
/**
* Any of the actions defined in this variable are exempt from
* being validated.
*
*
* This is most useful for the "Back" (action_prev) action, as
* you typically don't validate the form when the user is going
* back a step.
*
*
* @var array
*/
public static $actions_exempt_from_validation = array(
@ -124,7 +124,7 @@ abstract class MultiForm extends Form {
if(!empty($_REQUEST[$exemptAction])) {
$applyValidation = false;
break;
}
}
}
}
@ -134,19 +134,19 @@ abstract class MultiForm extends Form {
$validator = $currentStep->getValidator();
}
}
// Give the fields, actions, and validation for the current step back to the parent Form class
parent::__construct($controller, $name, $fields, $actions, $validator);
// Set a hidden field in our form with an encrypted hash to identify this session.
$this->fields->push(new HiddenField('MultiFormSessionID', false, $this->session->Hash));
// If there is saved data for the current step, we load it into the form it here
//(CAUTION: loadData() MUST unserialize first!)
if($data = $currentStep->loadData()) {
$this->loadDataFrom($data);
}
// Disable security token - we tie a form to a session ID instead
$this->disableSecurityToken();
}
@ -159,23 +159,23 @@ abstract class MultiForm extends Form {
public function getController() {
return $this->controller;
}
/**
* Get the current step.
*
*
* If StepID has been set in the URL, we attempt to get that record
* by the ID. Otherwise, we check if there's a current step ID in
* our session record. Failing those cases, we assume that the form has
* just been started, and so we create the first step and return it.
*
*
* @return MultiFormStep subclass
*/
public function getCurrentStep() {
$startStepClass = static::$start_step;
// Check if there was a start step defined on the subclass of MultiForm
if(!isset($startStepClass)) user_error('MultiForm::init(): Please define a $start_step on ' . $this->class, E_USER_ERROR);
// Determine whether we use the current step, or create one if it doesn't exist
$currentStep = null;
if(isset($_GET['StepID'])) {
@ -183,8 +183,8 @@ abstract class MultiForm extends Form {
$currentStep = DataObject::get_one('MultiFormStep', "\"SessionID\" = {$this->session->ID} AND \"ID\" = {$stepID}");
} elseif($this->session->CurrentStepID) {
$currentStep = $this->session->CurrentStep();
}
}
// Always fall back to creating a new step (in case the session or request data is invalid)
if(!$currentStep || !$currentStep->ID) {
$currentStep = Object::create($startStepClass);
@ -194,15 +194,15 @@ abstract class MultiForm extends Form {
$this->session->write();
$this->session->flushCache();
}
if($currentStep) $currentStep->setForm($this);
return $currentStep;
}
/**
* Set the step passed in as the current step.
*
*
* @param MultiFormStep $step A subclass of MultiFormStep
* @return boolean The return value of write()
*/
@ -212,54 +212,54 @@ abstract class MultiForm extends Form {
return $this->session->write();
}
/**
* Accessor method to $this->session.
*
*
* @return MultiFormSession
*/
public function getSession() {
return $this->session;
}
/**
* Set up the session.
*
*
* If MultiFormSessionID isn't set, we assume that this is a new
* multiform that requires a new session record to be created.
*
*
* @TODO Fix the fact you can continually refresh and create new records
* if MultiFormSessionID isn't set.
*
*
* @TODO Not sure if we should bake the session stuff directly into MultiForm.
* Perhaps it would be best dealt with on a separate class?
*/
protected function setSession() {
$this->session = $this->getCurrentSession();
// If there was no session found, create a new one instead
if(!$this->session) {
$this->session = new MultiFormSession();
}
// Create encrypted identification to the session instance if it doesn't exist
if(!$this->session->Hash) {
$this->session->Hash = sha1($this->session->ID . '-' . microtime());
$this->session->write();
}
}
/**
* Set the currently used encrypted hash to identify
* the MultiFormSession.
*
*
* @param string $hash Encrypted identification to session
*/
public function setCurrentSessionHash($hash) {
$this->currentSessionHash = $hash;
$this->setSession();
}
/**
* Return the currently used {@link MultiFormSession}
* @return MultiFormSession|boolean FALSE
@ -280,13 +280,13 @@ abstract class MultiForm extends Form {
return $this->session;
}
/**
* Get all steps saved in the database for the currently active session,
* in the order they were saved, oldest to newest (automatically ordered by ID).
* If you want a full chain of steps regardless if they've already been saved
* to the database, use {@link getAllStepsLinear()}.
*
*
* @param String $filter SQL WHERE statement
* @return DataObjectSet|boolean A set of MultiFormStep subclasses
*/
@ -295,18 +295,18 @@ abstract class MultiForm extends Form {
$filter .= sprintf("\"SessionID\" = '%s'", $this->session->ID);
return DataObject::get('MultiFormStep', $filter);
}
/**
* Get a step which was previously saved to the database in the current session.
* Caution: This might cause unexpected behaviour if you have multiple steps
* in your chain with the same classname.
*
*
* @param string $className Classname of a {@link MultiFormStep} subclass
* @return MultiFormStep
*/
function getSavedStepByClass($className) {
return DataObject::get_one(
'MultiFormStep',
'MultiFormStep',
sprintf("\"SessionID\" = '%s' AND \"ClassName\" = '%s'",
$this->session->ID,
Convert::raw2sql($className)
@ -336,7 +336,7 @@ abstract class MultiForm extends Form {
function actionsFor($step) {
// Create default multi step actions (next, prev), and merge with extra actions, if any
$actions = (class_exists('FieldList')) ? new FieldList() : new FieldSet();
// If the form is at final step, create a submit button to perform final actions
// The last step doesn't have a next button, so add that action to any step that isn't the final one
if($step->isFinalStep()) {
@ -344,7 +344,7 @@ abstract class MultiForm extends Form {
} else {
$actions->push(new FormAction('next', $step->getNextText()));
}
// If there is a previous step defined, add the back button
if($step->getPreviousStep() && $step->canGoBack()) {
// If there is a next step, insert the action before the next action
@ -358,10 +358,10 @@ abstract class MultiForm extends Form {
// Merge any extra action fields defined on the step
$actions->merge($step->getExtraActions());
return $actions;
}
/**
* Return a rendered version of this form, with a specific template.
* Looks through the step ancestory templates (MultiFormStep, current step
@ -384,13 +384,13 @@ abstract class MultiForm extends Form {
return $return;
}
/**
* This method saves the data on the final step, after submitting.
* It should always be overloaded with parent::finish($data, $form)
* so you can create your own functionality which handles saving
* of all the data collected through each step of the form.
*
*
* @param array $data The request data returned from the form
* @param object $form The form that the action was called on
*/
@ -410,15 +410,15 @@ abstract class MultiForm extends Form {
}
}
/**
* Determine what to do when the next action is called.
*
*
* Saves the current step session data to the database, creates the
* new step based on getNextStep() of the current step (or fetches
* an existing one), resets the current step to the next step,
* then redirects to the newly set step.
*
*
* @param array $data The request data returned from the form
* @param object $form The form that the action was called on
*/
@ -428,7 +428,7 @@ abstract class MultiForm extends Form {
// Get the next step class
$nextStepClass = $this->getCurrentStep()->getNextStep();
if(!$nextStepClass) {
$this->controller->redirectBack();
return false;
@ -455,18 +455,18 @@ abstract class MultiForm extends Form {
// Set the next step found as the current step
$this->setCurrentStep($nextStep);
// Redirect to the next step
$this->controller->redirect($nextStep->Link());
}
/**
* Determine what to do when the previous action is called.
*
*
* Retrieves the previous step class, finds the record for that
* class in the DB, and sets the current step to that step found.
* Finally, it redirects to that step.
*
*
* @param array $data The request data returned from the form
* @param object $form The form that the action was called on
*/
@ -484,21 +484,21 @@ abstract class MultiForm extends Form {
// Get the previous step of the class instance returned from $currentStep->getPreviousStep()
$prevStep = DataObject::get_one($prevStepClass, "\"SessionID\" = {$this->session->ID}");
// Set the current step as the previous step
$this->setCurrentStep($prevStep);
// Redirect to the previous step
$this->controller->redirect($prevStep->Link());
}
/**
* Save the raw data given back from the form into session.
*
*
* Take the submitted form data for the current step, removing
* any key => value pairs that shouldn't be saved, then saves
* the data into the session.
*
*
* @param array $data An array of data to save
*/
protected function save($data) {
@ -513,21 +513,21 @@ abstract class MultiForm extends Form {
}
return;
}
// ############ Misc ############
/**
* Add the MultiFormSessionID variable to the URL on form submission.
* This is a means to persist the session, by adding it's identification
* to the URL, which ties it back to this MultiForm instance.
*
*
* @return string
*/
function FormAction() {
$action = parent::FormAction();
$action .= (strpos($action, '?')) ? '&amp;' : '?';
$action .= "MultiFormSessionID={$this->session->Hash}";
return $action;
}
@ -563,17 +563,17 @@ abstract class MultiForm extends Form {
*/
public function getAllStepsLinear() {
$stepsFound = (class_exists('ArrayList')) ? new ArrayList() : new DataObjectSet();
$firstStep = DataObject::get_one(static::$start_step, "\"SessionID\" = {$this->session->ID}");
$firstStep->LinkingMode = ($firstStep->ID == $this->getCurrentStep()->ID) ? 'current' : 'link';
$firstStep->setForm($this);
$stepsFound->push($firstStep);
$this->getAllStepsRecursive($firstStep, $stepsFound);
return $stepsFound;
}
/**
* Recursively run through steps using the getNextStep() method on each step
* to determine what the next step is, gathering each step along the way.
@ -581,7 +581,7 @@ abstract class MultiForm extends Form {
* If a step in the chain was already saved to the database in the current
* session, its used - otherwise a singleton of this step is used.
* Caution: Doesn't consider branching for steps which aren't in the database yet.
*
*
* @param $step Subclass of MultiFormStep to find the next step of
* @param $stepsFound $stepsFound DataObjectSet reference, the steps found to call back on
* @return DataObjectSet of MultiFormStep instances
@ -595,7 +595,7 @@ abstract class MultiForm extends Form {
if(!$nextStep) {
// If it's not in the DB, we use a singleton instance of it instead - this step hasn't been accessed yet
$nextStep = singleton($step->getNextStep());
}
}
$nextStep->LinkingMode = ($nextStep->ID == $this->getCurrentStep()->ID) ? 'current' : 'link';
$nextStep->setForm($this);
// Add the array data, and do a callback
@ -607,23 +607,23 @@ abstract class MultiForm extends Form {
return $stepsFound;
}
}
/**
* Number of steps already completed (excluding currently started step).
* The way we determine a step is complete is to check if it has the Data
* field filled out with a serialized value, then we know that the user has
* clicked next on the given step, to proceed.
*
*
* @TODO Not sure if it's entirely appropriate to check if Data is set as a
* way to determine a step is "completed".
*
*
* @return int
*/
public function getCompletedStepCount() {
$steps = DataObject::get('MultiFormStep', "\"SessionID\" = {$this->session->ID} && \"Data\" IS NOT NULL");
return $steps ? $steps->Count() : 0;
}
/**
* Total number of steps in the shortest path (only counting straight path without any branching)
* The way we determine this is to check if each step has a next_step string variable set. If it's
@ -634,7 +634,7 @@ abstract class MultiForm extends Form {
public function getTotalStepCount() {
return $this->getAllStepsLinear() ? $this->getAllStepsLinear()->Count() : 0;
}
/**
* Percentage of steps completed (excluding currently started step)
*

View File

@ -1,22 +1,22 @@
<?php
/**
* Serializes one or more {@link MultiFormStep}s into
* Serializes one or more {@link MultiFormStep}s into
* a database object.
*
*
* MultiFormSession also stores the current step, so that
* the {@link MultiForm} and {@link MultiFormStep} classes
* know what the current step is.
*
*
* @package multiform
*/
class MultiFormSession extends DataObject {
private static $db = array(
'Hash' => 'Varchar(40)', // cryptographic hash identification to this session
'IsComplete' => 'Boolean' // flag to determine if this session is marked completed
);
private static $has_one = array(
'Submitter' => 'Member',
'CurrentStep' => 'MultiFormStep'
@ -25,10 +25,10 @@ class MultiFormSession extends DataObject {
private static $has_many = array(
'FormSteps' => 'MultiFormStep'
);
/**
* Mark this session as completed.
*
*
* This sets the flag "IsComplete" to true,
* and writes the session back.
*/
@ -36,7 +36,7 @@ class MultiFormSession extends DataObject {
$this->IsComplete = 1;
$this->write();
}
/**
* These actions are performed when write() is called on this object.
*/
@ -44,7 +44,7 @@ class MultiFormSession extends DataObject {
// save submitter if a Member is logged in
$currentMember = Member::currentUser();
if(!$this->SubmitterID && $currentMember) $this->SubmitterID = $currentMember->ID;
parent::onBeforeWrite();
}
@ -61,7 +61,7 @@ class MultiFormSession extends DataObject {
$step->destroy();
}
}
parent::onBeforeDelete();
}

View File

@ -6,7 +6,7 @@
* encapsulates the functionality required for the step to be aware of itself
* in the process by knowing what it's next step is, and if applicable, it's previous
* step.
*
*
* @package multiform
*/
class MultiFormStep extends DataObject {
@ -14,14 +14,14 @@ class MultiFormStep extends DataObject {
private static $db = array(
'Data' => 'Text' // stores serialized maps with all session information
);
private static $has_one = array(
'Session' => 'MultiFormSession'
);
/**
* Centerpiece of the flow control for the form.
*
*
* If set to a string, you have a linear form flow
* If set to an array, you should use {@link getNextStep()}
* to enact flow control and branching to different form
@ -31,7 +31,7 @@ class MultiFormStep extends DataObject {
* @var array|string
*/
public static $next_steps;
/**
* Each {@link MultiForm} subclass needs at least
* one step which is marked as the "final" one
@ -45,7 +45,7 @@ class MultiFormStep extends DataObject {
/**
* This variable determines whether a user can use
* the "back" action from this step.
*
*
* @TODO This does not check if the arbitrarily chosen step
* using the step indicator is actually a previous step, so
* unless you remove the link from the indicator template, or
@ -55,23 +55,23 @@ class MultiFormStep extends DataObject {
* @var boolean
*/
protected static $can_go_back = true;
/**
* Title of this step.
*
*
* Used for the step indicator templates.
*
* @var string
*/
protected $title;
/**
* Form class that this step is directly related to.
*
* @var MultiForm subclass
*/
protected $form;
/**
* Form fields to be rendered with this step.
* (Form object is created in {@link MultiForm}.
@ -84,7 +84,7 @@ class MultiFormStep extends DataObject {
public function getFields() {
user_error('Please implement getFields on your MultiFormStep subclass', E_USER_ERROR);
}
/**
* Additional form actions to be added to this step.
* (Form object is created in {@link MultiForm}.
@ -97,26 +97,26 @@ class MultiFormStep extends DataObject {
public function getExtraActions() {
return (class_exists('FieldList')) ? new FieldList() : new FieldSet();
}
/**
* Get a validator specific to this form.
* The form is automatically validated in {@link Form->httpSubmission()}.
*
*
* @return Validator
*/
public function getValidator() {
return false;
}
/**
* Accessor method for $this->title
*
*
* @return string Title of this step
*/
public function getTitle() {
return $this->title ? $this->title : $this->class;
}
/**
* Gets a direct link to this step (only works
* if you're allowed to skip steps, or this step
@ -133,21 +133,21 @@ class MultiFormStep extends DataObject {
* Unserialize stored session data and return it.
* This is used for loading data previously saved
* in session back into the form.
*
*
* You need to overload this method onto your own
* step if you require custom loading. An example
* would be selective loading specific fields, leaving
* others that are not required.
*
*
* @return array
*/
public function loadData() {
return ($this->Data && is_string($this->Data)) ? unserialize($this->Data) : array();
}
/**
* Save the data for this step into session, serializing it first.
*
*
* To selectively save fields, instead of it all, this
* method would need to be overloaded on your step class.
*
@ -157,7 +157,7 @@ class MultiFormStep extends DataObject {
$this->Data = serialize($data);
$this->write();
}
/**
* Save the data on this step into an object,
* similiar to {@link Form->saveInto()} - by building
@ -180,7 +180,7 @@ class MultiFormStep extends DataObject {
$form->saveInto($obj);
return $obj;
}
/**
* Custom validation for a step. In most cases, it should be sufficient
* to have built-in validation through the {@link Validator} class
@ -197,10 +197,10 @@ class MultiFormStep extends DataObject {
public function validateStep($data, $form) {
return true;
}
/**
* Returns the first value of $next_step
*
*
* @return String Classname of a {@link MultiFormStep} subclass
*/
public function getNextStep() {
@ -210,7 +210,7 @@ class MultiFormStep extends DataObject {
if(!$this->isFinalStep()) {
if(!isset($nextSteps)) user_error('MultiFormStep->getNextStep(): Please define at least one $next_steps on ' . $this->class, E_USER_ERROR);
}
if(is_string($nextSteps)) {
return $nextSteps;
} elseif(is_array($nextSteps) && count($nextSteps)) {
@ -223,10 +223,10 @@ class MultiFormStep extends DataObject {
/**
* Returns the next step to the current step in the database.
*
*
* This will only return something if you've previously visited
* the step ahead of the current step, and then gone back a step.
*
*
* @return MultiFormStep|boolean
*/
public function getNextStepFromDatabase() {
@ -242,22 +242,22 @@ class MultiFormStep extends DataObject {
}
}
}
/**
* Accessor method for self::$next_steps
*
*
* @return string|array
*/
public function getNextSteps() {
return static::$next_steps;
}
/**
* Returns the previous step, if there is one.
*
*
* To determine if there is a previous step, we check the database to see if there's
* a previous step for this multi form session ID.
*
*
* @return String Classname of a {@link MultiFormStep} subclass
*/
public function getPreviousStep() {
@ -274,7 +274,7 @@ class MultiFormStep extends DataObject {
}
}
}
/**
* Retrieves the previous step class record from the database.
*
@ -320,26 +320,26 @@ class MultiFormStep extends DataObject {
public function setForm($form) {
$this->form = $form;
}
/**
* @return Form
*/
public function getForm() {
return $this->form;
}
// ##################### Utility ####################
/**
* Determines whether the user is able to go back using the "action_back"
* form action, based on the boolean value of $can_go_back.
*
*
* @return boolean
*/
public function canGoBack() {
return static::$can_go_back;
}
/**
* Determines whether this step is the final step in the multi-step process or not,
* based on the variable $is_final_step - which must be defined on at least one step.
@ -349,17 +349,17 @@ class MultiFormStep extends DataObject {
public function isFinalStep() {
return static::$is_final_step;
}
/**
* Determines whether the currently viewed step is the current step set in the session.
* This assumes you are checking isCurrentStep() against a data record of a MultiFormStep
* subclass, otherwise it doesn't work. An example of this is using a singleton instance - it won't
* work because there's no data.
*
*
* @return boolean
*/
public function isCurrentStep() {
return ($this->class == $this->Session()->CurrentStep()->class) ? true : false;
}
}

View File

@ -2,29 +2,29 @@
/**
* Task to clean out all {@link MultiFormSession} objects from the database.
*
*
* Setup Instructions:
* You need to create an automated task for your system (cronjobs on unix)
* which triggers the process() method through cli-script.php:
* `php framework/cli-script.php MultiFormPurgeTask`
* or
* `framework/sake MultiFormPurgeTask`
*
*
* @package multiform
*/
class MultiFormPurgeTask extends BuildTask {
/**
* Days after which sessions expire and
* are automatically deleted.
*
*
* @var int
*/
public static $session_expiry_days = 7;
/**
* Run this cron task.
*
*
* Go through all MultiFormSession records that
* are older than the days specified in $session_expiry_days
* and delete them.
@ -51,5 +51,5 @@ class MultiFormPurgeTask extends BuildTask {
"DATEDIFF(NOW(), \"MultiFormSession\".\"Created\") > " . self::$session_expiry_days
);
}
}

View File

@ -2,7 +2,7 @@
/**
* MultiFormTest
* For testing purposes, we have some test classes:
*
*
* - MultiFormTest_Controller (simulation of a real Controller class)
* - MultiFormTest_Form (subclass of MultiForm)
* - MultiFormTest_StepOne (subclass of MultiFormStep)
@ -13,54 +13,54 @@
* of the multiform module - for example, MultiFormTest_Controller
* is a simulation of a page where MultiFormTest_Form is a simple
* multi-step contact form it belongs to.
*
*
* @package multiform
* @subpackage tests
*/
class MultiFormTest extends FunctionalTest {
public static $fixture_file = 'multiform/tests/MultiFormTest.yml';
protected $controller;
function setUp() {
parent::setUp();
$this->controller = new MultiFormTest_Controller();
$this->form = $this->controller->Form();
}
function testInitialisingForm() {
$this->assertTrue(is_numeric($this->form->getCurrentStep()->ID) && ($this->form->getCurrentStep()->ID > 0));
$this->assertTrue(is_numeric($this->form->getSession()->ID) && ($this->form->getSession()->ID > 0));
$this->assertEquals('MultiFormTest_StepOne', $this->form->getStartStep());
}
function testSessionGeneration() {
$this->assertTrue($this->form->session->ID > 0);
}
function testMemberLogging() {
// Grab any user to fake being logged in as, and ensure that after a session is written it has
// that user as the submitter.
$userId = Member::get_one("Member")->ID;
$this->session()->inst_set('loggedInAs', $userId);
$session = $this->form->session;
$session->write();
$this->assertEquals($userId, $session->SubmitterID);
}
function testSecondStep() {
$this->assertEquals('MultiFormTest_StepTwo', $this->form->getCurrentStep()->getNextStep());
}
function testParentForm() {
$currentStep = $this->form->getCurrentStep();
$this->assertEquals($currentStep->getForm()->class, $this->form->class);
}
function testTotalStepCount() {
$this->assertEquals(3, $this->form->getAllStepsLinear()->Count());
}
@ -71,14 +71,14 @@ class MultiFormTest extends FunctionalTest {
$this->form->session->markCompleted();
$this->assertNull($this->form->getCurrentSession());
}
function testIncorrectSessionIdentifier() {
$this->form->setCurrentSessionHash('sdfsdf3432325325sfsdfdf'); // made up!
// A new session is generated, even though we made up the identifier
$this->assertInstanceOf('MultiFormSession', $this->form->session);
}
}
/**
@ -90,7 +90,7 @@ class MultiFormTest_Controller extends Controller implements TestOnly {
function Link() {
return 'MultiFormTest_Controller';
}
public function Form($request = null) {
$form = new MultiFormTest_Form($this, 'Form');
$form->setHTMLID('MultiFormTest_Form');
@ -105,7 +105,7 @@ class MultiFormTest_Controller extends Controller implements TestOnly {
class MultiFormTest_Form extends MultiForm implements TestOnly {
public static $start_step = 'MultiFormTest_StepOne';
function getStartStep() {
return self::$start_step;
}
@ -117,9 +117,9 @@ class MultiFormTest_Form extends MultiForm implements TestOnly {
* @subpackage tests
*/
class MultiFormTest_StepOne extends MultiFormStep implements TestOnly {
public static $next_steps = 'MultiFormTest_StepTwo';
function getFields() {
$class = (class_exists('FieldList')) ? 'FieldList' : 'FieldSet';
return new $class(
@ -135,9 +135,9 @@ class MultiFormTest_StepOne extends MultiFormStep implements TestOnly {
* @subpackage tests
*/
class MultiFormTest_StepTwo extends MultiFormStep implements TestOnly {
public static $next_steps = 'MultiFormTest_StepThree';
function getFields() {
$class = (class_exists('FieldList')) ? 'FieldList' : 'FieldSet';
return new $class(
@ -151,14 +151,14 @@ class MultiFormTest_StepTwo extends MultiFormStep implements TestOnly {
* @subpackage tests
*/
class MultiFormTest_StepThree extends MultiFormStep implements TestOnly {
public static $is_final_step = true;
function getFields() {
$class = (class_exists('FieldList')) ? 'FieldList' : 'FieldSet';
return new $class(
new TextField('Test', 'Anything else you\'d like to tell us?')
);
}
}