@@ -11,42 +11,42 @@ |
||
| 11 | 11 | |
| 12 | 12 | class CwpStatsReportTest extends SapphireTest |
| 13 | 13 | { |
| 14 | - protected static $fixture_file = 'CwpStatsReportTest.yml'; |
|
| 15 | - |
|
| 16 | - protected function setUp() |
|
| 17 | - { |
|
| 18 | - Config::modify()->set(SiteTree::class, 'create_default_pages', false); |
|
| 19 | - |
|
| 20 | - parent::setUp(); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function testCount() |
|
| 24 | - { |
|
| 25 | - // Publish all pages apart from page3. |
|
| 26 | - $this->objFromFixture(Page::class, 'page1')->publishRecursive(); |
|
| 27 | - $this->objFromFixture(Page::class, 'page2')->publishRecursive(); |
|
| 28 | - $this->objFromFixture(Page::class, 'page3')->publishRecursive(); |
|
| 29 | - |
|
| 30 | - // Add page5s to a subsite, if the module is installed. |
|
| 31 | - $page5s = $this->objFromFixture(Page::class, 'page5s'); |
|
| 32 | - if (class_exists(Subsite::class)) { |
|
| 33 | - $subsite = Subsite::create(); |
|
| 34 | - $subsite->Title = 'subsite'; |
|
| 35 | - $subsite->write(); |
|
| 36 | - |
|
| 37 | - $page5s->SubsiteID = $subsite->ID; |
|
| 38 | - $page5s->write(); |
|
| 39 | - } |
|
| 40 | - $page5s->publishRecursive(); |
|
| 41 | - |
|
| 42 | - $report = CwpStatsReport::create(); |
|
| 43 | - $records = $report->sourceRecords([])->toArray(); |
|
| 44 | - $i = 0; |
|
| 45 | - $this->assertEquals($records[$i++]['Count'], 4, 'Four pages in total, across locales, subsites, live only.'); |
|
| 46 | - if (class_exists(Subsite::class)) { |
|
| 47 | - $this->assertEquals($records[$i++]['Count'], 3, 'Three pages in the main site, if subsites installed.'); |
|
| 48 | - $this->assertEquals($records[$i++]['Count'], 1, 'One page in the subsite, if subsites installed'); |
|
| 49 | - } |
|
| 50 | - $this->assertEquals($records[$i++]['Count'], 1, 'One file in total.'); |
|
| 51 | - } |
|
| 14 | + protected static $fixture_file = 'CwpStatsReportTest.yml'; |
|
| 15 | + |
|
| 16 | + protected function setUp() |
|
| 17 | + { |
|
| 18 | + Config::modify()->set(SiteTree::class, 'create_default_pages', false); |
|
| 19 | + |
|
| 20 | + parent::setUp(); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function testCount() |
|
| 24 | + { |
|
| 25 | + // Publish all pages apart from page3. |
|
| 26 | + $this->objFromFixture(Page::class, 'page1')->publishRecursive(); |
|
| 27 | + $this->objFromFixture(Page::class, 'page2')->publishRecursive(); |
|
| 28 | + $this->objFromFixture(Page::class, 'page3')->publishRecursive(); |
|
| 29 | + |
|
| 30 | + // Add page5s to a subsite, if the module is installed. |
|
| 31 | + $page5s = $this->objFromFixture(Page::class, 'page5s'); |
|
| 32 | + if (class_exists(Subsite::class)) { |
|
| 33 | + $subsite = Subsite::create(); |
|
| 34 | + $subsite->Title = 'subsite'; |
|
| 35 | + $subsite->write(); |
|
| 36 | + |
|
| 37 | + $page5s->SubsiteID = $subsite->ID; |
|
| 38 | + $page5s->write(); |
|
| 39 | + } |
|
| 40 | + $page5s->publishRecursive(); |
|
| 41 | + |
|
| 42 | + $report = CwpStatsReport::create(); |
|
| 43 | + $records = $report->sourceRecords([])->toArray(); |
|
| 44 | + $i = 0; |
|
| 45 | + $this->assertEquals($records[$i++]['Count'], 4, 'Four pages in total, across locales, subsites, live only.'); |
|
| 46 | + if (class_exists(Subsite::class)) { |
|
| 47 | + $this->assertEquals($records[$i++]['Count'], 3, 'Three pages in the main site, if subsites installed.'); |
|
| 48 | + $this->assertEquals($records[$i++]['Count'], 1, 'One page in the subsite, if subsites installed'); |
|
| 49 | + } |
|
| 50 | + $this->assertEquals($records[$i++]['Count'], 1, 'One file in total.'); |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -5,41 +5,41 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class CwpSiteSummaryExtension extends Extension |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Updates the modules used for the version label by: |
|
| 10 | - * - Removing SS Framework |
|
| 11 | - * - Adding CWP |
|
| 12 | - * - Relabelling SS CMS |
|
| 13 | - * |
|
| 14 | - * @param array $modules |
|
| 15 | - */ |
|
| 16 | - public function updateVersionModules(&$modules) |
|
| 17 | - { |
|
| 18 | - unset($modules['silverstripe/framework']); |
|
| 19 | - $modules = ['cwp/cwp' => 'CWP'] + $modules; |
|
| 20 | - $modules['silverstripe/cms'] = 'SilverStripe CMS'; |
|
| 21 | - } |
|
| 8 | + /** |
|
| 9 | + * Updates the modules used for the version label by: |
|
| 10 | + * - Removing SS Framework |
|
| 11 | + * - Adding CWP |
|
| 12 | + * - Relabelling SS CMS |
|
| 13 | + * |
|
| 14 | + * @param array $modules |
|
| 15 | + */ |
|
| 16 | + public function updateVersionModules(&$modules) |
|
| 17 | + { |
|
| 18 | + unset($modules['silverstripe/framework']); |
|
| 19 | + $modules = ['cwp/cwp' => 'CWP'] + $modules; |
|
| 20 | + $modules['silverstripe/cms'] = 'SilverStripe CMS'; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing |
|
| 25 | - * filter options) |
|
| 26 | - * |
|
| 27 | - * @param GridFieldDropdownFilter $dropdownFilter |
|
| 28 | - */ |
|
| 29 | - public function updateDropdownFilterOptions($dropdownFilter) |
|
| 30 | - { |
|
| 31 | - $dropdownFilter->removeFilterOption('supported'); |
|
| 32 | - $dropdownFilter->removeFilterOption('unsupported'); |
|
| 23 | + /** |
|
| 24 | + * Updates the dropdown filter used to filter supported packages by renaming the labels (replaces the existing |
|
| 25 | + * filter options) |
|
| 26 | + * |
|
| 27 | + * @param GridFieldDropdownFilter $dropdownFilter |
|
| 28 | + */ |
|
| 29 | + public function updateDropdownFilterOptions($dropdownFilter) |
|
| 30 | + { |
|
| 31 | + $dropdownFilter->removeFilterOption('supported'); |
|
| 32 | + $dropdownFilter->removeFilterOption('unsupported'); |
|
| 33 | 33 | |
| 34 | - $dropdownFilter->addFilterOption( |
|
| 35 | - 'supported', |
|
| 36 | - _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'), |
|
| 37 | - ['Supported' => true] |
|
| 38 | - ); |
|
| 39 | - $dropdownFilter->addFilterOption( |
|
| 40 | - 'unsupported', |
|
| 41 | - _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'), |
|
| 42 | - ['Supported' => false] |
|
| 43 | - ); |
|
| 44 | - } |
|
| 34 | + $dropdownFilter->addFilterOption( |
|
| 35 | + 'supported', |
|
| 36 | + _t(__CLASS__ . '.FilterSupported', 'CWP recipe modules'), |
|
| 37 | + ['Supported' => true] |
|
| 38 | + ); |
|
| 39 | + $dropdownFilter->addFilterOption( |
|
| 40 | + 'unsupported', |
|
| 41 | + _t(__CLASS__ . '.FilterUnsupported', 'Non CWP modules'), |
|
| 42 | + ['Supported' => false] |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -9,30 +9,30 @@ |
||
| 9 | 9 | |
| 10 | 10 | class RelatedPageLink extends DataObject |
| 11 | 11 | { |
| 12 | - private static $table_name = 'BasePage_RelatedPages'; |
|
| 12 | + private static $table_name = 'BasePage_RelatedPages'; |
|
| 13 | 13 | |
| 14 | - private static $extensions = [ |
|
| 15 | - Versioned::class |
|
| 16 | - ]; |
|
| 14 | + private static $extensions = [ |
|
| 15 | + Versioned::class |
|
| 16 | + ]; |
|
| 17 | 17 | |
| 18 | - private static $db = [ |
|
| 19 | - 'SortOrder' => DBInt::class |
|
| 20 | - ]; |
|
| 18 | + private static $db = [ |
|
| 19 | + 'SortOrder' => DBInt::class |
|
| 20 | + ]; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * For backwards compatibility these must match a traditional 'many_many' definition. |
|
| 24 | - * This was BasePage.RelatedPages => BasePage |
|
| 25 | - * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID |
|
| 26 | - * excepting in the case where ${DefiningClass} === ${RelatedClass} |
|
| 27 | - * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID". |
|
| 28 | - * |
|
| 29 | - * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()} |
|
| 30 | - * |
|
| 31 | - * @var array |
|
| 32 | - * @config |
|
| 33 | - */ |
|
| 34 | - private static $has_one = [ |
|
| 35 | - 'BasePage' => BasePage::class, |
|
| 36 | - 'Child' => BasePage::class, |
|
| 37 | - ]; |
|
| 22 | + /** |
|
| 23 | + * For backwards compatibility these must match a traditional 'many_many' definition. |
|
| 24 | + * This was BasePage.RelatedPages => BasePage |
|
| 25 | + * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID |
|
| 26 | + * excepting in the case where ${DefiningClass} === ${RelatedClass} |
|
| 27 | + * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID". |
|
| 28 | + * |
|
| 29 | + * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()} |
|
| 30 | + * |
|
| 31 | + * @var array |
|
| 32 | + * @config |
|
| 33 | + */ |
|
| 34 | + private static $has_one = [ |
|
| 35 | + 'BasePage' => BasePage::class, |
|
| 36 | + 'Child' => BasePage::class, |
|
| 37 | + ]; |
|
| 38 | 38 | } |