| Conditions | 2 |
| Paths | 2 |
| Total Lines | 51 |
| Code Lines | 26 |
| 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 | } |
||
| 79 | |||
| 172 |