Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REFACTOR CMS5 compatibility #219

Merged
merged 8 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 5 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,11 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: CI

on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]

name: "CI"
workflow_dispatch:

jobs:
tests:
name: "Tests"

runs-on: "ubuntu-latest"

env:
php_extensions: ctype, dom, fileinfo, hash, intl, mbstring, session, simplexml, tokenizer, xml, pdo, mysqli, gd, zip

services:
mysql:
image: "mysql:5.7"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: test_db
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.php_extensions }}"
coverage: "xdebug"

- name: "Start mysql service"
run: "sudo /etc/init.d/mysql start"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }}"
restore-keys: "php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install dependencies with composer"
run: "composer install --no-ansi --no-interaction --no-progress"

- name: "Run tests with phpunit/phpunit"
env:
SS_DATABASE_PORT: ${{ job.services.mysql.ports['3306'] }}
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Upload coverage results to CodeCov"
uses: codecov/codecov-action@v1
with:
files: ./coverage.xml # optional
flags: unittests # optional

- name: "Run tests with squizlabs/php_codesniffer"
run: "vendor/bin/phpcs -s --report=summary --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/"
ci:
name: CI
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
55 changes: 30 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"name": "dynamic/flexslider",
"description": "Display a FlexSlider on pages of your website",
"authors": [
{
"name": "Dynamic",
"homepage": "http://www.dynamicagency.com",
"email": "dev@dynamicagency.com"
}
],
"license": "BSD-3-Clause",
"type": "silverstripe-vendormodule",
"keywords": [
"silverstripe",
"flexslider",
Expand All @@ -16,38 +11,48 @@
"slider",
"jquery"
],
"license": "BSD-3-Clause",
"type": "silverstripe-vendormodule",
"authors": [
{
"name": "Dynamic",
"email": "dev@dynamicagency.com",
"homepage": "https://www.dynamicagency.com"
}
],
"require": {
"silverstripe/recipe-cms": "^4.0",
"dynamic/silverstripe-linkable": "^1.0",
"symbiote/silverstripe-gridfieldextensions": "^3.0"
"dynamic/silverstripe-linkable": "dev-master",
"silverstripe/recipe-cms": "^5",
"symbiote/silverstripe-gridfieldextensions": "^4"
},
"require-dev": {
"silverstripe/recipe-testing": "^2",
"squizlabs/php_codesniffer": "^3.0"
"silverstripe/recipe-testing": "^3"
},
"repositories": {
"dynamic/silverstripe-linkable": {
"type": "vcs",
"url": "git@github.com:dynamic/silverstripe-linkable.git"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Dynamic\\FlexSlider\\": "src/",
"Dynamic\\FlexSlider\\Test\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"composer/installers": true,
"silverstripe/recipe-plugin": true,
"silverstripe/vendor-plugin": true
},
"process-timeout": 600
},
"extra": {
"expose": [
"css",
"images",
"thirdparty"
]
},
"config": {
"process-timeout": 600,
"allow-plugins": {
"composer/installers": true,
"silverstripe/recipe-plugin": true,
"silverstripe/vendor-plugin": true
}
}
}
}
34 changes: 12 additions & 22 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
<?xml version="1.0"?>
<ruleset name="SS4">
<description>Coding standard for SilverStripe 4.x</description>

<!-- Don't sniff third party libraries -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/thirdparty/*</exclude-pattern>

<!-- Show progress and output sniff names on violation, and add colours -->
<arg value="sp"/>
<arg name="colors"/>

<!-- Use PSR-2 as a base standard -->
<rule ref="PSR2">
<!-- Allow classes to not declare a namespace -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>

<!-- Allow underscores in class names -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>

<!-- Allow non camel cased method names -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<file>src</file>
<file>tests</file>

<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion src/ORM/FlexSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function updateCMSFields(FieldList $fields)
$config
);

$slideTitle = $this->owner->stat('slide_tab_title') ?: _t(__CLASS__ . '.SLIDES', 'Slides');
$slideTitle = $this->owner->config()->get('slide_tab_title') ?: _t(__CLASS__ . '.SLIDES', 'Slides');

$animations = [];
$animationOptions = $this->owner->dbObject('Animation')->getEnum();
Expand Down
2 changes: 1 addition & 1 deletion tests/FlexSliderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testTabNameConfig()
$this->assertNotNull($pageFields->dataFieldByName('Slides'));

Config::modify()
->update(TestPage::class, 'slide_tab_title', 'MyCustomSlideTitle');
->set(TestPage::class, 'slide_tab_title', 'MyCustomSlideTitle');
$page2 = TestPage::create();
$page2->write();
$page2Fields = $page2->getCMSFields();
Expand Down
2 changes: 1 addition & 1 deletion tests/SlideImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function testImageSizeLimit()
$this->assertEquals(Config::modify()->get(SlideImage::class, 'image_size_limit'), $default);

$new = 1024000;
Config::modify()->update(SlideImage::class, 'image_size_limit', $new);
Config::modify()->set(SlideImage::class, 'image_size_limit', $new);
$this->assertEquals(Config::modify()->get(SlideImage::class, 'image_size_limit'), $new);
}

Expand Down