Conditions | 2 |
Paths | 2 |
Total Lines | 63 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
Bugs | 1 | 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 |
||
16 | public function testAdminEmailsDashboardAction() |
||
17 | { |
||
18 | $this->checkApplication(); |
||
19 | |||
20 | // Create a new client to browse the application |
||
21 | $client = static::createClient(); |
||
22 | $client->followRedirects(); |
||
23 | |||
24 | $manager = $this->getEntityManager(); |
||
25 | /** @var SentEmailRepository $sentEmailRep */ |
||
26 | $sentEmailRep = $manager->getRepository("Azine\EmailBundle\Entity\SentEmail"); |
||
27 | |||
28 | $testSentEmails = $sentEmailRep->search(array('recipients' => TestHelper::TEST_EMAIL, 'template' => AzineTemplateProvider::NEWSLETTER_TEMPLATE))->getArrayResult(); |
||
29 | $pageLimit = 10; |
||
30 | |||
31 | if (count($testSentEmails) < $pageLimit) { |
||
32 | $amountToAdd = ($pageLimit * 2) + 2; |
||
33 | TestHelper::addSentEmails($manager, $amountToAdd); |
||
34 | } |
||
35 | |||
36 | $testSentEmails = $sentEmailRep->search(array('template' => AzineTemplateProvider::NEWSLETTER_TEMPLATE))->getArrayResult(); |
||
37 | |||
38 | $listUrl = substr($this->getRouter()->generate('azine_admin_email_dashboard', array('_locale' => 'en', 'limit' => $pageLimit, 'sentEmail[template]' => AzineTemplateProvider::NEWSLETTER_TEMPLATE)), 13); |
||
39 | $crawler = $this->loginUserIfRequired($client, $listUrl); |
||
40 | |||
41 | $this->assertSame($pageLimit, $crawler->filter('.sentEmail')->count(), 'emailsDashboard expected with '.$pageLimit.' sent emails'); |
||
42 | |||
43 | $numberOfPaginationLinks = intval(ceil(count($testSentEmails) / $pageLimit)); |
||
44 | |||
45 | $this->assertSame($numberOfPaginationLinks, $crawler->filter('.pagination .page')->count() + $crawler->filter('.pagination .current')->count(), $numberOfPaginationLinks.' pagination links expected'); |
||
46 | |||
47 | //click on an email web view link to get to the web page |
||
48 | $link = $crawler->filter(".sentEmail:contains('".AzineTemplateProvider::NEWSLETTER_TEMPLATE."')")->filter('a.showWebViewButton')->link(); |
||
49 | $crawler = $client->click($link); |
||
50 | |||
51 | $this->assertSame(1, $crawler->filter("span:contains('Hello')")->count(), ' div with hello message expected.'); |
||
52 | |||
53 | $crawler = $client->request('GET', $listUrl); |
||
54 | |||
55 | // Test filtering by email |
||
56 | $crawler = $crawler->selectButton('sentEmail[filter]'); |
||
57 | $form = $crawler->form(); |
||
58 | $form['sentEmail[recipients]'] = TestHelper::TEST_EMAIL; |
||
59 | $crawler = $client->submit($form); |
||
60 | |||
61 | $this->assertSame($crawler->filter('.sentEmail')->count(), $crawler->filter("tr:contains('".TestHelper::TEST_EMAIL."')")->count(), 'Table rows only with '.TestHelper::TEST_EMAIL.' email are expected'); |
||
62 | |||
63 | //click on email details view link to get to the details page |
||
64 | $link = $crawler->filter(".sentEmail:contains('".TestHelper::TEST_EMAIL."')")->filter('a.showDetailsButton')->link(); |
||
65 | $crawler = $client->click($link); |
||
66 | |||
67 | $this->assertSame(1, $crawler->filter("tr:contains('".TestHelper::TEST_EMAIL."')")->count(), 'Table cell with '.TestHelper::TEST_EMAIL.' expected'); |
||
68 | |||
69 | $client->request('GET', $listUrl); |
||
70 | |||
71 | $form['sentEmail[recipients]'] = ''; |
||
72 | $client->submit($form); |
||
73 | |||
74 | //Test filtering by token |
||
75 | $form['sentEmail[token]'] = TestHelper::TEST_TOKEN; |
||
76 | $crawler = $client->submit($form); |
||
77 | |||
78 | $this->assertSame($crawler->filter('.sentEmail')->count(), $crawler->filter(".sentEmail:contains('".TestHelper::TEST_TOKEN."')")->count(), 'Table row only with '.TestHelper::TEST_TOKEN.' token is expected'); |
||
79 | } |
||
174 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths