From 182c95e4da1cf932d53270c35fb243cda141a979 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Thu, 24 Mar 2022 16:50:39 +1300 Subject: [PATCH 1/5] NEW: Github workflows setup. --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3fc1da08 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,9 @@ +name: Module CI + +on: + push: + pull_request: + +jobs: + ci: + uses: silverstripe/github-actions-ci-cd/.github/workflows/ci.yml@v0.1 From 56337af2373ea141cba679fd53dc6e5677454f43 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Fri, 25 Mar 2022 13:39:20 +1300 Subject: [PATCH 2/5] BUG: PHP 8 compatibility patch. --- composer.json | 5 ++--- tests/php/Extension/FluentAdminTraitTest.php | 4 ++-- tests/php/Extension/FluentBadgeExtensionTest.php | 2 +- tests/php/Extension/FluentDirectorExtensionTest.php | 2 +- tests/php/Extension/FluentExtensionTest.php | 2 +- tests/php/Extension/FluentFilteredExtensionTest.php | 2 +- tests/php/Extension/FluentSiteTreeExtensionTest.php | 2 +- tests/php/Extension/FluentVersionedExtensionTest.php | 2 +- tests/php/Middleware/DetectLocaleMiddlewareTest.php | 2 +- tests/php/Model/Delete/DeleteRecordPolicyTest.php | 2 +- tests/php/Model/LocalDateTimeTest.php | 2 +- tests/php/Model/LocaleTest.php | 2 +- 12 files changed, 14 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 0e91bad7..02fe039f 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "issues": "http://github.com/tractorcow-farm/silverstripe-fluent/issues" }, "require": { - "php": "^7.1 || ^8.0", + "php": "^7.4 || ^8", "silverstripe/vendor-plugin": "^1", "silverstripe/framework": "^4.7", "silverstripe/admin": "^1", @@ -42,8 +42,7 @@ "silverstripe/cms": "Localise pages" }, "require-dev": { - "sminnee/phpunit": "^5.7", - "squizlabs/php_codesniffer": "^3" + "silverstripe/recipe-testing": "^1 || ^2" }, "extra": { "branch-alias": { diff --git a/tests/php/Extension/FluentAdminTraitTest.php b/tests/php/Extension/FluentAdminTraitTest.php index 6b5ffe4e..f7243293 100644 --- a/tests/php/Extension/FluentAdminTraitTest.php +++ b/tests/php/Extension/FluentAdminTraitTest.php @@ -38,14 +38,14 @@ class FluentAdminTraitTest extends SapphireTest /** * @throws ValidationException */ - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpTestModels(); $this->reset(); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); $this->reset(); diff --git a/tests/php/Extension/FluentBadgeExtensionTest.php b/tests/php/Extension/FluentBadgeExtensionTest.php index 05f2d8da..d9ee95a0 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(); diff --git a/tests/php/Extension/FluentDirectorExtensionTest.php b/tests/php/Extension/FluentDirectorExtensionTest.php index c659face..046e4d07 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 { parent::setUp(); diff --git a/tests/php/Extension/FluentExtensionTest.php b/tests/php/Extension/FluentExtensionTest.php index 86df7837..11ab1f88 100644 --- a/tests/php/Extension/FluentExtensionTest.php +++ b/tests/php/Extension/FluentExtensionTest.php @@ -40,7 +40,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 509656fc..17b5eacf 100644 --- a/tests/php/Extension/FluentFilteredExtensionTest.php +++ b/tests/php/Extension/FluentFilteredExtensionTest.php @@ -27,7 +27,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 a949f024..ff37b1e9 100644 --- a/tests/php/Extension/FluentSiteTreeExtensionTest.php +++ b/tests/php/Extension/FluentSiteTreeExtensionTest.php @@ -39,7 +39,7 @@ class FluentSiteTreeExtensionTest extends SapphireTest ], ]; - protected function setUp() + protected function setUp(): void { parent::setUp(); Config::modify() diff --git a/tests/php/Extension/FluentVersionedExtensionTest.php b/tests/php/Extension/FluentVersionedExtensionTest.php index b84a7dbf..44e97905 100644 --- a/tests/php/Extension/FluentVersionedExtensionTest.php +++ b/tests/php/Extension/FluentVersionedExtensionTest.php @@ -22,7 +22,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 1c80ffff..bf1f4e6c 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/LocalDateTimeTest.php b/tests/php/Model/LocalDateTimeTest.php index a25585c0..db2448cb 100644 --- a/tests/php/Model/LocalDateTimeTest.php +++ b/tests/php/Model/LocalDateTimeTest.php @@ -15,7 +15,7 @@ class LocalDateTimeTest extends SapphireTest { protected static $fixture_file = 'LocaleTest.yml'; - public function setUp() + protected function setUp(): void { // SapphireTest SetUp() sets timezone to UTC parent::setUp(); diff --git a/tests/php/Model/LocaleTest.php b/tests/php/Model/LocaleTest.php index 16c542ef..015b897c 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() + protected function setUp(): void { parent::setUp(); From bf37abbb7fcde233ce9dec387ecec0a970b97e31 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Fri, 25 Mar 2022 14:00:15 +1300 Subject: [PATCH 3/5] Fixes. --- .../Extension/FluentBadgeExtensionTest.php | 12 +++++------ .../Extension/FluentDirectorExtensionTest.php | 4 ++-- .../Extension/FluentSiteTreeExtensionTest.php | 8 ++++---- tests/php/Model/LocaleTest.php | 20 +++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/php/Extension/FluentBadgeExtensionTest.php b/tests/php/Extension/FluentBadgeExtensionTest.php index d9ee95a0..be43a165 100644 --- a/tests/php/Extension/FluentBadgeExtensionTest.php +++ b/tests/php/Extension/FluentBadgeExtensionTest.php @@ -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('Localised in', $result->getValue()); - $this->assertContains('NZ', $result->getValue(), 'Badge shows owner locale'); + $this->assertStringContainsString('fluent-badge--default', $result->getValue()); + $this->assertStringContainsString('Localised in', $result->getValue()); + $this->assertStringContainsString('NZ', $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('Page has no available content in', $result->getValue()); - $this->assertContains('de_DE', $result->getValue(), 'Badge shows owner locale'); + $this->assertStringContainsString('fluent-badge--invisible', $result->getValue()); + $this->assertStringContainsString('Page has no available content in', $result->getValue()); + $this->assertStringContainsString('de_DE', $result->getValue(), 'Badge shows owner locale'); }); } } diff --git a/tests/php/Extension/FluentDirectorExtensionTest.php b/tests/php/Extension/FluentDirectorExtensionTest.php index 046e4d07..f6f2a136 100644 --- a/tests/php/Extension/FluentDirectorExtensionTest.php +++ b/tests/php/Extension/FluentDirectorExtensionTest.php @@ -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/FluentSiteTreeExtensionTest.php b/tests/php/Extension/FluentSiteTreeExtensionTest.php index ff37b1e9..fb689bc6 100644 --- a/tests/php/Extension/FluentSiteTreeExtensionTest.php +++ b/tests/php/Extension/FluentSiteTreeExtensionTest.php @@ -212,7 +212,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()); }); } @@ -235,7 +235,7 @@ public function testStatusMessageUnknown() $statusMessage = $fields->fieldByName('LocaleStatusMessage'); $this->assertNotNull($fields->fieldByName('LocaleStatusMessage')); - $this->assertContains('No content is available for this page', $statusMessage->getContent()); + $this->assertStringContainsString('No content is available for this page', $statusMessage->getContent()); }); } @@ -259,7 +259,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()); }); } @@ -305,7 +305,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/Model/LocaleTest.php b/tests/php/Model/LocaleTest.php index 015b897c..a3d9345f 100644 --- a/tests/php/Model/LocaleTest.php +++ b/tests/php/Model/LocaleTest.php @@ -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() From bb46d9d2c50c31d8fc03b812129b0aa135ab033f Mon Sep 17 00:00:00 2001 From: Mojmir Fendek <mfendek@silverstripe.com> Date: Fri, 25 Mar 2022 14:57:00 +1300 Subject: [PATCH 4/5] Lowering minimum PHP version to see if we can support it. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 02fe039f..f0bd5a00 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "issues": "http://github.com/tractorcow-farm/silverstripe-fluent/issues" }, "require": { - "php": "^7.4 || ^8", + "php": "^7.1 || ^8", "silverstripe/vendor-plugin": "^1", "silverstripe/framework": "^4.7", "silverstripe/admin": "^1", From 4a1f86db6324412ff73bcfde0586e019edfd37bb Mon Sep 17 00:00:00 2001 From: Mojmir Fendek <mfendek@silverstripe.com> Date: Mon, 28 Mar 2022 08:10:53 +1300 Subject: [PATCH 5/5] BUG: Explicit PHP version for scrutinizer.. --- .scrutinizer.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 4625fbfe..1047887b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,6 +1,8 @@ inherit: true build: + environment: + php: 8.0 nodes: analysis: tests: