Browse Source

format

master
Ilya Sigunov 13 years ago
parent
commit
acb3b8bf27
  1. 131
      tests/form/FormFieldTest.php
  2. 133
      tests/form/FormTest.php
  3. 13
      tests/form/FormViewHelperTest.php

131
tests/form/FormFieldTest.php

@ -12,9 +12,7 @@
require_once dirname(__FILE__) . '/../../validator/iValidator.php'; require_once dirname(__FILE__) . '/../../validator/iValidator.php';
require_once dirname(__FILE__) . '/../../validator/Validator.php'; require_once dirname(__FILE__) . '/../../validator/Validator.php';
require_once dirname(__FILE__) . '/../../validator/NotEmptyValidator.php'; require_once dirname(__FILE__) . '/../../validator/NotEmptyValidator.php';
require_once dirname(__FILE__) . '/../../validator/RegexValidator.php';
require_once dirname(__FILE__) . '/../../validator/EmailValidator.php'; require_once dirname(__FILE__) . '/../../validator/EmailValidator.php';
require_once dirname(__FILE__) . '/../../form/Form.php';
require_once dirname(__FILE__) . '/../../form/FormField.php'; require_once dirname(__FILE__) . '/../../form/FormField.php';
@ -22,8 +20,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
{ {
public function setUp() public function setUp()
{ {
$this->ff = new TestFormForFormField;
$this->obj_fields = $this->ff->getProp('fields');
/**/
} }
public function testSetRequired() public function testSetRequired()
@ -70,16 +67,11 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
'NotEmpty' => new NotEmptyValidator(), 'NotEmpty' => new NotEmptyValidator(),
'Email' => new EmailValidator() 'Email' => new EmailValidator()
); );
$this->assertInstanceOf('iValidator', $validator['NotEmpty']); $this->assertInstanceOf('iValidator', $validator['NotEmpty']);
$this->assertInstanceOf('iValidator', $validator['Email']); $this->assertInstanceOf('iValidator', $validator['Email']);
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$return_object = $tmp_form_field->addValidators($validator); $return_object = $tmp_form_field->addValidators($validator);
$array = array('NotEmptyValidator'=>new NotEmptyValidator,'EmailValidator'=>new EmailValidator); $array = array('NotEmptyValidator'=>new NotEmptyValidator,'EmailValidator'=>new EmailValidator);
$this->assertAttributeEquals($array, 'validators', $tmp_form_field); $this->assertAttributeEquals($array, 'validators', $tmp_form_field);
$this->assertSame($tmp_form_field, $return_object); $this->assertSame($tmp_form_field, $return_object);
} }
@ -88,27 +80,19 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
{ {
$validator = new NotEmptyValidator; $validator = new NotEmptyValidator;
$array = array('NotEmptyValidator'=>new NotEmptyValidator); $array = array('NotEmptyValidator'=>new NotEmptyValidator);
$this->assertInstanceOf('iValidator', new NotEmptyValidator); $this->assertInstanceOf('iValidator', new NotEmptyValidator);
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$return_object = $tmp_form_field->addValidator($validator); $return_object = $tmp_form_field->addValidator($validator);
$this->assertAttributeEquals($array, 'validators', $tmp_form_field); $this->assertAttributeEquals($array, 'validators', $tmp_form_field);
$this->assertSame($tmp_form_field, $return_object); $this->assertSame($tmp_form_field, $return_object);
} }
public function testAddValidatorString() public function testAddValidatorString()
{ {
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$return_object = $tmp_form_field->addValidator('NotEmpty'); $return_object = $tmp_form_field->addValidator('NotEmpty');
$this->assertInstanceOf('iValidator', new NotEmptyValidator); $this->assertInstanceOf('iValidator', new NotEmptyValidator);
$array = array('NotEmptyValidator'=>new NotEmptyValidator); $array = array('NotEmptyValidator'=>new NotEmptyValidator);
$this->assertAttributeEquals($array, 'validators', $tmp_form_field); $this->assertAttributeEquals($array, 'validators', $tmp_form_field);
$this->assertSame($tmp_form_field, $return_object); $this->assertSame($tmp_form_field, $return_object);
} }
@ -116,11 +100,8 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
public function testAddValidatorElse() public function testAddValidatorElse()
{ {
$validator = true; $validator = true;
$this->setExpectedException('Exception'); $this->setExpectedException('Exception');
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$tmp_form_field->addValidator($validator); $tmp_form_field->addValidator($validator);
} }
@ -128,43 +109,31 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
public function testAddFilters() public function testAddFilters()
{ {
$array = array('loginFilter' => new loginFilter(),'passwordFilter' => new passwordFilter()); $array = array('loginFilter' => new loginFilter(),'passwordFilter' => new passwordFilter());
$this->assertInstanceOf('iFilter', $array['loginFilter']); $this->assertInstanceOf('iFilter', $array['loginFilter']);
$this->assertInstanceOf('iFilter', $array['passwordFilter']); $this->assertInstanceOf('iFilter', $array['passwordFilter']);
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$return_object = $tmp_form_field->addFilters($array); $return_object = $tmp_form_field->addFilters($array);
$this->assertAttributeEquals($array, 'filters', $tmp_form_field); $this->assertAttributeEquals($array, 'filters', $tmp_form_field);
$this->assertSame($tmp_form_field, $return_object); $this->assertSame($tmp_form_field, $return_object);
} }
public function testAddFilterObject() public function testAddFilterObject()
{ {
$filter = new loginFilter;
$filter = new loginFilter;
$array = array('loginFilter' => new loginFilter()); $array = array('loginFilter' => new loginFilter());
$this->assertInstanceOf('iFilter', new loginFilter); $this->assertInstanceOf('iFilter', new loginFilter);
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$return_object = $tmp_form_field->addFilter($filter); $return_object = $tmp_form_field->addFilter($filter);
$this->assertAttributeEquals($array, 'filters', $tmp_form_field); $this->assertAttributeEquals($array, 'filters', $tmp_form_field);
$this->assertSame($tmp_form_field, $return_object); $this->assertSame($tmp_form_field, $return_object);
} }
public function testAddFilterString() public function testAddFilterString()
{ {
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$array = array('loginFilter' => new loginFilter()); $array = array('loginFilter' => new loginFilter());
$this->assertInstanceOf('iFilter', new loginFilter); $this->assertInstanceOf('iFilter', new loginFilter);
$return_object = $tmp_form_field->addFilter('login'); $return_object = $tmp_form_field->addFilter('login');
$this->assertAttributeEquals($array, 'filters', $tmp_form_field); $this->assertAttributeEquals($array, 'filters', $tmp_form_field);
$this->assertSame($tmp_form_field, $return_object); $this->assertSame($tmp_form_field, $return_object);
} }
@ -172,30 +141,22 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
public function testAddFilterElse() public function testAddFilterElse()
{ {
$this->setExpectedException('Exception'); $this->setExpectedException('Exception');
$filter = new NotEmptyValidator; $filter = new NotEmptyValidator;
$tmp_form_field = new TmpFormField;
$tmp_form_field = new FormField;
$tmp_form_field->addFilter($filter); $tmp_form_field->addFilter($filter);
} }
public function testGetValueArray() public function testGetValueArray()
{ {
$form = new TestFormForFormField();
$form = new FormField();
$test_array = array( $test_array = array(
'login'=> 'login', 'login'=> 'login',
'password'=> 'password' 'password'=> 'password'
); );
$this->assertSame(1, $form->isValid($test_array));
$tmp_form_field = new TmpFormField;
$this->assertTrue($form->isValid($test_array));
$tmp_form_field = new FormField;
$this->assertTrue($tmp_form_field->isValid($test_array)); $this->assertTrue($tmp_form_field->isValid($test_array));
$this->assertAttributeInternalType('array', 'value', $tmp_form_field); $this->assertAttributeInternalType('array', 'value', $tmp_form_field);
$this->assertArrayHasKey('login', $tmp_form_field->getSourceValue()); $this->assertArrayHasKey('login', $tmp_form_field->getSourceValue());
} }
@ -206,12 +167,9 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
'login'=> 'login', 'login'=> 'login',
'password'=> 'password' 'password'=> 'password'
); );
$test_form_field = new FormField(); $test_form_field = new FormField();
$this->assertTrue($test_form_field->isValid($test_array['login'])); $this->assertTrue($test_form_field->isValid($test_array['login']));
$this->assertAttributeNotInternalType('array', 'value', $test_form_field); $this->assertAttributeNotInternalType('array', 'value', $test_form_field);
$this->assertEquals('login',$test_form_field->getSourceValue()); $this->assertEquals('login',$test_form_field->getSourceValue());
} }
@ -221,19 +179,15 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
$this->assertNotNull($test_form_field->getMessage()); $this->assertNotNull($test_form_field->getMessage());
} }
public function testIsValidMissing1()
public function testIsValidMissingException()
{ {
$test_array = array( $test_array = array(
'login'=> '', 'login'=> '',
'password'=> '' 'password'=> ''
); );
$test_form_field = new FormField(); $test_form_field = new FormField();
$test_form_field->addValidator('NotEmpty'); $test_form_field->addValidator('NotEmpty');
$this->setExpectedException('Exception','Define default message for array fields'); $this->setExpectedException('Exception','Define default message for array fields');
$this->assertTrue($test_form_field->isValid($test_array)); $this->assertTrue($test_form_field->isValid($test_array));
} }
@ -243,37 +197,32 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
'login'=> '', 'login'=> '',
'password'=> '' 'password'=> ''
); );
$test_form_field = new FormField('ssssssss'); $test_form_field = new FormField('ssssssss');
$return_object = $test_form_field->addValidator('NotEmpty'); $return_object = $test_form_field->addValidator('NotEmpty');
$this->assertInstanceOf('iValidator', new NotEmptyValidator); $this->assertInstanceOf('iValidator', new NotEmptyValidator);
$array = array('NotEmptyValidator'=>new NotEmptyValidator); $array = array('NotEmptyValidator'=>new NotEmptyValidator);
$this->assertAttributeEquals($array, 'validators', $test_form_field); $this->assertAttributeEquals($array, 'validators', $test_form_field);
$this->assertSame($test_form_field, $return_object); $this->assertSame($test_form_field, $return_object);
$this->assertFalse($test_form_field->isValid($test_array)); $this->assertFalse($test_form_field->isValid($test_array));
} }
public function testIsValidMissing2()
public function testIsValidMissingRequired()
{ {
$form_field = new FormField; $form_field = new FormField;
$form_field->setRequired(false); $form_field->setRequired(false);
$this->assertTrue($form_field->isValid('')); $this->assertTrue($form_field->isValid(''));
} }
public function testIsValidMissing3()
public function testIsValidMissingValid()
{ {
$test_array = array(
'login'=> 'login',
'password'=> 'password'
);
$validator = new NotEmptyValidator();
$form_field = new FormField; $form_field = new FormField;
$form_field->setRequired(false);
$form_field->isValid('');
$this->assertFalse($form_field->isRequired());
$return_object = $form_field->addValidator($validator);
$this->assertTrue($form_field->isValid($test_array));
} }
public function testFilterValue() public function testFilterValue()
@ -281,45 +230,11 @@ class FormFieldTest extends PHPUnit_Framework_TestCase
$form_field = new FormField; $form_field = new FormField;
$form_field->isValid('login'); $form_field->isValid('login');
$form_field->addFilter('login'); $form_field->addFilter('login');
$lf = new loginFilter; $lf = new loginFilter;
$this->assertSame($form_field->getValue(), $lf->filter('login')); $this->assertSame($form_field->getValue(), $lf->filter('login'));
} }
} }
class TmpFormField extends FormField
{
public function getProp($name)
{
return $this->$name;
}
}
class TestFormForFormField extends Form
{
public function init()
{
///*
$validator = new NotEmptyValidator();
$validator->setMessage('Enter login name.');
$this->addField('login')->addValidator($validator);
// User password
$validator = new NotEmptyValidator();
$validator->setMessage('Enter your password.');
$this->addField('password')->addValidator($validator);
}
public function getProp($name)
{
return $this->$name;
}
}
interface iFilter interface iFilter
{ {
public function isValid($value, $context = null); public function isValid($value, $context = null);

133
tests/form/FormTest.php

@ -7,53 +7,48 @@
require_once dirname(__FILE__) . '/../../form/Form.php'; require_once dirname(__FILE__) . '/../../form/Form.php';
require_once dirname(__FILE__) . '/../../form/FormField.php'; require_once dirname(__FILE__) . '/../../form/FormField.php';
require_once dirname(__FILE__) . '/../../session/Session.php';
require_once dirname(__FILE__) . '/../../validator/iValidator.php';
require_once dirname(__FILE__) . '/../../validator/Validator.php';
require_once dirname(__FILE__) . '/../../validator/RegexValidator.php';
require_once dirname(__FILE__) . '/../../validator/NotEmptyValidator.php';
require_once dirname(__FILE__) . '/../../validator/EmailValidator.php';
class FormTest extends PHPUnit_Framework_TestCase class FormTest extends PHPUnit_Framework_TestCase
{ {
public function testIsValidWithNotArray() public function testIsValidWithNotArray()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$this->setExpectedException('Exception'); $this->setExpectedException('Exception');
$form->isValid(''); $form->isValid('');
} }
public function testIsValidCorrectFields() public function testIsValidCorrectFields()
{ {
$form = new NotEmptyForm();
$test_array = array(
$form = new NotEmptyForm();
$test_array = array(
'login'=> 'login', 'login'=> 'login',
'password'=> 'password' 'password'=> 'password'
);
$this->assertSame(1, $form->isValid($test_array));
);
$this->assertSame(1, $form->isValid($test_array));
} }
public function testIsValidMissingField() public function testIsValidMissingField()
{ {
$form = new NotEmptyForm();
$test_array = array(
$form = new NotEmptyForm();
$test_array = array(
'password'=> 'password' 'password'=> 'password'
);
$this->assertSame(0, $form->isValid($test_array));
);
$this->assertSame(0, $form->isValid($test_array));
} }
public function testGetValues() public function testGetValues()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> 'login', 'login'=> 'login',
'password'=>'password' 'password'=>'password'
); );
$this->assertSame(1, $form->isValid($fields)); $this->assertSame(1, $form->isValid($fields));
$this->assertEquals($fields, $form->getValues()); $this->assertEquals($fields, $form->getValues());
} }
@ -61,14 +56,11 @@ class FormTest extends PHPUnit_Framework_TestCase
public function testGetValueCorrect() public function testGetValueCorrect()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> 'login', 'login'=> 'login',
'password'=>'password' 'password'=>'password'
); );
$this->assertSame(1, $form->isValid($fields)); $this->assertSame(1, $form->isValid($fields));
$this->assertEquals($fields['login'], $form->getValue('login')); $this->assertEquals($fields['login'], $form->getValue('login'));
$this->assertEquals($fields['password'], $form->getValue('password')); $this->assertEquals($fields['password'], $form->getValue('password'));
} }
@ -77,13 +69,10 @@ class FormTest extends PHPUnit_Framework_TestCase
public function testGetValueMissing() public function testGetValueMissing()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> '' 'login'=> ''
); );
$this->assertSame(0, $form->isValid($fields)); $this->assertSame(0, $form->isValid($fields));
$this->assertEquals('', $form->getValue('login')); $this->assertEquals('', $form->getValue('login'));
$this->assertEquals('', $form->getValue('password')); $this->assertEquals('', $form->getValue('password'));
} }
@ -92,15 +81,11 @@ class FormTest extends PHPUnit_Framework_TestCase
public function testGetValueMissingFieldLogin() public function testGetValueMissingFieldLogin()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> '' 'login'=> ''
); );
$this->assertSame(0, $form->isValid($fields)); $this->assertSame(0, $form->isValid($fields));
$this->assertFalse($form->getValue('loginw')); $this->assertFalse($form->getValue('loginw'));
$this->assertEquals('', $form->getValue('passwordw')); $this->assertEquals('', $form->getValue('passwordw'));
} }
@ -108,47 +93,35 @@ class FormTest extends PHPUnit_Framework_TestCase
public function testGetValueMissingFieldPassword() public function testGetValueMissingFieldPassword()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> '' 'login'=> ''
); );
$this->assertSame(0, $form->isValid($fields)); $this->assertSame(0, $form->isValid($fields));
$this->assertFalse($form->getValue('loginw')); $this->assertFalse($form->getValue('loginw'));
$this->assertEquals('', $form->getValue('password')); $this->assertEquals('', $form->getValue('password'));
} }
public function testGetMessageTypeCorrect() public function testGetMessageTypeCorrect()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> 'login', 'login'=> 'login',
'password'=>'password' 'password'=>'password'
); );
$this->assertEquals(1, $form->isValid($fields)); $this->assertEquals(1, $form->isValid($fields));
$this->assertEquals('success', Form::SUCCESS); $this->assertEquals('success', Form::SUCCESS);
$this->assertEquals($form->getMessageType(), Form::SUCCESS); $this->assertEquals($form->getMessageType(), Form::SUCCESS);
} }
public function testGetMessageTypeMissing() public function testGetMessageTypeMissing()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> '', 'login'=> '',
'password'=>'' 'password'=>''
); );
$this->assertSame(0, $form->isValid($fields)); $this->assertSame(0, $form->isValid($fields));
$this->assertEquals('error', Form::ERROR); $this->assertEquals('error', Form::ERROR);
$this->assertEquals($form->getMessageType(), Form::ERROR); $this->assertEquals($form->getMessageType(), Form::ERROR);
} }
@ -156,16 +129,12 @@ class FormTest extends PHPUnit_Framework_TestCase
public function testGetMessageCorrect() public function testGetMessageCorrect()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> 'login', 'login'=> 'login',
'password'=>'password' 'password'=>'password'
); );
$this->assertSame(1, $form->isValid($fields)); $this->assertSame(1, $form->isValid($fields));
$form->setSuccessMessage('message'); $form->setSuccessMessage('message');
$this->assertEquals('message', $form->getMessage()); $this->assertEquals('message', $form->getMessage());
} }
@ -173,15 +142,11 @@ class FormTest extends PHPUnit_Framework_TestCase
public function testGetMessageMissing() public function testGetMessageMissing()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> '' 'login'=> ''
); );
$this->assertSame(0, $form->isValid($fields)); $this->assertSame(0, $form->isValid($fields));
$form->setErrorMessage('message'); $form->setErrorMessage('message');
$this->assertEquals('message', $form->getMessage()); $this->assertEquals('message', $form->getMessage());
} }
@ -189,87 +154,47 @@ class FormTest extends PHPUnit_Framework_TestCase
public function testSetSuccessMessage() public function testSetSuccessMessage()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> 'login', 'login'=> 'login',
'password'=>'password' 'password'=>'password'
); );
$this->assertSame(1, $form->isValid($fields)); $this->assertSame(1, $form->isValid($fields));
$message = 'Form data valid'; $message = 'Form data valid';
$form->setSuccessMessage($message); $form->setSuccessMessage($message);
$this->assertNotNull($form->getMessage()); $this->assertNotNull($form->getMessage());
} }
public function testSetErrorMessage() public function testSetErrorMessage()
{ {
$form = new NotEmptyForm(); $form = new NotEmptyForm();
$fields = array( $fields = array(
'login'=> '' 'login'=> ''
); );
$this->assertSame(0, $form->isValid($fields)); $this->assertSame(0, $form->isValid($fields));
$message = 'Form data invalid'; $message = 'Form data invalid';
$form->setErrorMessage($message); $form->setErrorMessage($message);
$this->assertNotNull($form->getMessage()); $this->assertNotNull($form->getMessage());
} }
} }
require_once dirname(__FILE__) . '/../../validator/iValidator.php';
require_once dirname(__FILE__) . '/../../validator/Validator.php';
require_once dirname(__FILE__) . '/../../validator/NotEmptyValidator.php';
class NotEmptyForm extends Form class NotEmptyForm extends Form
{ {
public function init()
{
///*
$validator = new NotEmptyValidator();
$validator->setMessage('Enter login name.');
$this->addField('login')->addValidator($validator);
// User password
$validator = new NotEmptyValidator();
$validator->setMessage('Enter your password.');
$this->addField('password')->addValidator($validator);
}
public function getProp($name)
{
return $this->$name;
}
}
require_once dirname(__FILE__) . '/../../validator/RegexValidator.php';
require_once dirname(__FILE__) . '/../../validator/EmailValidator.php';
class DiffForm extends Form
{
public function init()
{
///*
$validator = new EmailValidator();
$validator->setMessage('Enter login name.');
$this->addField('login')->addValidator($validator);
// User password
$validator = new NotEmptyValidator();
$validator->setMessage('Enter your password.');
$this->addField('password')->addValidator($validator);
}
public function getProp($name)
{
return $this->$name;
}
public function init()
{
///*
$validator = new NotEmptyValidator();
$validator->setMessage('Enter login name.');
$this->addField('login')->addValidator($validator);
// User password
$validator = new NotEmptyValidator();
$validator->setMessage('Enter your password.');
$this->addField('password')->addValidator($validator);
}
public function getProp($name)
{
return $this->$name;
}
} }

13
tests/form/FormViewHelperTest.php

@ -9,9 +9,6 @@
* @filesource $URL$ * @filesource $URL$
*/ */
require_once dirname(__FILE__) . '/../../form/Form.php';
require_once dirname(__FILE__) . '/../../form/FormField.php';
require_once dirname(__FILE__) . '/../../view/iView.php'; require_once dirname(__FILE__) . '/../../view/iView.php';
require_once dirname(__FILE__) . '/../../view/PHPView.php'; require_once dirname(__FILE__) . '/../../view/PHPView.php';
require_once dirname(__FILE__) . '/../../view/helpers/ViewHelper.php'; require_once dirname(__FILE__) . '/../../view/helpers/ViewHelper.php';
@ -23,11 +20,8 @@ class FormViewHelperTest extends PHPUnit_Framework_TestCase
public function setUp() public function setUp()
{ {
Session::start(); Session::start();
$phpview = new PHPView(array('path' => 'document_root')); $phpview = new PHPView(array('path' => 'document_root'));
$this->form = new FormViewHelper($phpview); $this->form = new FormViewHelper($phpview);
$_SESSION['path'] = array( $_SESSION['path'] = array(
'values'=>array( 'values'=>array(
'path'=>'path' 'path'=>'path'
@ -41,44 +35,37 @@ class FormViewHelperTest extends PHPUnit_Framework_TestCase
public function testForm2() public function testForm2()
{ {
$this->assertNull($this->assertAttributeEquals(null,'data',$this->form)); $this->assertNull($this->assertAttributeEquals(null,'data',$this->form));
$this->setExpectedException('Exception'); $this->setExpectedException('Exception');
$this->form->form(null); $this->form->form(null);
} }
public function testForm1() public function testForm1()
{ {
$this->assertNull($this->assertAttributeEquals(null,'data',$this->form)); //аналог getProp $this->assertNull($this->assertAttributeEquals(null,'data',$this->form)); //аналог getProp
$this->form->form('path'); $this->form->form('path');
} }
public function testValueIsset() public function testValueIsset()
{ {
$this->form->form('path'); $this->form->form('path');
$this->assertEquals('path', $this->form->value('path')); $this->assertEquals('path', $this->form->value('path'));
} }
public function testValueNotIsset() public function testValueNotIsset()
{ {
$this->form->form('path'); $this->form->form('path');
$this->assertEquals('param2', $this->form->value('param1','param2')); $this->assertEquals('param2', $this->form->value('param1','param2'));
} }
public function testMessageIsset() public function testMessageIsset()
{ {
$this->form->form('path'); $this->form->form('path');
$this->assertNotEmpty($this->form->message('path')); $this->assertNotEmpty($this->form->message('path'));
} }
public function testMessageNotIsset() public function testMessageNotIsset()
{ {
$this->form->form('path'); $this->form->form('path');
$this->assertEmpty($this->form->message('')); $this->assertEmpty($this->form->message(''));
} }
} }
Loading…
Cancel
Save