Skip to content

Commit 2ecebe5

Browse files
authored
add: Silverstripe 6 Support (#10)
* remove: CMS is no longer a required dependency * add: Silverstripe 6 Support * fix: master used for PRs * fix: phpunit * fix 💩 * fix phpstan * make phpunit resolve * resolve phpunit... * fix stan * only use SS 6 * stan again * cs * use 6.0 for coverage * update phpunit
1 parent 32a9f99 commit 2ecebe5

File tree

8 files changed

+78
-44
lines changed

8 files changed

+78
-44
lines changed

.github/workflows/tests.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
11
name: 🎭 Tests
22
on:
3-
- push
4-
env:
5-
DB: MYSQL
6-
PDO: 1
7-
SS_ENVIRONMENT_TYPE: "dev"
8-
RECIPE_CMS_VERSION: 4.x-dev
3+
push:
4+
paths-ignore:
5+
- .chglog/**
6+
- .github/**
7+
- '!.github/workflows/tests.yml'
8+
- .editorconfig
9+
- .gitattributes
10+
- .gitignore
11+
- .htaccess
12+
- '**.md'
13+
branches:
14+
- 'master'
15+
pull_request:
16+
paths-ignore:
17+
- .chglog/**
18+
- .github/**
19+
- '!.github/workflows/tests.yml'
20+
- .editorconfig
21+
- .gitattributes
22+
- .gitignore
23+
- .htaccess
24+
- '**.md'
25+
branches:
26+
- 'master'
27+
928
jobs:
10-
silverstripe-module:
11-
name: 🧰 Silverstripe Module Testsuite
12-
uses: syntro-opensource/workflows/.github/workflows/silverstripe-module.yml@master
29+
silverstripe-module-6:
30+
name: 🧰 Silverstripe Module Testsuite 6
31+
uses: syntro-opensource/workflows/.github/workflows/silverstripe-module-6.yml@master
1332
with:
1433
phpunit: true
1534
phpstan: true
16-
phpcs: true
35+
silverstripe-module-codecoverage:
36+
name: 📊 Silverstripe Code Coverage
37+
uses: syntro-opensource/workflows/.github/workflows/silverstripe-module-codecoverage.yml@master
38+
with:
39+
php_version: 8.3
40+
silverstripe_version: 6.0
41+
silverstripe-phpcs:
42+
name: 🧹 Silverstripe PHPCS
43+
uses: syntro-opensource/workflows/.github/workflows/silverstripe-phpcs.yml@master
44+
with:
45+
dir: src/

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@
99
}
1010
],
1111
"require": {
12-
"php": "^7.4.0 || ^8",
13-
"silverstripe/cms": "^4 || ^5",
14-
"silverstripe/framework": "^4 || ^5",
12+
"php": "^8",
13+
"silverstripe/framework": "^6",
1514
"giggsey/libphonenumber-for-php": "^8.0"
1615
},
1716
"require-dev": {
17+
"silverstripe/cms": "^6",
1818
"squizlabs/php_codesniffer": "^3.0",
19-
"syntro/silverstripe-phpstan": "^1",
20-
"phpunit/phpunit": "^9.4"
19+
"cambis/silverstan": "^2.0",
20+
"phpunit/phpunit": "^11"
2121
},
2222
"keywords": [
2323
"silverstripe",
24-
"silverstripe 4",
2524
"frontend forms"
2625
],
2726
"license": "BSD-3-Clause",
@@ -40,7 +39,7 @@
4039
},
4140
"extra": {
4241
"branch-alias": {
43-
"dev-master": "1.x-dev"
42+
"dev-master": "6.x-dev"
4443
}
4544
},
4645
"config": {

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
includes:
2-
- vendor/syntro/silverstripe-phpstan/phpstan.neon
2+
- vendor/cambis/silverstan/extension.neon

phpunit.xml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11

22
<phpunit
33
bootstrap="vendor/silverstripe/framework/tests/bootstrap.php"
4-
colors="true"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
7-
beStrictAboutChangesToGlobalState="true"
8-
beStrictAboutOutputDuringTests="true"
9-
beStrictAboutTestsThatDoNotTestAnything="true"
10-
beStrictAboutTodoAnnotatedTests="true"
11-
failOnRisky="true"
12-
failOnWarning="true"
4+
colors="true"
5+
backupGlobals="false"
6+
backupStaticProperties="false"
7+
beStrictAboutChangesToGlobalState="true"
8+
beStrictAboutOutputDuringTests="true"
9+
beStrictAboutTestsThatDoNotTestAnything="true"
10+
failOnRisky="true"
11+
failOnWarning="true"
1312
>
1413
<testsuite name="Default">
1514
<directory>tests</directory>
1615
</testsuite>
17-
<coverage>
16+
17+
<source>
1818
<include>
19-
<directory suffix=".php">src</directory>
19+
<directory suffix=".php">./src</directory>
2020
</include>
2121
<exclude>
22-
<directory suffix=".php">vendor/</directory>
22+
<directory suffix=".php">vendor</directory>
23+
<directory suffix=".php">./src/Dev</directory>
2324
</exclude>
24-
</coverage>
25-
</phpunit>
25+
</source>
26+
</phpunit>

src/Dev/FormPage.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@
1111
*/
1212
class FormPage extends SiteTree implements TestOnly
1313
{
14-
14+
/**
15+
* Defines the database table name
16+
* @var string
17+
* @config
18+
*/
19+
private static $table_name = 'FormPage';
1520
}

src/Dev/FormPageController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use SilverStripe\Forms\FieldList;
88
use SilverStripe\Forms\Form;
99
use SilverStripe\Forms\FormAction;
10-
use SilverStripe\Forms\RequiredFields;
10+
use SilverStripe\Forms\Validation\RequiredFieldsValidator;
1111
use Syntro\SilverstripeBootstrapForms\Forms\CheckboxField;
1212
use Syntro\SilverstripeBootstrapForms\Forms\CheckboxSetField;
1313
use Syntro\SilverstripeBootstrapForms\Forms\DropdownField;
@@ -41,7 +41,7 @@ class FormPageController extends ContentController implements TestOnly
4141
*/
4242
public function Form()
4343
{
44-
$fields = new FieldList(
44+
$fields = FieldList::create(
4545
$checkboxfield = CheckboxField::create('checkboxfield', 'checkboxfield'),
4646
$checkboxsetfield = CheckboxSetField::create('checkboxsetfield', 'checkboxsetfield', ['a' => 'value a', 'b' => 'value b']),
4747
$dropdownfield = DropdownField::create('dropdownfield', 'dropdownfield', ['a' => 'value a', 'b' => 'value b']),
@@ -63,9 +63,9 @@ public function Form()
6363
$textareafield->addHolderClass('textareafieldholderclass')->addExtraClass('textareafieldextraclass');
6464
$textfield->addHolderClass('textfieldholderclass')->addExtraClass('textfieldextraclass');
6565

66-
$actions = new FieldList(FormAction::create('submit', 'Submit'));
67-
$required = new RequiredFields('required');
68-
$form = new Form($this, 'Form', $fields, $actions, $required);
66+
$actions = FieldList::create(FormAction::create('submit', 'Submit'));
67+
$required = RequiredFieldsValidator::create(['required']);
68+
$form = Form::create($this, 'Form', $fields, $actions, $required);
6969

7070
return $form;
7171
}

src/Forms/CheckboxField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class CheckboxField extends BackendCheckboxField
2828
/**
2929
* Creates a new field.
3030
*
31-
* @param string $name The internal field name, passed to forms.
32-
* @param null|string|\SilverStripe\View\ViewableData $title The human-readable field label.
33-
* @param mixed $value The value of the field.
31+
* @param string $name The internal field name, passed to forms.
32+
* @param null|string|\SilverStripe\Model\ModelData $title The human-readable field label.
33+
* @param mixed $value The value of the field.
3434
*/
3535
function __construct($name, $title = null, $value = null)
3636
{

src/Forms/TextareaField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class TextareaField extends BackendTextareaField
1818
/**
1919
* Creates a new field.
2020
*
21-
* @param string $name The internal field name, passed to forms.
22-
* @param null|string|\SilverStripe\View\ViewableData $title The human-readable field label.
23-
* @param mixed $value The value of the field.
21+
* @param string $name The internal field name, passed to forms.
22+
* @param null|string|\SilverStripe\Model\ModelData $title The human-readable field label.
23+
* @param mixed $value The value of the field.
2424
*/
2525
function __construct($name, $title = null, $value = null)
2626
{

0 commit comments

Comments
 (0)