| Conditions | 1 |
| Paths | 1 |
| Total Lines | 66 |
| Code Lines | 41 |
| 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 |
||
| 20 | public function testPageIndexation() |
||
| 21 | { |
||
| 22 | /* @var BasePage $homepage */ |
||
| 23 | $homepage = $this->entityManager->getRepository('VictoirePageBundle:BasePage')->findOneByHomepage('en'); |
||
| 24 | |||
| 25 | //English first |
||
| 26 | $pageSeo = new PageSeo(); |
||
| 27 | $pageSeo->setCurrentLocale('en'); |
||
| 28 | $pageSeo->setSitemapIndexed(false); |
||
| 29 | $pageSeo->setSitemapPriority(0.8); |
||
| 30 | $this->entityManager->persist($pageSeo); |
||
| 31 | |||
| 32 | $page = new Page(); |
||
| 33 | $page->setCurrentLocale('en'); |
||
| 34 | $page->setName('Indexed page'); |
||
| 35 | $page->setSeo($pageSeo); |
||
| 36 | $page->setParent($homepage); |
||
| 37 | $this->entityManager->persist($page); |
||
| 38 | |||
| 39 | //French |
||
| 40 | $page->setCurrentLocale('fr'); |
||
| 41 | $page->setName('Page indexée'); |
||
| 42 | $pageSeo->setCurrentLocale('fr'); |
||
| 43 | $pageSeo->setSitemapIndexed(true); |
||
| 44 | $pageSeo->setSitemapPriority(0.3); |
||
| 45 | |||
| 46 | $this->entityManager->flush(); |
||
| 47 | $this->resetViewsReference(); |
||
| 48 | |||
| 49 | $englishAssertions = [ |
||
| 50 | [ |
||
| 51 | 'loc' => '/en/', |
||
| 52 | 'changefreq' => 'monthly', |
||
| 53 | 'priority' => '0.5', |
||
| 54 | ], |
||
| 55 | [ |
||
| 56 | 'loc' => '/en/english-test', |
||
| 57 | 'changefreq' => 'monthly', |
||
| 58 | 'priority' => '0.5', |
||
| 59 | ], |
||
| 60 | ]; |
||
| 61 | |||
| 62 | $frenchAssertions = [ |
||
| 63 | [ |
||
| 64 | 'loc' => '/fr/', |
||
| 65 | 'changefreq' => 'monthly', |
||
| 66 | 'priority' => '0.5', |
||
| 67 | ], |
||
| 68 | [ |
||
| 69 | 'loc' => '/fr/test', |
||
| 70 | 'changefreq' => 'monthly', |
||
| 71 | 'priority' => '0.5', |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | 'loc' => '/fr/page-indexee', |
||
| 75 | 'changefreq' => 'monthly', |
||
| 76 | 'priority' => '0.3', |
||
| 77 | ], |
||
| 78 | ]; |
||
| 79 | |||
| 80 | $englishPages = $this->getSitemapPages('en'); |
||
| 81 | $this->runAssertions($englishPages, $englishAssertions); |
||
| 82 | |||
| 83 | $frenchPages = $this->getSitemapPages('fr'); |
||
| 84 | $this->runAssertions($frenchPages, $frenchAssertions); |
||
| 85 | } |
||
| 86 | |||
| 112 |