| Conditions | 2 |
| Paths | 2 |
| Total Lines | 33 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 25 | public function testInlineGalleries() { |
||
| 26 | Page::add_extension('AttachedGalleryExtension'); |
||
| 27 | // this page is alone at the top level |
||
| 28 | $page = $this->objFromFixture('Page', 'page02'); |
||
| 29 | $this->assertEquals(0, $page->InlineGalleries()->count()); |
||
|
1 ignored issue
–
show
|
|||
| 30 | |||
| 31 | // Check for an attached gallery |
||
| 32 | $gallery1 = $this->objFromFixture('GalleryPage', 'gp01'); |
||
| 33 | $page->AttachedGalleryID = $gallery1->ID; |
||
| 34 | $page->write(); |
||
| 35 | $expected = array($page); |
||
|
1 ignored issue
–
show
|
|||
| 36 | $this->assertEquals('Test Gallery 1', $page->InlineGalleries()->first()->Title); |
||
|
1 ignored issue
–
show
|
|||
| 37 | $this->assertEquals(1, $page->InlineGalleries()->count()); |
||
|
1 ignored issue
–
show
|
|||
| 38 | |||
| 39 | // Now add child galleries as well |
||
| 40 | $gallery2 = $this->objFromFixture('GalleryPage', 'gp02'); |
||
| 41 | $gallery2->ParentID = $page->ID; |
||
| 42 | $gallery2->write(); |
||
| 43 | |||
| 44 | $gallery3 = $this->objFromFixture('GalleryPage', 'gp03'); |
||
| 45 | $gallery3->ParentID = $page->ID; |
||
| 46 | $gallery3->write(); |
||
| 47 | |||
| 48 | $this->assertEquals(3, $page->InlineGalleries()->count()); |
||
|
1 ignored issue
–
show
|
|||
| 49 | $titles = array(); |
||
| 50 | foreach ($page->InlineGalleries() as $gallery) { |
||
| 51 | array_push($titles, $gallery->Title); |
||
| 52 | } |
||
| 53 | $expected = array('Test Gallery 2', 'Test Gallery 3', 'Test Gallery 1'); |
||
| 54 | $this->assertEquals($expected, $titles); |
||
|
1 ignored issue
–
show
|
|||
| 55 | Page::remove_extension('AttachedGalleryExtension'); |
||
| 56 | |||
| 57 | } |
||
| 58 | } |
||
| 59 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.