| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 7 | |||
| 8 | /** |
||
| 9 | * KnockoutConfirmedPasswordFieldTest |
||
| 10 | */ |
||
| 11 | class KnockoutConfirmedPasswordFieldTest extends SapphireTest |
||
| 12 | { |
||
| 13 | public function testKnockoutConfirmedPasswordField() |
||
| 14 | { |
||
| 15 | $field = KnockoutConfirmedPasswordField::create("MyField", "My Field"); |
||
| 16 | $fields = $field->children; |
||
| 17 | $password_field = $fields->fieldByName('MyField[_Password]'); |
||
| 18 | $password_confirmed_field = $fields->fieldByName('MyField[_ConfirmPassword]'); |
||
| 19 | |||
| 20 | $this->assertNotNull( |
||
| 21 | $password_field, |
||
| 22 | "password field is not null" |
||
| 23 | ); |
||
| 24 | $this->assertNotNull( |
||
| 25 | $password_confirmed_field, |
||
| 26 | "password confirmed field is not null" |
||
| 27 | ); |
||
| 28 | $this->assertEquals( |
||
| 29 | "password", |
||
| 30 | $password_field->getObservable(), |
||
| 31 | "observable is set to password by default in the Password field" |
||
| 32 | ); |
||
| 33 | $this->assertEquals( |
||
| 34 | "confirmedPassword", |
||
| 35 | $password_confirmed_field->getObservable(), |
||
| 36 | "observable is set to confirmedPassword by default in the Confirmed Password field" |
||
| 37 | ); |
||
| 38 | $this->assertEquals( |
||
| 39 | ['password', 'confirmedPassword'], |
||
| 40 | $field->getObservables(), |
||
| 41 | "The function getObservables returns an array of the observables set on the child fields" |
||
| 42 | ); |
||
| 43 | |||
| 44 | |||
| 45 | $field2 = KnockoutConfirmedPasswordField::create("MyField2", "My Field2") |
||
| 46 | ->setObservables(['password2', 'confirmedPassword2']); |
||
| 47 | $fields2 = $field2->children; |
||
| 48 | |||
| 49 | $password_field2 = $fields2->fieldByName('MyField2[_Password]'); |
||
| 50 | $password_confirmed_field2 = $fields2->fieldByName('MyField2[_ConfirmPassword]'); |
||
| 51 | |||
| 52 | $this->assertEquals( |
||
| 53 | "password2", |
||
| 54 | $password_field2->getObservable(), |
||
| 55 | "observable is set to password2 through the setObservables method" |
||
| 56 | ); |
||
| 57 | $this->assertEquals( |
||
| 58 | "confirmedPassword2", |
||
| 59 | $password_confirmed_field2->getObservable(), |
||
| 60 | "observable is set to confirmedPassword2 through the setObservables method" |
||
| 61 | ); |
||
| 62 | $this->assertEquals( |
||
| 69 |