| Conditions | 1 |
| Paths | 1 |
| Total Lines | 80 |
| Code Lines | 63 |
| 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 |
||
| 28 | public function testKnockoutForm() |
||
| 29 | { |
||
| 30 | $page = $this->get('KnockoutFormTest_Controller'); |
||
| 31 | $this->assertEquals(200, $page->getStatusCode(), "a page should load"); |
||
| 32 | $body = $page->getBody(); |
||
| 33 | |||
| 34 | $this->assertContains( |
||
| 35 | 'data-bind="submit: addToCart2"', |
||
| 36 | $body, |
||
| 37 | 'form element has submit binding to javascript function' |
||
| 38 | ); |
||
| 39 | $this->assertContains( |
||
| 40 | '<input data-bind="textInput: spaceship2, hasFocus: true"', |
||
| 41 | $body, |
||
| 42 | 'Databind attribute in input element' |
||
| 43 | ); |
||
| 44 | $this->assertContains( |
||
| 45 | "setKnockout:{value:'Enterprise\'s Voyage'}", |
||
| 46 | $body, |
||
| 47 | 'Comma escaped in HTML for javascript' |
||
| 48 | ); |
||
| 49 | $this->assertContains( |
||
| 50 | '<select data-bind="value: menu"', |
||
| 51 | $body, |
||
| 52 | 'Databind attribute applied to select element' |
||
| 53 | ); |
||
| 54 | $this->assertContains( |
||
| 55 | '<input data-bind="textInput: seatNumber, setKnockout:{value:4}"', |
||
| 56 | $body, |
||
| 57 | 'KnockoutNumericField works' |
||
| 58 | ); |
||
| 59 | $this->assertContains( |
||
| 60 | '<input data-bind="enable: canSaveInterGalacticAction, css:{ \'FormAction_Disabled\': !canSaveInterGalacticAction() }" type="submit"', |
||
| 61 | $body, |
||
| 62 | 'Databind attribute in submit button' |
||
| 63 | ); |
||
| 64 | $this->assertContains( |
||
| 65 | '<input data-bind="textInput: email, setKnockout:{value:\'[email protected]\'}"', |
||
| 66 | $body, |
||
| 67 | 'Databind attribute applied to input element for email field' |
||
| 68 | ); |
||
| 69 | $this->assertContains( |
||
| 70 | 'class="email text"', |
||
| 71 | $body, |
||
| 72 | 'KnockoutEmailField has a class of "email text"' |
||
| 73 | ); |
||
| 74 | $this->assertContains( |
||
| 75 | '<textarea data-bind="textInput: comments"', |
||
| 76 | $body, |
||
| 77 | 'Databind attribute applied to the textareafield' |
||
| 78 | ); |
||
| 79 | $this->assertContains( |
||
| 80 | 'class="knockouttextarea textarea"', |
||
| 81 | $body, |
||
| 82 | 'KnockoutTextareaField has a class of "textarea text"' |
||
| 83 | ); |
||
| 84 | $this->assertContains( |
||
| 85 | 'data-bind="checked: accessories, setKnockout:{value:\'Zero Gravity Pillow\'}, blah: someOtherFunction"', |
||
| 86 | $body, |
||
| 87 | 'Databind attribute applied to the radio buttons' |
||
| 88 | ); |
||
| 89 | $this->assertContains( |
||
| 90 | 'class="radio"', |
||
| 91 | $body, |
||
| 92 | 'KnockoutOptionsetField has a class of "radio"' |
||
| 93 | ); |
||
| 94 | $this->assertContains( |
||
| 95 | 'data-bind="enable: canSaveInterGalacticAction', |
||
| 96 | $body, |
||
| 97 | 'KnockoutFormAction has an obserable of "canSaveInterGalacticAction"' |
||
| 98 | ); |
||
| 99 | $this->assertContains( |
||
| 100 | 'data-bind="textInput: password', |
||
| 101 | $body, |
||
| 102 | 'KnockoutConfirmedPasswordField has a child with an obserable of "password"' |
||
| 103 | ); |
||
| 104 | $this->assertContains( |
||
| 105 | 'data-bind="textInput: confirmedPassword', |
||
| 106 | $body, |
||
| 107 | 'KnockoutConfirmedPasswordField has a child with an obserable of "confirmedPassword"' |
||
| 108 | ); |
||
| 112 |