Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 3 |
Lines | 0 |
Ratio | 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 |
||
71 | function testMemberProfileDisplays() { |
||
72 | /* Get the profile of a secretive member */ |
||
73 | $this->get('ForumMemberProfile/show/' . $this->idFromFixture('Member', 'test1')); |
||
74 | |||
75 | /* Check that it just contains the bare minimum |
||
76 | |||
77 | Commented out by wrossiter since this was breaking with custom themes. A test like this should not fail |
||
78 | because of a custom theme. Will reenable these tests when we tackle the new Member functionality |
||
79 | |||
80 | $this->assertExactMatchBySelector("div#UserProfile label", array( |
||
81 | "Nickname:", |
||
82 | "Number of posts:", |
||
83 | "Forum ranking:", |
||
84 | "Avatar:", |
||
85 | )); |
||
86 | $this->assertExactMatchBySelector("div#UserProfile p", array( |
||
87 | 'test1', |
||
88 | '5', |
||
89 | 'n00b', |
||
90 | '', |
||
91 | )); |
||
92 | |||
93 | /* Get the profile of a public member */ |
||
94 | $this->get('ForumMemberProfile/show/' . $this->idFromFixture('Member', 'test2')); |
||
95 | |||
96 | /* Check that it just contains everything |
||
97 | |||
98 | $this->assertExactMatchBySelector("div#UserProfile label", array( |
||
99 | "Nickname:", |
||
100 | 'First Name:', |
||
101 | 'Surname:', |
||
102 | 'Email:', |
||
103 | 'Occupation:', |
||
104 | 'Country:', |
||
105 | 'Number of posts:', |
||
106 | 'Forum ranking:', |
||
107 | 'Avatar:' |
||
108 | )); |
||
109 | $this->assertExactMatchBySelector("div#UserProfile p", array( |
||
110 | 'test2', |
||
111 | 'Test', |
||
112 | 'Two', |
||
113 | '', |
||
114 | 'OtherUser', |
||
115 | 'Australia', |
||
116 | '8', |
||
117 | 'l33t', |
||
118 | '', |
||
119 | )); |
||
120 | */ |
||
121 | } |
||
122 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.