| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 39 |
| 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 |
||
| 73 | public function testPublishedPagesMatchedByTitleInDefaultLanguage() |
||
| 74 | { |
||
| 75 | $publishedPage = $this->objFromFixture(SiteTree::class, 'publishedPage'); |
||
| 76 | $publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||
| 77 | |||
| 78 | $translatedPublishedPage = $publishedPage->createTranslation('de_DE'); |
||
| 79 | $translatedPublishedPage->Title = 'translatedPublishedPage'; |
||
| 80 | $translatedPublishedPage->Content = 'German content'; |
||
| 81 | $translatedPublishedPage->write(); |
||
| 82 | $publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||
| 83 | |||
| 84 | $this->waitUntilIndexingFinished(); |
||
| 85 | |||
| 86 | $lang = 'en_US'; |
||
| 87 | $request = new HTTPRequest('GET', 'search', ['Search'=>'content', 'searchlocale' => $lang]); |
||
| 88 | $request->setSession($this->session()); |
||
| 89 | $this->mockController->setRequest($request); |
||
| 90 | $sf = new SearchForm($this->mockController); |
||
| 91 | $results = $sf->getResults(); |
||
| 92 | |||
| 93 | $this->assertContains( |
||
| 94 | $publishedPage->ID, |
||
| 95 | $results->column('ID'), |
||
| 96 | 'Published pages are found by searchform in default language' |
||
| 97 | ); |
||
| 98 | $this->assertNotContains( |
||
| 99 | $translatedPublishedPage->ID, |
||
| 100 | $results->column('ID'), |
||
| 101 | 'Published pages in another language are not found when searching in default language' |
||
| 102 | ); |
||
| 103 | |||
| 104 | $lang = 'de_DE'; |
||
| 105 | $request = new HTTPRequest('GET', 'search', ['Search'=>'content', 'searchlocale' => $lang]); |
||
| 106 | $request->setSession($this->session()); |
||
| 107 | $this->mockController->setRequest($request); |
||
| 108 | $sf2 = new SearchForm($this->mockController); |
||
| 109 | $results = $sf2->getResults(); |
||
| 110 | |||
| 111 | $this->assertNotContains( |
||
| 112 | $publishedPage->ID, |
||
| 113 | $results->column('ID'), |
||
| 114 | 'Published pages in default language are not found when searching in another language' |
||
| 115 | ); |
||
| 116 | $actual = $results->column('ID'); |
||
| 117 | array_walk($actual, 'intval'); |
||
| 118 | $this->assertContains( |
||
| 119 | (int)$translatedPublishedPage->ID, |
||
| 120 | $actual, |
||
| 121 | 'Published pages in another language are found when searching in this language' |
||
| 122 | ); |
||
| 123 | } |
||
| 124 | } |
||
| 125 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.