-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14218 from SidRoberts/fixes-14217
Form::clear() now correctly clears single fields
- Loading branch information
Showing
3 changed files
with
168 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,16 +40,155 @@ public function _before(IntegrationTester $I) | |
} | ||
|
||
/** | ||
* Tests Phalcon\Forms\Form :: clear() | ||
* Tests Phalcon\Forms\Form :: clear() - all | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2018-11-13 | ||
* @author Sid Roberts <https://github.com/SidRoberts> | ||
* @since 2019-06-28 | ||
*/ | ||
public function formsFormClearAll(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Forms\Form - clear() - all'); | ||
|
||
$name = new Text('name'); | ||
$email = new Email('email'); | ||
$password = new Password('password'); | ||
|
||
$form = new Form(); | ||
|
||
$form | ||
->add($name) | ||
->add($email) | ||
->add($password) | ||
; | ||
|
||
$entity = new \stdClass(); | ||
|
||
$form->bind( | ||
[ | ||
'name' => 'Sid Roberts', | ||
'email' => '[email protected]', | ||
'password' => 'hunter2', | ||
], | ||
$entity | ||
); | ||
|
||
$form->clear(); | ||
|
||
$I->assertNull( | ||
$form->get('name')->getValue() | ||
); | ||
|
||
$I->assertNull( | ||
$form->get('email')->getValue() | ||
); | ||
|
||
$I->assertNull( | ||
$form->get('password')->getValue() | ||
); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Forms\Form :: clear() - fields array | ||
* | ||
* @author Sid Roberts <https://github.com/SidRoberts> | ||
* @since 2019-06-28 | ||
*/ | ||
public function formsFormClearFieldsArray(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Forms\Form - clear() - fields array'); | ||
|
||
$name = new Text('name'); | ||
$email = new Email('email'); | ||
$password = new Password('password'); | ||
|
||
$form = new Form(); | ||
|
||
$form | ||
->add($name) | ||
->add($email) | ||
->add($password) | ||
; | ||
|
||
$entity = new \stdClass(); | ||
|
||
$form->bind( | ||
[ | ||
'name' => 'Sid Roberts', | ||
'email' => '[email protected]', | ||
'password' => 'hunter2', | ||
], | ||
$entity | ||
); | ||
|
||
$form->clear( | ||
[ | ||
'email', | ||
'password', | ||
] | ||
); | ||
|
||
$I->assertEquals( | ||
'Sid Roberts', | ||
$form->get('name')->getValue() | ||
); | ||
|
||
$I->assertNull( | ||
$form->get('email')->getValue() | ||
); | ||
|
||
$I->assertNull( | ||
$form->get('password')->getValue() | ||
); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Forms\Form :: clear() - field string | ||
* | ||
* @author Sid Roberts <https://github.com/SidRoberts> | ||
* @since 2019-06-28 | ||
*/ | ||
public function formsFormClear(IntegrationTester $I) | ||
public function formsFormClearFieldString(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Forms\Form - clear()'); | ||
$I->wantToTest('Forms\Form - clear() - field string'); | ||
|
||
$name = new Text('name'); | ||
$email = new Email('email'); | ||
$password = new Password('password'); | ||
|
||
$I->skipTest('Need implementation'); | ||
$form = new Form(); | ||
|
||
$form | ||
->add($name) | ||
->add($email) | ||
->add($password) | ||
; | ||
|
||
$entity = new \stdClass(); | ||
|
||
$form->bind( | ||
[ | ||
'name' => 'Sid Roberts', | ||
'email' => '[email protected]', | ||
'password' => 'hunter2', | ||
], | ||
$entity | ||
); | ||
|
||
$form->clear('password'); | ||
|
||
$I->assertEquals( | ||
'Sid Roberts', | ||
$form->get('name')->getValue() | ||
); | ||
|
||
$I->assertEquals( | ||
'[email protected]', | ||
$form->get('email')->getValue() | ||
); | ||
|
||
$I->assertNull( | ||
$form->get('password')->getValue() | ||
); | ||
} | ||
|
||
/** | ||
|