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