Skip to content

Commit

Permalink
Merge pull request #756 from tractorcow-farm/feature/github-workflows
Browse files Browse the repository at this point in the history
NEW: Github workflows setup.
  • Loading branch information
mfendeksilverstripe authored Mar 27, 2022
2 parents 3c78af3 + 4a1f86d commit f630298
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 37 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Module CI

on:
push:
pull_request:

jobs:
ci:
uses: silverstripe/github-actions-ci-cd/.github/workflows/[email protected]
2 changes: 2 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
inherit: true

build:
environment:
php: 8.0
nodes:
analysis:
tests:
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"issues": "http://github.com/tractorcow-farm/silverstripe-fluent/issues"
},
"require": {
"php": "^7.1 || ^8.0",
"php": "^7.1 || ^8",
"silverstripe/vendor-plugin": "^1",
"silverstripe/framework": "^4.7",
"silverstripe/admin": "^1",
Expand All @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Extension/FluentAdminTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 7 additions & 7 deletions tests/php/Extension/FluentBadgeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FluentBadgeExtensionTest extends SapphireTest
*/
protected $extension;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand All @@ -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');
});
}

Expand All @@ -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');
});
}
}
6 changes: 3 additions & 3 deletions tests/php/Extension/FluentDirectorExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FluentDirectorExtensionTest extends FunctionalTest
],
];

public function setUp() // phpcs:ignore SlevomatCodingStandard.TypeHints
protected function setUp(): void
{
parent::setUp();

Expand All @@ -62,7 +62,7 @@ public function testVisitUrlByLocaleWithMultiByteCharacter()

$this->get($page->AbsoluteLink());

$this->assertContains(sprintf('<title>%s', $expectedTitle), $this->content());
$this->assertStringContainsString(sprintf('<title>%s', $expectedTitle), $this->content());
});
}

Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Extension/FluentExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class FluentExtensionTest extends SapphireTest
],
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Extension/FluentFilteredExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FluentFilteredExtensionTest extends SapphireTest
],
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
10 changes: 5 additions & 5 deletions tests/php/Extension/FluentSiteTreeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FluentSiteTreeExtensionTest extends SapphireTest
],
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
Config::modify()
Expand Down Expand Up @@ -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());
});
}

Expand All @@ -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());
});
}

Expand All @@ -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());
});
}

Expand Down Expand Up @@ -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()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Extension/FluentVersionedExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FluentVersionedExtensionTest extends SapphireTest
],
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Middleware/DetectLocaleMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DetectLocaleMiddlewareTest extends SapphireTest
*/
protected $globalDefaultLocale;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->middleware = new Stub\DetectLocaleMiddlewareSpy;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Model/Delete/DeleteRecordPolicyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DeleteRecordPolicyTest extends SapphireTest
FilteredRecord::class,
];

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Model/LocalDateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
22 changes: 11 additions & 11 deletions tests/php/Model/LocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LocaleTest extends SapphireTest
{
protected static $fixture_file = 'LocaleTest.yml';

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit f630298

Please sign in to comment.