Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
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 |
||
37 | public function testHeaders() { |
||
38 | $request = new TestRequest(); |
||
39 | $response = $request->get(array('id' => 'wiki:dokuwiki'), '/doku.php'); |
||
40 | |||
41 | print_r($response); |
||
42 | |||
43 | $this->assertTrue( |
||
44 | strpos($response->getContent(), 'DokuWiki') !== false, |
||
45 | 'DokuWiki was not a word in the output' |
||
46 | ); |
||
47 | |||
48 | // check twitter meta headers |
||
49 | $this->assertEquals( |
||
50 | 'DokuWiki', |
||
51 | $response->queryHTML('meta[name="twitter:title"]')->attr('content') |
||
52 | ); |
||
53 | $this->assertEquals( |
||
54 | '@twitterName', |
||
55 | $response->queryHTML('meta[name="twitter:site"]')->attr('content') |
||
56 | ); |
||
57 | $this->assertEquals( |
||
58 | 'summary', |
||
59 | $response->queryHTML('meta[name="twitter:card"]')->attr('content') |
||
60 | ); |
||
61 | $this->assertEquals( |
||
62 | '@twitterUserName', |
||
63 | $response->queryHTML('meta[name="twitter:creator"]')->attr('content') |
||
64 | ); |
||
65 | $this->assertEquals( |
||
66 | 'http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png', |
||
67 | $response->queryHTML('meta[name="twitter:image"]')->attr('content') |
||
68 | ); |
||
69 | $this->assertEquals( |
||
70 | '', |
||
71 | $response->queryHTML('meta[name="twitter:image:alt"]')->attr('content') |
||
72 | ); |
||
73 | |||
74 | // check og meta headers |
||
75 | $this->assertEquals( |
||
76 | 'My Test Wiki', |
||
77 | $response->queryHTML('meta[property="og:site_name"]')->attr('content') |
||
78 | ); |
||
79 | $this->assertEquals( |
||
80 | 'en_US', |
||
81 | $response->queryHTML('meta[property="og:locale"]')->attr('content') |
||
82 | ); |
||
83 | $this->assertEquals( |
||
84 | 'http://wiki.example.com/./lib/exe/fetch.php?media=wiki:dokuwiki-128.png', |
||
85 | $response->queryHTML('meta[property="og:image"]')->attr('content') |
||
86 | ); |
||
87 | $this->assertEquals( |
||
88 | 'DokuWiki', |
||
89 | $response->queryHTML('meta[property="og:title"]')->attr('content') |
||
90 | ); |
||
91 | $this->assertEquals( |
||
92 | 'article', |
||
93 | $response->queryHTML('meta[property="og:type"]')->attr('content') |
||
94 | ); |
||
95 | } |
||
96 | } |
||
97 |