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