diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 826f9e4..61cf37f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,6 @@ on: - .htaccess - '**.md' branches: - - develop - master pull_request: paths-ignore: @@ -24,94 +23,25 @@ on: - .htaccess - '**.md' branches: - - develop - master -env: - DB: MYSQL - PDO: 1 - SS_ENVIRONMENT_TYPE: "dev" - RECIPE_CMS_VERSION: 4.x-dev + jobs: - phpunit: - name: 🧩 PHPUnit - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php: - - 7.3 - - 7.4 - container: brettt89/silverstripe-web:${{ matrix.php }}-apache - services: - database: - image: mysql:5.7 - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - env: - SS_DEFAULT_ADMIN_USERNAME: admin - SS_DEFAULT_ADMIN_PASSWORD: admin - SS_DATABASE_SERVER: database - SS_DATABASE_NAME: ss_default_${{ matrix.php }} - SS_DATABASE_USERNAME: root - SS_DATABASE_PASSWORD: '' - SS_ENVIRONMENT_TYPE: dev - steps: - - name: Install Composer - run: | - curl \ - -sS https://getcomposer.org/installer \ - | php && \ - mv -f composer.phar /usr/local/bin/composer - - name: Checkout code - uses: actions/checkout@v2 - - name: install dependencies - run: | - composer require --no-update silverstripe/recipe-cms:$RECIPE_CMS_VERSION &&\ - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile - - name: run phpunit - run: vendor/bin/phpunit -c "phpunit.xml" tests/ - - name: generate coverage - run: phpdbg -qrr vendor/bin/phpunit -dmemory_limit=512M --coverage-clover=coverage.xml tests/ - if: ${{ matrix.php == '7.4' }} - - name: submit coverage - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.xml - if: ${{ matrix.php == '7.4' }} - phpstan: - name: 🔺 PHPStan - runs-on: ubuntu-latest - container: brettt89/silverstripe-web:7.4-apache - steps: - - name: Install Composer - run: | - curl \ - -sS https://getcomposer.org/installer \ - | php && \ - mv -f composer.phar /usr/local/bin/composer - - name: Checkout code - uses: actions/checkout@v2 - - name: install dependencies - run: | - composer require --no-update silverstripe/recipe-cms:$RECIPE_CMS_VERSION &&\ - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile - - name: run phpstan - run: vendor/bin/phpstan analyse src/ -c "phpstan.neon" -a vendor/symbiote/silverstripe-phpstan/bootstrap.php --level 4 - phpcs: - name: 🔮 PHPcs - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: lint source - uses: chindit/actions-phpcs@master - with: - dir: src/ - - name: lint tests - uses: chindit/actions-phpcs@master - with: - dir: tests/ + silverstripe-module: + name: 🧰 Silverstripe Module Testsuite + uses: syntro-opensource/workflows/.github/workflows/silverstripe-module.yml@master + with: + phpunit: true + phpstan: true + phpcs: true + # silverstripe-client: + # name: 📦 Client Testsuite + # uses: syntro-opensource/workflows/.github/workflows/client.yml@master + # with: + # eslint: true + # eslint_dir: client/src/seo-field/ + # eslint_configfile: client/src/seo-field/.eslintrc + # eslint_ext: + # eslint_max-warnings: + # stylelint: true + # stylelint_glob: client/src/seo-field/**/*.scss + # stylelint_max-warnings: diff --git a/composer.json b/composer.json index cfac327..03b9f53 100644 --- a/composer.json +++ b/composer.json @@ -14,9 +14,8 @@ }, "require-dev": { "squizlabs/php_codesniffer": "^3.0", - "symbiote/silverstripe-phpstan": "^4", - "phpstan/phpstan-shim": "~0.11.0", - "phpunit/phpunit": "^5.7" + "syntro/silverstripe-phpstan": "^1", + "phpunit/phpunit": "^9.5" }, "keywords": [ "silverstripe metadata", @@ -39,6 +38,13 @@ "phpunit": "../../bin/phpunit", "phpunit-flush": "../../bin/phpunit . '' flush=1" }, + "config": { + "allow-plugins": { + "composer/installers": true, + "silverstripe/vendor-plugin": true, + "silverstripe/recipe-plugin": true + } + }, "minimum-stability": "dev", "prefer-stable": true } diff --git a/phpstan-dev.neon b/phpstan-dev.neon index 5fecaf9..f166109 100644 --- a/phpstan-dev.neon +++ b/phpstan-dev.neon @@ -1,6 +1,2 @@ -parameters: - autoload_directories: - - src - - tests/php includes: - - ../../symbiote/silverstripe-phpstan/phpstan.neon + - ../../syntro/silverstripe-phpstan/phpstan.neon diff --git a/phpstan.neon b/phpstan.neon index 1f31f5c..7417811 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,2 @@ -parameters: - autoload_directories: - - src - - tests/php includes: - - vendor/symbiote/silverstripe-phpstan/phpstan.neon + - vendor/syntro/silverstripe-phpstan/phpstan.neon diff --git a/phpunit.xml b/phpunit.xml index cc2592b..4b5e9f0 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,26 +1,26 @@ + tests/php - - + + vendor/ - - - - src - - + + + src + + diff --git a/src/Dev/TestDataObject.php b/src/Dev/TestDataObject.php index cff9cb7..7f9520e 100644 --- a/src/Dev/TestDataObject.php +++ b/src/Dev/TestDataObject.php @@ -13,8 +13,14 @@ */ class SharedObject extends DataObject implements TestOnly { - + /** + * @config + */ private static $sharing_allow_user_overwrite = true; + + /** + * @config + */ private static $sharing_fallback_description = [ 'Description', 'getDefaultDescription' @@ -22,6 +28,7 @@ class SharedObject extends DataObject implements TestOnly /** * Database fields + * @config * @var array */ private static $db = [ @@ -32,6 +39,7 @@ class SharedObject extends DataObject implements TestOnly /** * Defines extension names and parameters to be applied * to this object upon construction. + * @config * @var array */ private static $extensions = [ diff --git a/src/Extension/ShareExtension.php b/src/Extension/ShareExtension.php index 032e6e9..410836a 100644 --- a/src/Extension/ShareExtension.php +++ b/src/Extension/ShareExtension.php @@ -56,6 +56,7 @@ class ShareExtension extends DataExtension implements SharingMetaSource /** * Database fields + * @config * @var array */ private static $db = [ @@ -67,6 +68,7 @@ class ShareExtension extends DataExtension implements SharingMetaSource /** * Has_one relationship + * @config * @var array */ private static $has_one = [ @@ -75,6 +77,7 @@ class ShareExtension extends DataExtension implements SharingMetaSource /** * Relationship version ownership + * @config * @var array */ private static $owns = [ @@ -83,6 +86,7 @@ class ShareExtension extends DataExtension implements SharingMetaSource /** * Add default values to database + * @config * @var array */ private static $defaults = [ @@ -92,6 +96,7 @@ class ShareExtension extends DataExtension implements SharingMetaSource /** * fields to be translated by fluent + * @config * @var array */ private static $field_include = [ @@ -101,6 +106,7 @@ class ShareExtension extends DataExtension implements SharingMetaSource /** * fields to be ignored by fluent + * @config * @var array */ private static $field_exclude = [ @@ -323,14 +329,14 @@ public function getFallbackDescription() if ($fallbackField && is_array($fallbackField)) { foreach ($fallbackField as $field) { $string = $this->getDescriptionFromField($field); - if ($string && $string != '') { + if ($string) { return $string; } } } elseif ($fallbackField) { // return (string) $owner->obj($fallbackField); $string = $this->getDescriptionFromField($fallbackField); - if ($string && $string != '') { + if ($string) { return $string; } } diff --git a/src/Extension/ShareSiteConfigExtension.php b/src/Extension/ShareSiteConfigExtension.php index 9a5edb3..f062eb5 100644 --- a/src/Extension/ShareSiteConfigExtension.php +++ b/src/Extension/ShareSiteConfigExtension.php @@ -16,6 +16,7 @@ class ShareSiteConfigExtension extends DataExtension { /** * Database fields + * @config * @var array */ private static $db = [ @@ -24,6 +25,7 @@ class ShareSiteConfigExtension extends DataExtension /** * Has_one relationship + * @config * @var array */ private static $has_one = [ @@ -32,6 +34,7 @@ class ShareSiteConfigExtension extends DataExtension /** * Relationship version ownership + * @config * @var array */ private static $owns = [ @@ -40,6 +43,7 @@ class ShareSiteConfigExtension extends DataExtension /** * fields to be ignored by fluent + * @config * @var array */ private static $field_exclude = [ diff --git a/tests/php/ShareMetadataPageExtensionTest.php b/tests/php/ShareMetadataPageExtensionTest.php index 2399fa0..81bae6b 100644 --- a/tests/php/ShareMetadataPageExtensionTest.php +++ b/tests/php/ShareMetadataPageExtensionTest.php @@ -25,7 +25,7 @@ class ShareMetadataPageExtensionTest extends SapphireTest * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $config = DataObject::get_one(SiteConfig::class); diff --git a/tests/php/ShareSiteConfigExtensionTest.php b/tests/php/ShareSiteConfigExtensionTest.php index 3ed0b77..8e2cae7 100644 --- a/tests/php/ShareSiteConfigExtensionTest.php +++ b/tests/php/ShareSiteConfigExtensionTest.php @@ -26,7 +26,7 @@ class ShareSiteConfigExtensionTest extends SapphireTest * * @return void */ - public function setUp() + public function setUp(): void { parent::setUp(); $config = DataObject::get_one(SiteConfig::class);