diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..c19d6e8c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,9 @@ +name: Module CI + +on: + push: + pull_request: + +jobs: + ci: + uses: silverstripe/github-actions-ci-cd/.github/workflows/ci.yml@0.1.9 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index df3a773f..00000000 --- a/.travis.yml +++ /dev/null @@ -1,46 +0,0 @@ -language: php - -dist: xenial - -services: - - mysql - - postgresql - -addons: - apt: - packages: - - tidy - -matrix: - include: - - php: 7.0 - env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 - - php: 7.1 - env: DB=MYSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_COVERAGE_TEST=1 - - php: 7.2 - env: DB=PGSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 - - php: 7.3 - env: DB=MYSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 - - php: 7.3 - env: DB=MYSQL RECIPE_VERSION=4.6.x-dev PHPUNIT_TEST=1 - - php: 7.4 - env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_TEST=1 - -before_script: - # Init PHP - - phpenv rehash - - phpenv config-rm xdebug.ini - - # Install composer dependencies - - composer validate - - composer require --no-update silverstripe/recipe-cms:"$RECIPE_VERSION" - - if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.x-dev --no-update; fi - - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile - -script: - - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit --exclude-group exclude-from-travis; fi - - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml --exclude-group exclude-from-travis; fi - - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi - -after_success: - - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi diff --git a/composer.json b/composer.json index 36499da4..a8e48fb8 100644 --- a/composer.json +++ b/composer.json @@ -30,14 +30,14 @@ "issues": "http://github.com/tractorcow-farm/silverstripe-fluent/issues" }, "require": { + "php": "^7.3 || ^8.0", "silverstripe/vendor-plugin": "^1", - "silverstripe/framework": "^4", + "silverstripe/framework": "^4.10", "silverstripe/cms": "^4", "symbiote/silverstripe-gridfieldextensions": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^5.7", - "sminnee/phpunit-mock-objects": "^3.4.5", + "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3" }, "extra": { diff --git a/tests/php/Extension/FluentBadgeExtensionTest.php b/tests/php/Extension/FluentBadgeExtensionTest.php index f3c32b75..9ddd94eb 100644 --- a/tests/php/Extension/FluentBadgeExtensionTest.php +++ b/tests/php/Extension/FluentBadgeExtensionTest.php @@ -37,7 +37,7 @@ class FluentBadgeExtensionTest extends SapphireTest */ protected $extension; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -63,9 +63,9 @@ public function testDefaultLocaleBadgeAdded() $result = $this->extension->getBadge($this->mockPage); $this->assertInstanceOf(DBHTMLText::class, $result); - $this->assertContains('fluent-badge--default', $result->getValue()); - $this->assertContains('Default locale', $result->getValue()); - $this->assertContains('NZ', $result->getValue(), 'Badge shows owner locale'); + $this->assertStringContainsString('fluent-badge--default', (string) $result->getValue()); + $this->assertStringContainsString('Default locale', (string) $result->getValue()); + $this->assertStringContainsString('NZ', (string) $result->getValue(), 'Badge shows owner locale'); }); } @@ -77,9 +77,9 @@ public function testInvisibleLocaleBadgeWasAdded() $result = $this->extension->getBadge($this->mockPage); $this->assertInstanceOf(DBHTMLText::class, $result); - $this->assertContains('fluent-badge--invisible', $result->getValue()); - $this->assertContains('is not visible in this locale', $result->getValue()); - $this->assertContains('NZ', $result->getValue(), 'Badge shows owner locale'); + $this->assertStringContainsString('fluent-badge--invisible', (string) $result->getValue()); + $this->assertStringContainsString('is not visible in this locale', (string) $result->getValue()); + $this->assertStringContainsString('NZ', (string) $result->getValue(), 'Badge shows owner locale'); }); } } diff --git a/tests/php/Extension/FluentDirectorExtensionTest.php b/tests/php/Extension/FluentDirectorExtensionTest.php index c659face..424a0bce 100644 --- a/tests/php/Extension/FluentDirectorExtensionTest.php +++ b/tests/php/Extension/FluentDirectorExtensionTest.php @@ -40,7 +40,7 @@ class FluentDirectorExtensionTest extends FunctionalTest ], ]; - public function setUp() // phpcs:ignore SlevomatCodingStandard.TypeHints + protected function setUp(): void // phpcs:ignore SlevomatCodingStandard.TypeHints { parent::setUp(); @@ -62,7 +62,7 @@ public function testVisitUrlByLocaleWithMultiByteCharacter() $this->get($page->AbsoluteLink()); - $this->assertContains(sprintf('%s', $expectedTitle), $this->content()); + $this->assertStringContainsString(sprintf('<title>%s', $expectedTitle), $this->content()); }); } @@ -83,7 +83,7 @@ public function testLocalizedControllerRouting() $this->get(Director::absoluteURL('nouvelle-z%C3%A9lande/TestController')); - $this->assertContains('Test Controller! en_NZ', $this->content()); + $this->assertStringContainsString('Test Controller! en_NZ', $this->content()); } protected function setUpRoutes() diff --git a/tests/php/Extension/FluentExtensionTest.php b/tests/php/Extension/FluentExtensionTest.php index 0604dbd8..e0addd1f 100644 --- a/tests/php/Extension/FluentExtensionTest.php +++ b/tests/php/Extension/FluentExtensionTest.php @@ -34,7 +34,7 @@ class FluentExtensionTest extends SapphireTest ], ]; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/php/Extension/FluentFilteredExtensionTest.php b/tests/php/Extension/FluentFilteredExtensionTest.php index afd5cd12..aebfcbc0 100644 --- a/tests/php/Extension/FluentFilteredExtensionTest.php +++ b/tests/php/Extension/FluentFilteredExtensionTest.php @@ -25,7 +25,7 @@ class FluentFilteredExtensionTest extends SapphireTest ], ]; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/php/Extension/FluentSiteTreeExtensionTest.php b/tests/php/Extension/FluentSiteTreeExtensionTest.php index c5eaa694..ef91578f 100644 --- a/tests/php/Extension/FluentSiteTreeExtensionTest.php +++ b/tests/php/Extension/FluentSiteTreeExtensionTest.php @@ -31,7 +31,7 @@ class FluentSiteTreeExtensionTest extends SapphireTest ], ]; - protected function setUp() + protected function setUp(): void { parent::setUp(); Config::modify() @@ -204,7 +204,7 @@ public function testStatusMessageNotVisible() $statusMessage = $fields->fieldByName('LocaleStatusMessage'); $this->assertNotNull($statusMessage, 'Locale message was not added'); - $this->assertContains('This page will not be visible', $statusMessage->getContent()); + $this->assertStringContainsString('This page will not be visible', $statusMessage->getContent()); }); } @@ -227,7 +227,7 @@ public function testStatusMessageInherited() $statusMessage = $fields->fieldByName('LocaleStatusMessage'); $this->assertNotNull($fields->fieldByName('LocaleStatusMessage')); - $this->assertContains('Content for this page may be inherited', $statusMessage->getContent()); + $this->assertStringContainsString('Content for this page may be inherited', $statusMessage->getContent()); }); } @@ -251,7 +251,7 @@ public function testStatusMessageDrafted() $statusMessage = $fields->fieldByName('LocaleStatusMessage'); $this->assertNotNull($fields->fieldByName('LocaleStatusMessage')); - $this->assertContains('A draft has been created for this locale', $statusMessage->getContent()); + $this->assertStringContainsString('A draft has been created for this locale', $statusMessage->getContent()); }); } @@ -295,7 +295,7 @@ public function testUpdateCMSActionsDrafted() $this->assertEquals('Saved', $actionSave->Title()); // The default value changed between SS 4.0 and 4.1 - assert it contains Publish instead of exact matching - $this->assertContains('publish', strtolower($actionPublish->Title())); + $this->assertStringContainsString('publish', strtolower($actionPublish->Title())); } /** diff --git a/tests/php/Extension/FluentVersionedExtensionTest.php b/tests/php/Extension/FluentVersionedExtensionTest.php index 1740e5d3..3190d04b 100644 --- a/tests/php/Extension/FluentVersionedExtensionTest.php +++ b/tests/php/Extension/FluentVersionedExtensionTest.php @@ -21,7 +21,7 @@ class FluentVersionedExtensionTest extends SapphireTest ], ]; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/php/Middleware/DetectLocaleMiddlewareTest.php b/tests/php/Middleware/DetectLocaleMiddlewareTest.php index 950d242a..6e3658bd 100644 --- a/tests/php/Middleware/DetectLocaleMiddlewareTest.php +++ b/tests/php/Middleware/DetectLocaleMiddlewareTest.php @@ -29,7 +29,7 @@ class DetectLocaleMiddlewareTest extends SapphireTest */ protected $globalDefaultLocale; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->middleware = new Stub\DetectLocaleMiddlewareSpy; diff --git a/tests/php/Model/Delete/DeleteRecordPolicyTest.php b/tests/php/Model/Delete/DeleteRecordPolicyTest.php index 6d862101..eaf07c57 100644 --- a/tests/php/Model/Delete/DeleteRecordPolicyTest.php +++ b/tests/php/Model/Delete/DeleteRecordPolicyTest.php @@ -25,7 +25,7 @@ class DeleteRecordPolicyTest extends SapphireTest FilteredRecord::class, ]; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/php/Model/LocaleTest.php b/tests/php/Model/LocaleTest.php index 16c542ef..068c8227 100644 --- a/tests/php/Model/LocaleTest.php +++ b/tests/php/Model/LocaleTest.php @@ -14,7 +14,7 @@ class LocaleTest extends SapphireTest { protected static $fixture_file = 'LocaleTest.yml'; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -100,26 +100,26 @@ public function testGetBaseURLContainsDomainAndURLSegmentForNonDefaultLocale() { // es_ES has a domain but is not the default locale for that domain $result = Locale::getByLocale('es_ES')->getBaseURL(); - $this->assertContains('fluent.es', $result, "Locale's domain is in the URL"); - $this->assertContains('/es/', $result, 'URL segment for non-default locale is in the URL'); + $this->assertStringContainsString('fluent.es', $result, "Locale's domain is in the URL"); + $this->assertStringContainsString('/es/', $result, 'URL segment for non-default locale is in the URL'); // Turning off domain mode removes domain but not prefix FluentState::singleton()->setIsDomainMode(false); $result = Locale::getByLocale('es_ES')->getBaseURL(); - $this->assertNotContains('fluent.es', $result, "Locale's domain is in the URL"); - $this->assertContains('/es/', $result, 'URL segment for non-default locale is in the URL'); + $this->assertStringNotContainsString('fluent.es', $result, "Locale's domain is in the URL"); + $this->assertStringContainsString('/es/', $result, 'URL segment for non-default locale is in the URL'); } public function testBaseURLPrefixDisabled() { // Default base url includes the default url segment $result = Locale::getDefault()->getBaseURL(); - $this->assertContains('/au/', $result); + $this->assertStringContainsString('/au/', $result); // Default base url shortens the default locale url base by excluding the locale's url segment Config::inst()->set(FluentDirectorExtension::class, 'disable_default_prefix', true); $result = Locale::getDefault()->getBaseURL(); - $this->assertNotContains('/au/', $result); + $this->assertStringNotContainsString('/au/', $result); } public function testGetBaseURLOnlyContainsDomainForPrefixDisabledDefaultLocale() @@ -128,14 +128,14 @@ public function testGetBaseURLOnlyContainsDomainForPrefixDisabledDefaultLocale() // es_US has a domain and is the default $result = Locale::getByLocale('es_US')->getBaseURL(); - $this->assertContains('fluent.es', $result, "Locale's domain is in the URL"); - $this->assertNotContains('/es-usa/', $result, 'URL segment is not in the URL for default locales'); + $this->assertStringContainsString('fluent.es', $result, "Locale's domain is in the URL"); + $this->assertStringNotContainsString('/es-usa/', $result, 'URL segment is not in the URL for default locales'); // When domain mode is turned off, prefix is now necessary FluentState::singleton()->setIsDomainMode(false); $result = Locale::getByLocale('es_US')->getBaseURL(); - $this->assertNotContains('fluent.es', $result, "Domain not used"); - $this->assertContains('/es-usa/', $result, 'URL Segment necessary for non-global default'); + $this->assertStringNotContainsString('fluent.es', $result, "Domain not used"); + $this->assertStringContainsString('/es-usa/', $result, 'URL Segment necessary for non-global default'); } public function testGetSiblings()