diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d29f886..ac36110 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,16 +1,45 @@ name: ๐ŸŽญ Tests on: - - push -env: - DB: MYSQL - PDO: 1 - SS_ENVIRONMENT_TYPE: "dev" - RECIPE_CMS_VERSION: 4.x-dev + push: + paths-ignore: + - .chglog/** + - .github/** + - '!.github/workflows/tests.yml' + - .editorconfig + - .gitattributes + - .gitignore + - .htaccess + - '**.md' + branches: + - 'master' + pull_request: + paths-ignore: + - .chglog/** + - .github/** + - '!.github/workflows/tests.yml' + - .editorconfig + - .gitattributes + - .gitignore + - .htaccess + - '**.md' + branches: + - 'master' + jobs: - silverstripe-module: - name: ๐Ÿงฐ Silverstripe Module Testsuite - uses: syntro-opensource/workflows/.github/workflows/silverstripe-module.yml@master + silverstripe-module-6: + name: ๐Ÿงฐ Silverstripe Module Testsuite 6 + uses: syntro-opensource/workflows/.github/workflows/silverstripe-module-6.yml@master with: phpunit: true phpstan: true - phpcs: true + silverstripe-module-codecoverage: + name: ๐Ÿ“Š Silverstripe Code Coverage + uses: syntro-opensource/workflows/.github/workflows/silverstripe-module-codecoverage.yml@master + with: + php_version: 8.3 + silverstripe_version: 6.0 + silverstripe-phpcs: + name: ๐Ÿงน Silverstripe PHPCS + uses: syntro-opensource/workflows/.github/workflows/silverstripe-phpcs.yml@master + with: + dir: src/ diff --git a/composer.json b/composer.json index 494b260..e8b6e00 100644 --- a/composer.json +++ b/composer.json @@ -9,19 +9,18 @@ } ], "require": { - "php": "^7.4.0 || ^8", - "silverstripe/cms": "^4 || ^5", - "silverstripe/framework": "^4 || ^5", + "php": "^8", + "silverstripe/framework": "^6", "giggsey/libphonenumber-for-php": "^8.0" }, "require-dev": { + "silverstripe/cms": "^6", "squizlabs/php_codesniffer": "^3.0", - "syntro/silverstripe-phpstan": "^1", - "phpunit/phpunit": "^9.4" + "cambis/silverstan": "^2.0", + "phpunit/phpunit": "^11" }, "keywords": [ "silverstripe", - "silverstripe 4", "frontend forms" ], "license": "BSD-3-Clause", @@ -40,7 +39,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "6.x-dev" } }, "config": { diff --git a/phpstan.neon b/phpstan.neon index 7417811..5265314 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,2 +1,2 @@ includes: - - vendor/syntro/silverstripe-phpstan/phpstan.neon + - vendor/cambis/silverstan/extension.neon diff --git a/phpunit.xml b/phpunit.xml index 43e228a..269edf4 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,25 +1,26 @@ tests - + + - src + ./src - vendor/ + vendor + ./src/Dev - - + + \ No newline at end of file diff --git a/src/Dev/FormPage.php b/src/Dev/FormPage.php index 9308524..2513555 100644 --- a/src/Dev/FormPage.php +++ b/src/Dev/FormPage.php @@ -11,5 +11,10 @@ */ class FormPage extends SiteTree implements TestOnly { - + /** + * Defines the database table name + * @var string + * @config + */ + private static $table_name = 'FormPage'; } diff --git a/src/Dev/FormPageController.php b/src/Dev/FormPageController.php index bfb30ef..7111cc8 100644 --- a/src/Dev/FormPageController.php +++ b/src/Dev/FormPageController.php @@ -7,7 +7,7 @@ use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; -use SilverStripe\Forms\RequiredFields; +use SilverStripe\Forms\Validation\RequiredFieldsValidator; use Syntro\SilverstripeBootstrapForms\Forms\CheckboxField; use Syntro\SilverstripeBootstrapForms\Forms\CheckboxSetField; use Syntro\SilverstripeBootstrapForms\Forms\DropdownField; @@ -41,7 +41,7 @@ class FormPageController extends ContentController implements TestOnly */ public function Form() { - $fields = new FieldList( + $fields = FieldList::create( $checkboxfield = CheckboxField::create('checkboxfield', 'checkboxfield'), $checkboxsetfield = CheckboxSetField::create('checkboxsetfield', 'checkboxsetfield', ['a' => 'value a', 'b' => 'value b']), $dropdownfield = DropdownField::create('dropdownfield', 'dropdownfield', ['a' => 'value a', 'b' => 'value b']), @@ -63,9 +63,9 @@ public function Form() $textareafield->addHolderClass('textareafieldholderclass')->addExtraClass('textareafieldextraclass'); $textfield->addHolderClass('textfieldholderclass')->addExtraClass('textfieldextraclass'); - $actions = new FieldList(FormAction::create('submit', 'Submit')); - $required = new RequiredFields('required'); - $form = new Form($this, 'Form', $fields, $actions, $required); + $actions = FieldList::create(FormAction::create('submit', 'Submit')); + $required = RequiredFieldsValidator::create(['required']); + $form = Form::create($this, 'Form', $fields, $actions, $required); return $form; } diff --git a/src/Forms/CheckboxField.php b/src/Forms/CheckboxField.php index 1723ff5..bf1d36d 100644 --- a/src/Forms/CheckboxField.php +++ b/src/Forms/CheckboxField.php @@ -28,9 +28,9 @@ class CheckboxField extends BackendCheckboxField /** * Creates a new field. * - * @param string $name The internal field name, passed to forms. - * @param null|string|\SilverStripe\View\ViewableData $title The human-readable field label. - * @param mixed $value The value of the field. + * @param string $name The internal field name, passed to forms. + * @param null|string|\SilverStripe\Model\ModelData $title The human-readable field label. + * @param mixed $value The value of the field. */ function __construct($name, $title = null, $value = null) { diff --git a/src/Forms/TextareaField.php b/src/Forms/TextareaField.php index 0dbe58c..70c0f9e 100644 --- a/src/Forms/TextareaField.php +++ b/src/Forms/TextareaField.php @@ -18,9 +18,9 @@ class TextareaField extends BackendTextareaField /** * Creates a new field. * - * @param string $name The internal field name, passed to forms. - * @param null|string|\SilverStripe\View\ViewableData $title The human-readable field label. - * @param mixed $value The value of the field. + * @param string $name The internal field name, passed to forms. + * @param null|string|\SilverStripe\Model\ModelData $title The human-readable field label. + * @param mixed $value The value of the field. */ function __construct($name, $title = null, $value = null) {