Skip to content

Commit

Permalink
Merge pull request #6 from logicbrush/feature/ss5
Browse files Browse the repository at this point in the history
Feature/ss5
  • Loading branch information
jflearn authored Sep 25, 2024
2 parents ab08dec + 973312a commit dc7305f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 40 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: "Continuous Integration"

on:
- pull_request
- push
push:

jobs:

Expand All @@ -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: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/t.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}],
"require": {
"php": "^7.4||^8.0",
"silverstripe/cms": "^4.0"
"silverstripe/cms": "^4.0||^5.0"
},
"extra": {
"expose": [
Expand All @@ -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": {
Expand Down
Empty file added public/assets/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions src/Model/RollupPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function getCMSFields() {
$fields = parent::getCMSFields();

$fields->insertBefore(
'Content',
OptionsetField::create(
'ShowLinksOnly',
'Rollup Display',
Expand All @@ -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' );

Expand Down
16 changes: 8 additions & 8 deletions tests/unit/Controllers/RollupPageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function testDisplayingRollupPageInline() {
$rollupPage->Content = '<p>Rollup</p>';
$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() );
Expand All @@ -66,10 +66,10 @@ public function testDisplayingRollupPageAsTabs() {
$rollupPage->Content = '<p>Rollup</p>';
$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() );
Expand All @@ -90,13 +90,13 @@ public function testBlockDefaultRollupPageCSS() {
$rollupPage->Title = 'Rollup Page';
$rollupPage->Content = '<p>Rollup</p>';
$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() );

Expand All @@ -113,13 +113,13 @@ public function testBlockDefaultRollupPageJavascript() {
$rollupPage->Title = 'Rollup Page';
$rollupPage->Content = '<p>Rollup</p>';
$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() );

Expand Down
36 changes: 18 additions & 18 deletions tests/unit/Model/RollupPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,45 @@ public function testChildren() {
$rollupPage = RollupPage::create();
$rollupPage->ShowLinksOnly = 1;
$rollupPage->write();
$rollupPage->publish( 'Stage', 'Live' );
$rollupPage->publishSingle();

$this->assertEquals( 0, $rollupPage->Children()->count() );

$page1 = Page::create();
$page1->Content = '<p>Page 1</p>';
$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 = '<p>Page 2</p>';
$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() );
}
Expand Down Expand Up @@ -120,22 +120,22 @@ public function testContent() {
$rollupPage->Title = 'Rollup Page';
$rollupPage->ShowLinksOnly = 0;
$rollupPage->write();
$rollupPage->publish( 'Stage', 'Live' );
$rollupPage->publishSingle();


$page1 = Page::create();
$page1->Title = 'Page 1';
$page1->Content = '<p>Page 1 content</p>';
$page1->ParentID = $rollupPage->ID;
$page1->write();
$page1->publish( 'Stage', 'Live' );
$page1->publishSingle();

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

$this->assertStringContainsString( '<p>Page 1 content</p>', $rollupPage->Content() );
$this->assertStringContainsString( '<p>Page 2 content</p>', $rollupPage->Content() );
Expand All @@ -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( '<p>Page 1 content</p>', $rollupPage->Content() );
$this->assertStringContainsString( '<nav class="rollup-page-navigation-list">', $rollupPage->Content() );
Expand All @@ -162,17 +162,17 @@ public function testContent() {

$rollupPage->ShowLinksOnly = 2;
$rollupPage->write();
$rollupPage->publish( 'Stage', 'Live' );
$rollupPage->publishSingle();

$page1->write();
$page1->publish( 'Stage', 'Live' );
$page1->publishSingle();

$page2->Content = '';
$page2->write();
$page2->publish( 'Stage', 'Live' );
$page2->publishSingle();

$rollupPage->write();
$rollupPage->publish( 'Stage', 'Live' );
$rollupPage->publishSingle();

$this->assertStringContainsString( '<p>Page 1 content</p>', $rollupPage->Content() );
$this->assertStringContainsString( '<nav class="rollup-page-navigation-tabs">', $rollupPage->Content() );
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/Model/WithRollupSupportExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ public function testLink() {
$page1->ParentID = $rollupPage->ID;
$page1->write();

$this->assertEquals( '/rollup-page/page-1/', $page1->Link() );
$this->assertContains( $page1->Link(), ['/rollup-page/page-1/', '/rollup-page/page-1'] );

$rollupPage->ShowLinksOnly = 0;
$rollupPage->write();
$page1->ParentID = $rollupPage->ID;
$page1->write();

$this->assertEquals( '/rollup-page/#page-1', $page1->Link() );
$this->assertContains( $page1->Link(), ['/rollup-page/#page-1', '/rollup-page#page-1'] );

$rollupPage->ShowLinksOnly = 2;
$rollupPage->write();
$page1->ParentID = $rollupPage->ID;
$page1->write();

$this->assertEquals( '/rollup-page/#page-1', $page1->Link() );
$this->assertContains( $page1->Link(), ['/rollup-page/#page-1', '/rollup-page#page-1'] );
}


Expand Down

0 comments on commit dc7305f

Please sign in to comment.