diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73d94bf..0927f16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,7 @@ name: "Continuous Integration" on: - - pull_request - - push + push: jobs: @@ -12,20 +11,22 @@ jobs: matrix: include: - operating-system: 'ubuntu-latest' - php-version: '8.2' - - operating-system: 'ubuntu-latest' + silverstripe-version: '5.0' php-version: '8.1' - operating-system: 'ubuntu-latest' + silverstripe-version: '4.0' php-version: '8.0' - operating-system: 'ubuntu-latest' + silverstripe-version: '4.0' php-version: '7.4' - name: PHP ${{ matrix.php-version }} + name: SS ${{ matrix.silverstripe-version }}, PHP ${{ matrix.php-version }} runs-on: ${{ matrix.operating-system }} steps: - uses: actions/checkout@v3 - uses: php-actions/composer@v6 with: + command: update --with silverstripe/framework:^${{ matrix.silverstripe-version }} php_version: ${{ matrix.php-version }} php_extensions: intl - run: | diff --git a/.github/workflows/t.yml b/.github/workflows/t.yml index eb31e9a..87fa1a2 100644 --- a/.github/workflows/t.yml +++ b/.github/workflows/t.yml @@ -15,6 +15,8 @@ jobs: - uses: actions/checkout@v3 - uses: php-actions/composer@v6 with: + command: update --with silverstripe/framework:^5.0 + php_version: 8.1 php_extensions: xdebug intl - name: Generate Code Coverage run: | diff --git a/composer.json b/composer.json index 6b582fa..02a1eb5 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }], "require": { "php": "^7.4||^8.0", - "silverstripe/cms": "^4.0" + "silverstripe/cms": "^4.0||^5.0" }, "extra": { "expose": [ @@ -25,9 +25,9 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "silverstripe/sqlite3": "^2.2", - "logicbrush/metrics": "^0.2.0", - "cmrcx/phptidy": "^3.3" + "silverstripe/sqlite3": "*", + "logicbrush/metrics": "*", + "cmrcx/phptidy": "*" }, "autoload": { "psr-4": { diff --git a/public/assets/.gitkeep b/public/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Model/RollupPage.php b/src/Model/RollupPage.php index b0e5085..e9a7d10 100644 --- a/src/Model/RollupPage.php +++ b/src/Model/RollupPage.php @@ -59,6 +59,7 @@ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->insertBefore( + 'Content', OptionsetField::create( 'ShowLinksOnly', 'Rollup Display', @@ -67,8 +68,7 @@ public function getCMSFields() { 2 => 'Show children in tabs', 1 => 'Show children as links', ] - ), - 'Content' ); + ) ); $contentField = $fields->dataFieldByName( 'Content' ); $contentField->setTitle( 'Introduction' ); diff --git a/tests/unit/Controllers/RollupPageControllerTest.php b/tests/unit/Controllers/RollupPageControllerTest.php index a97a0d8..64171ad 100644 --- a/tests/unit/Controllers/RollupPageControllerTest.php +++ b/tests/unit/Controllers/RollupPageControllerTest.php @@ -42,10 +42,10 @@ public function testDisplayingRollupPageInline() { $rollupPage->Content = '

Rollup

'; $rollupPage->ShowLinksOnly = RollupPage::DISPLAY_INLINE; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $child1 = $this->addChildPage( $rollupPage, 'Child 1' ); - $child1->publish( 'Stage', 'Live' ); + $child1->publishSingle(); $response = $this->get( $rollupPage->Link() ); $this->assertEquals( 200, $response->getStatusCode() ); @@ -66,10 +66,10 @@ public function testDisplayingRollupPageAsTabs() { $rollupPage->Content = '

Rollup

'; $rollupPage->ShowLinksOnly = RollupPage::DISPLAY_TABS; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $child1 = $this->addChildPage( $rollupPage, 'Child 1' ); - $child1->publish( 'Stage', 'Live' ); + $child1->publishSingle(); $response = $this->get( $rollupPage->Link() ); $this->assertEquals( 200, $response->getStatusCode() ); @@ -90,13 +90,13 @@ public function testBlockDefaultRollupPageCSS() { $rollupPage->Title = 'Rollup Page'; $rollupPage->Content = '

Rollup

'; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $response = $this->get( $rollupPage->Link() ); $this->assertStringContainsString( 'css/rolluppage.css', $response->getBody() ); - RollupPage::config()->update( 'block_default_rollup_page_css', true ); + RollupPage::config()->set( 'block_default_rollup_page_css', true ); $response = $this->get( $rollupPage->Link() ); @@ -113,13 +113,13 @@ public function testBlockDefaultRollupPageJavascript() { $rollupPage->Title = 'Rollup Page'; $rollupPage->Content = '

Rollup

'; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $response = $this->get( $rollupPage->Link() ); $this->assertStringContainsString( 'javascript/rolluppage.js', $response->getBody() ); - RollupPage::config()->update( 'block_default_rollup_page_js', true ); + RollupPage::config()->set( 'block_default_rollup_page_js', true ); $response = $this->get( $rollupPage->Link() ); diff --git a/tests/unit/Model/RollupPageTest.php b/tests/unit/Model/RollupPageTest.php index 176663e..75d2133 100644 --- a/tests/unit/Model/RollupPageTest.php +++ b/tests/unit/Model/RollupPageTest.php @@ -46,7 +46,7 @@ public function testChildren() { $rollupPage = RollupPage::create(); $rollupPage->ShowLinksOnly = 1; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $this->assertEquals( 0, $rollupPage->Children()->count() ); @@ -54,37 +54,37 @@ public function testChildren() { $page1->Content = '

Page 1

'; $page1->ParentID = $rollupPage->ID; $page1->write(); - $page1->publish( 'Stage', 'Live' ); + $page1->publishSingle(); $page2 = Page::create(); $page2->Content = ''; $page2->ParentID = $rollupPage->ID; $page2->write(); - $page2->publish( 'Stage', 'Live' ); + $page2->publishSingle(); $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $this->assertEquals( 1, $rollupPage->Children()->count() ); $page2->Content = '

Page 2

'; $page2->write(); - $page2->publish( 'Stage', 'Live' ); + $page2->publishSingle(); $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $this->assertEquals( 2, $rollupPage->Children()->count() ); $rollupPage->ShowLinksOnly = 2; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $this->assertEquals( 0, $rollupPage->Children()->count() ); $rollupPage->ShowLinksOnly = 0; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $this->assertEquals( 0, $rollupPage->Children()->count() ); } @@ -120,7 +120,7 @@ public function testContent() { $rollupPage->Title = 'Rollup Page'; $rollupPage->ShowLinksOnly = 0; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $page1 = Page::create(); @@ -128,14 +128,14 @@ public function testContent() { $page1->Content = '

Page 1 content

'; $page1->ParentID = $rollupPage->ID; $page1->write(); - $page1->publish( 'Stage', 'Live' ); + $page1->publishSingle(); $page2 = FakePage::create(); $page2->Title = 'Page 2'; $page2->Content = '

Page 2 content

'; $page2->ParentID = $rollupPage->ID; $page2->write(); - $page2->publish( 'Stage', 'Live' ); + $page2->publishSingle(); $this->assertStringContainsString( '

Page 1 content

', $rollupPage->Content() ); $this->assertStringContainsString( '

Page 2 content

', $rollupPage->Content() ); @@ -145,13 +145,13 @@ public function testContent() { $rollupPage->ShowLinksOnly = 1; $rollupPage->write(); - $rollupPage->publish( 'Stage', 'Live' ); + $rollupPage->publishSingle(); $page1->write(); - $page1->publish( 'Stage', 'Live' ); + $page1->publishSingle(); $page2->write(); - $page2->publish( 'Stage', 'Live' ); + $page2->publishSingle(); $this->assertStringNotContainsString( '

Page 1 content

', $rollupPage->Content() ); $this->assertStringContainsString( '