| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 56 | 
| Code Lines | 34 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 43 | public function testSendEmail()  | 
            ||
| 44 |     { | 
            ||
| 45 | $author = $this->objFromFixture(Member::class, 'author');  | 
            ||
| 46 | $item1 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item1');  | 
            ||
| 47 | $item2 = $this->objFromFixture(CommentNotifiableTestDataObject::class, 'item2');  | 
            ||
| 48 | $comment1 = $this->objFromFixture(Comment::class, 'comment1');  | 
            ||
| 49 | $comment2 = $this->objFromFixture(Comment::class, 'comment2');  | 
            ||
| 50 | $comment3 = $this->objFromFixture(Comment::class, 'comment3');  | 
            ||
| 51 | $controller = new CommentNotifierTestController();  | 
            ||
| 52 | |||
| 53 | // Comment 1  | 
            ||
| 54 | $result = $controller->notifyCommentRecipient($comment1, $item1, $author);  | 
            ||
| 55 |         $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted'); | 
            ||
| 56 | |||
| 57 |         $email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted'); | 
            ||
| 58 | |||
| 59 |         $this->assertContains('<li>Bob Bobberson</li>', $email['Content']); | 
            ||
| 60 |         $this->assertContains('<li>[email protected]</li>', $email['Content']); | 
            ||
| 61 |         $this->assertContains('<blockquote>Hey what a lovely comment</blockquote>', $email['Content']); | 
            ||
| 62 | |||
| 63 | $this->clearEmails();  | 
            ||
| 64 | |||
| 65 | // Comment 2  | 
            ||
| 66 | $result = $controller->notifyCommentRecipient($comment2, $item2, $author);  | 
            ||
| 67 |         $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted'); | 
            ||
| 68 | |||
| 69 |         $email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted'); | 
            ||
| 70 |         $this->assertContains('<li>Secret</li>', $email['Content']); | 
            ||
| 71 |         $this->assertContains('<li>[email protected]</li>', $email['Content']); | 
            ||
| 72 |         $this->assertContains('<blockquote>I don't want to disclose my details</blockquote>', $email['Content']); | 
            ||
| 73 | |||
| 74 | $this->clearEmails();  | 
            ||
| 75 | |||
| 76 | // Comment 3  | 
            ||
| 77 | $result = $controller->notifyCommentRecipient($comment3, $item1, $author);  | 
            ||
| 78 |         $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted'); | 
            ||
| 79 | |||
| 80 |         $email = $this->findEmail('[email protected]', '[email protected]', 'A new comment has been posted'); | 
            ||
| 81 | |||
| 82 |         $this->assertContains('<li>Anonymous</li>', $email['Content']); | 
            ||
| 83 |         $this->assertContains('<li>[email protected]</li>', $email['Content']); | 
            ||
| 84 |         $this->assertContains('<blockquote>I didn't log in</blockquote>', $email['Content']); | 
            ||
| 85 | |||
| 86 | $this->clearEmails();  | 
            ||
| 87 | |||
| 88 | // Comment 3 without an author  | 
            ||
| 89 | $result = $controller->notifyCommentRecipient($comment3, $item1, '[email protected]');  | 
            ||
| 90 |         $this->assertEmailSent('[email protected]', '[email protected]', 'A new comment has been posted'); | 
            ||
| 91 | |||
| 92 | $this->clearEmails();  | 
            ||
| 93 | |||
| 94 | // Comment 3 without a valid email  | 
            ||
| 95 | $result = $controller->notifyCommentRecipient($comment3, $item1, '<foobar1>');  | 
            ||
| 96 |         $noEmail = (bool) $this->findEmail('<foobar1>', '[email protected]', 'A new comment has been posted'); | 
            ||
| 97 | |||
| 98 | $this->assertFalse($noEmail);  | 
            ||
| 99 | }  | 
            ||
| 114 |