function testIncludesParentsForNestedMatches() { $parent = $this->objFromFixture('Page', 'page3'); $child = $this->objFromFixture('Page', 'page3b'); $f = new CMSSiteTreeFilter_Search(array('Title' => 'Page 3b')); $results = $f->pagesIncluded(); $this->assertTrue($f->isPageIncluded($parent)); $this->assertTrue($f->isPageIncluded($child)); $this->assertEquals(1, count($results)); $this->assertEquals(array('ID' => $child->ID, 'ParentID' => $parent->ID), $results[0]); }
/** * Returns a sorted array of all implementators of CMSSiteTreeFilter, suitable for use in a dropdown. * * @return array */ public static function get_all_filters() { // get all filter instances $filters = ClassInfo::subclassesFor('CMSSiteTreeFilter'); // remove abstract CMSSiteTreeFilter class array_shift($filters); // add filters to map $filterMap = array(); foreach ($filters as $filter) { $filterMap[$filter] = $filter::title(); } // Ensure that 'all pages' filter is on top position and everything else is sorted alphabetically uasort($filterMap, function ($a, $b) { return $a === CMSSiteTreeFilter_Search::title() ? -1 : strcasecmp($a, $b); }); return $filterMap; }
public function testDateFromToLastSameDate() { $draftPage = $this->objFromFixture('Page', 'page4'); // Grab the date $date = substr($draftPage->LastEdited, 0, 10); // Filter with that date $filter = new CMSSiteTreeFilter_Search(array('LastEditedFrom' => $date, 'LastEditedTo' => $date)); $this->assertTrue($filter->isPageIncluded($draftPage), 'Using the same date for from and to should show find that page'); }