From 8aa83f5124b79838c6d05544c5aeafb995d7048e Mon Sep 17 00:00:00 2001 From: Ilya Sigunov Date: Fri, 21 Oct 2011 11:45:37 +0400 Subject: [PATCH] format2 --- tests/form/FormFieldTest.php | 60 +++++++++++++++++++-------------------- tests/form/FormTest.php | 5 ---- tests/form/FormViewHelperTest.php | 10 +++---- 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/tests/form/FormFieldTest.php b/tests/form/FormFieldTest.php index 1df04c6..1327804 100644 --- a/tests/form/FormFieldTest.php +++ b/tests/form/FormFieldTest.php @@ -25,7 +25,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testSetRequired() { - $form_field = new FormField; + $form_field = new FormField(); $this->assertTrue($form_field->isRequired()); $return_object = $form_field->setRequired(false); $this->assertInstanceOf('FormField', $return_object); @@ -35,7 +35,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testSetIgnored() { - $form_field = new FormField; + $form_field = new FormField(); $this->assertFalse($form_field->isIgnored()); $return_object = $form_field->setIgnored(true); $this->assertInstanceOf('FormField', $return_object); @@ -46,7 +46,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testIsIgnored() { $class_name = 'FormField'; - $form_field = new $class_name; + $form_field = new $class_name(); $this->assertFalse($form_field->isIgnored()); $form_field->setIgnored(true); $this->assertTrue($form_field->isIgnored()); @@ -55,7 +55,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testIsRequired() { $class_name = 'FormField'; - $form_field = new $class_name; + $form_field = new $class_name(); $this->assertTrue($form_field->isRequired()); $form_field->setRequired(false); $this->assertFalse($form_field->isRequired()); @@ -69,19 +69,19 @@ class FormFieldTest extends PHPUnit_Framework_TestCase ); $this->assertInstanceOf('iValidator', $validator['NotEmpty']); $this->assertInstanceOf('iValidator', $validator['Email']); - $tmp_form_field = new FormField; + $tmp_form_field = new FormField(); $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->assertSame($tmp_form_field, $return_object); } public function testAddValidatorObject() { - $validator = new NotEmptyValidator; - $array = array('NotEmptyValidator'=>new NotEmptyValidator); - $this->assertInstanceOf('iValidator', new NotEmptyValidator); - $tmp_form_field = new FormField; + $validator = new NotEmptyValidator(); + $array = array('NotEmptyValidator'=>new NotEmptyValidator()); + $this->assertInstanceOf('iValidator', new NotEmptyValidator()); + $tmp_form_field = new FormField(); $return_object = $tmp_form_field->addValidator($validator); $this->assertAttributeEquals($array, 'validators', $tmp_form_field); $this->assertSame($tmp_form_field, $return_object); @@ -89,10 +89,10 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testAddValidatorString() { - $tmp_form_field = new FormField; + $tmp_form_field = new FormField(); $return_object = $tmp_form_field->addValidator('NotEmpty'); - $this->assertInstanceOf('iValidator', new NotEmptyValidator); - $array = array('NotEmptyValidator'=>new NotEmptyValidator); + $this->assertInstanceOf('iValidator', new NotEmptyValidator()); + $array = array('NotEmptyValidator'=>new NotEmptyValidator()); $this->assertAttributeEquals($array, 'validators', $tmp_form_field); $this->assertSame($tmp_form_field, $return_object); } @@ -101,7 +101,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase { $validator = true; $this->setExpectedException('Exception'); - $tmp_form_field = new FormField; + $tmp_form_field = new FormField(); $tmp_form_field->addValidator($validator); } @@ -111,7 +111,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase $array = array('loginFilter' => new loginFilter(),'passwordFilter' => new passwordFilter()); $this->assertInstanceOf('iFilter', $array['loginFilter']); $this->assertInstanceOf('iFilter', $array['passwordFilter']); - $tmp_form_field = new FormField; + $tmp_form_field = new FormField(); $return_object = $tmp_form_field->addFilters($array); $this->assertAttributeEquals($array, 'filters', $tmp_form_field); $this->assertSame($tmp_form_field, $return_object); @@ -119,10 +119,10 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testAddFilterObject() { - $filter = new loginFilter; + $filter = new loginFilter(); $array = array('loginFilter' => new loginFilter()); - $this->assertInstanceOf('iFilter', new loginFilter); - $tmp_form_field = new FormField; + $this->assertInstanceOf('iFilter', new loginFilter()); + $tmp_form_field = new FormField(); $return_object = $tmp_form_field->addFilter($filter); $this->assertAttributeEquals($array, 'filters', $tmp_form_field); $this->assertSame($tmp_form_field, $return_object); @@ -130,9 +130,9 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testAddFilterString() { - $tmp_form_field = new FormField; + $tmp_form_field = new FormField(); $array = array('loginFilter' => new loginFilter()); - $this->assertInstanceOf('iFilter', new loginFilter); + $this->assertInstanceOf('iFilter', new loginFilter()); $return_object = $tmp_form_field->addFilter('login'); $this->assertAttributeEquals($array, 'filters', $tmp_form_field); $this->assertSame($tmp_form_field, $return_object); @@ -141,8 +141,8 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testAddFilterElse() { $this->setExpectedException('Exception'); - $filter = new NotEmptyValidator; - $tmp_form_field = new FormField; + $filter = new NotEmptyValidator(); + $tmp_form_field = new FormField(); $tmp_form_field->addFilter($filter); } @@ -155,7 +155,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase 'password'=> 'password' ); $this->assertTrue($form->isValid($test_array)); - $tmp_form_field = new FormField; + $tmp_form_field = new FormField(); $this->assertTrue($tmp_form_field->isValid($test_array)); $this->assertAttributeInternalType('array', 'value', $tmp_form_field); $this->assertArrayHasKey('login', $tmp_form_field->getSourceValue()); @@ -170,7 +170,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase $test_form_field = new FormField(); $this->assertTrue($test_form_field->isValid($test_array['login'])); $this->assertAttributeNotInternalType('array', 'value', $test_form_field); - $this->assertEquals('login',$test_form_field->getSourceValue()); + $this->assertEquals('login', $test_form_field->getSourceValue()); } public function testGetMessage() @@ -199,8 +199,8 @@ class FormFieldTest extends PHPUnit_Framework_TestCase ); $test_form_field = new FormField('ssssssss'); $return_object = $test_form_field->addValidator('NotEmpty'); - $this->assertInstanceOf('iValidator', new NotEmptyValidator); - $array = array('NotEmptyValidator'=>new NotEmptyValidator); + $this->assertInstanceOf('iValidator', new NotEmptyValidator()); + $array = array('NotEmptyValidator'=>new NotEmptyValidator()); $this->assertAttributeEquals($array, 'validators', $test_form_field); $this->assertSame($test_form_field, $return_object); $this->assertFalse($test_form_field->isValid($test_array)); @@ -208,7 +208,7 @@ class FormFieldTest extends PHPUnit_Framework_TestCase public function testIsValidMissingRequired() { - $form_field = new FormField; + $form_field = new FormField(); $form_field->setRequired(false); $this->assertTrue($form_field->isValid('')); } @@ -220,17 +220,17 @@ class FormFieldTest extends PHPUnit_Framework_TestCase 'password'=> 'password' ); $validator = new NotEmptyValidator(); - $form_field = new FormField; + $form_field = new FormField(); $return_object = $form_field->addValidator($validator); $this->assertTrue($form_field->isValid($test_array)); } public function testFilterValue() { - $form_field = new FormField; + $form_field = new FormField(); $form_field->isValid('login'); $form_field->addFilter('login'); - $lf = new loginFilter; + $lf = new loginFilter(); $this->assertSame($form_field->getValue(), $lf->filter('login')); } } diff --git a/tests/form/FormTest.php b/tests/form/FormTest.php index 3527edf..33e3876 100644 --- a/tests/form/FormTest.php +++ b/tests/form/FormTest.php @@ -192,9 +192,4 @@ class NotEmptyForm extends Form $validator->setMessage('Enter your password.'); $this->addField('password')->addValidator($validator); } - - public function getProp($name) - { - return $this->$name; - } } \ No newline at end of file diff --git a/tests/form/FormViewHelperTest.php b/tests/form/FormViewHelperTest.php index 508b7f4..980f569 100644 --- a/tests/form/FormViewHelperTest.php +++ b/tests/form/FormViewHelperTest.php @@ -34,33 +34,33 @@ class FormViewHelperTest extends PHPUnit_Framework_TestCase public function testForm2() { - $this->assertNull($this->assertAttributeEquals(null,'data',$this->form)); + $this->assertNull($this->assertAttributeEquals(null, 'data', $this->form)); $this->setExpectedException('Exception'); $this->form->form(null); } 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'); } public function testValueIsset() { $this->form->form('path'); - $this->assertEquals('path', $this->form->value('path')); + $this->assertEquals(htmlentities('path', ENT_QUOTES, 'UTF-8'), $this->form->value('path')); } public function testValueNotIsset() { $this->form->form('path'); - $this->assertEquals('param2', $this->form->value('param1','param2')); + $this->assertEquals(htmlentities('param2', ENT_QUOTES, 'UTF-8'), $this->form->value('param1','param2')); } public function testMessageIsset() { $this->form->form('path'); - $this->assertNotEmpty($this->form->message('path')); + $this->assertEquals('' . htmlentities('path', ENT_QUOTES, 'UTF-8') . '', $this->form->message('path')); } public function testMessageNotIsset()