| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Created by PhpStorm. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * User: simon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Date: 20-Oct-17 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Time: 15:04 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class PageUpdateServiceTest extends SapphireTest | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      * @var PageUpdateService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     protected $service; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     public function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $this->service = new PageUpdateService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         return parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * Validate an array with two empty values finds the homepage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     public function testFindHomePage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $testArray = ['', '']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $page = $this->service->findPage($testArray); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->assertInstanceOf(Page::class, $page); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertEquals('home', $page->URLSegment); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * Validate we're traversing correctly down in to the child pages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 37 |  | View Code Duplication |     public function testFindChildPage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         /** @var Page $homePage */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $homePage = Page::get()->filter(['URLSegment' => 'home'])->first(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         /** @var Page $homePage */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $child = Page::create(['Title' => 'Test Page', 'ParentID' => $homePage->ID]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $child->write(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $child->doPublish(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $testArray = ['', '', 'test-page']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $page = $this->service->findPage($testArray); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $this->assertInstanceOf(Page::class, $page); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $this->assertEquals('/home/test-page/', $page->Link()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * Make sure the get params are ignored | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 54 |  | View Code Duplication |     public function testFindChildPageWithQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         /** @var Page $homePage */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $homePage = Page::get()->filter(['URLSegment' => 'home'])->first(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         /** @var Page $homePage */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $child = Page::create(['Title' => 'Test Page', 'ParentID' => $homePage->ID]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $child->write(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $child->doPublish(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $testArray = ['', '', 'test-page', '?stage=Stage']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $page = $this->service->findPage($testArray); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->assertInstanceOf(Page::class, $page); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->assertEquals('/home/test-page/', $page->Link()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      * Make sure an empty last value is skipped | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 71 |  | View Code Duplication |     public function testFindPageWithEmptyLast() | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |         /** @var Page $homePage */ | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |         $homePage = Page::get()->filter(['URLSegment' => 'home'])->first(); | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |         /** @var Page $homePage */ | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |         $child = Page::create(['Title' => 'Test Page', 'ParentID' => $homePage->ID]); | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |         $child->write(); | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |         $child->doPublish(); | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |         $testArray = ['', '', 'test-page', '']; | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |         $page = $this->service->findPage($testArray); | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |         $this->assertInstanceOf(Page::class, $page); | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |         $this->assertEquals('/home/test-page/', $page->Link()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * Validate updating the pages works | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     public function testUpdateVisits() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $result = $this->service->updateVisits([new AnalyticsResponseHomePageMock()]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $this->assertEquals(1, $result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $page = Page::get()->filter(['URLSegment' => 'home'])->first(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->assertEquals(45477, $page->VisitCount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * Validate that if no pages is found, nothing is done. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     public function testUpdateNoVisits() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $result = $this->service->updateVisits([new AnalyticsResponseNoPageMock()]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $this->assertEquals(0, $result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $this->assertFalse($this->service->batched); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 105 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 106 |  |  |  | 
            
                        
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