| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 70 | 
| Code Lines | 37 | 
| 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  | 
            ||
| 28 | public function testAdminEmailsDashboardAction()  | 
            ||
| 29 |     { | 
            ||
| 30 | $this->checkApplication();  | 
            ||
| 31 | |||
| 32 | // Create a new client to browse the application  | 
            ||
| 33 | $client = static::createClient();  | 
            ||
| 34 | $client->followRedirects();  | 
            ||
| 35 | |||
| 36 | $manager = $this->getEntityManager();  | 
            ||
| 37 |         $sentEmailRep = $manager->getRepository("Azine\EmailBundle\Entity\SentEmail"); | 
            ||
| 38 | |||
| 39 | $sentEmails = $sentEmailRep->findAll();  | 
            ||
| 40 | |||
| 41 | $count = count($sentEmails);  | 
            ||
| 42 | |||
| 43 |         $pagination = $this->getContainer()->get('azine.email.bundle.pagination'); | 
            ||
| 44 | |||
| 45 | $manager = $this->getEntityManager();  | 
            ||
| 46 | |||
| 47 | // make sure there is some data in the application  | 
            ||
| 48 |         if ($count < $pagination->getDefaultPageSize()) { | 
            ||
| 49 | |||
| 50 | $amountToAdd = $pagination->getDefaultPageSize() * 2;  | 
            ||
| 51 | TestHelper::addSentEmails($manager, $amountToAdd);  | 
            ||
| 52 | |||
| 53 | $count += $amountToAdd;  | 
            ||
| 54 | }  | 
            ||
| 55 | |||
| 56 |         $listUrl = substr($this->getRouter()->generate("admin_emails_dashboard", array('_locale' => "en")), 13); | 
            ||
| 57 | $crawler = $this->loginUserIfRequired($client, $listUrl);  | 
            ||
| 58 | |||
| 59 |         $this->assertEquals($pagination->getDefaultPageSize(), $crawler->filter(".sentEmail")->count(), "emailsDashboard expected with .".$pagination->getDefaultPageSize()." sent emails"); | 
            ||
| 60 | |||
| 61 | $numberOfPaginationLinks = floor($count / $pagination->getDefaultPageSize()) + 3;  | 
            ||
| 62 |         $this->assertEquals($numberOfPaginationLinks, $crawler->filter(".pagination li")->count(),$numberOfPaginationLinks . " pagination links expected"); | 
            ||
| 63 | |||
| 64 | //click on an email web view link to get to the web page  | 
            ||
| 65 |         $link = $crawler->filter("tr:contains('".EmailTemplateProvider::NEWSLETTER_TEMPLATE."')")->first()->filter("td")->last()->filter("a")->first()->link(); | 
            ||
| 66 | $crawler = $client->click($link);  | 
            ||
| 67 | |||
| 68 |         $this->assertEquals(1, $crawler->filter("span:contains('_az.email.hello')")->count(), " div with hello message expected."); | 
            ||
| 69 | |||
| 70 | $crawler = $this->loginUserIfRequired($client, $listUrl);  | 
            ||
| 71 | |||
| 72 | //click on an email details view link to get to the details page  | 
            ||
| 73 |         $link = $crawler->filter("tr:contains('[email protected]')")->first()->filter("td")->last()->filter("a")->last()->link(); | 
            ||
| 74 | $crawler = $client->click($link);  | 
            ||
| 75 | |||
| 76 |         $this->assertEquals(1, $crawler->filter("tr:contains('[email protected]')")->count(),"Table cell with email expected"); | 
            ||
| 77 | |||
| 78 | $crawler = $this->loginUserIfRequired($client, $listUrl);  | 
            ||
| 79 | |||
| 80 | //Test filtering by email  | 
            ||
| 81 |         $crawler = $crawler->selectButton('sentEmail[save]'); | 
            ||
| 82 | $form = $crawler->form();  | 
            ||
| 83 | $form['sentEmail[recipients]'] = '[email protected]';  | 
            ||
| 84 | $crawler = $client->submit($form);  | 
            ||
| 85 | |||
| 86 |         $this->assertEquals($crawler->filter(".sentEmail")->count(), $crawler->filter("tr:contains('[email protected]')")->count(),"Table rows only with [email protected] email are expected"); | 
            ||
| 87 | |||
| 88 | $form['sentEmail[recipients]'] = '';  | 
            ||
| 89 | $crawler = $client->submit($form);  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 90 | |||
| 91 | //Test filtering by token  | 
            ||
| 92 | $form['sentEmail[token]'] = 'fdasdfasfafsadf';  | 
            ||
| 93 | $crawler = $client->submit($form);  | 
            ||
| 94 | |||
| 95 |         $this->assertEquals($crawler->filter(".sentEmail")->count(), $crawler->filter("tr:contains('fdasdfasfafsadf')")->count(),"Table rows only with fdasdfasfafsadf token are expected"); | 
            ||
| 96 | |||
| 97 | }  | 
            ||
| 98 | |||
| 191 | 
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.