-
Notifications
You must be signed in to change notification settings - Fork 0
Make fluent CMS 5 compatible #3
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
10 | ||
18 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
] | ||
} |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,7 +176,7 @@ public function testLocalisedMixSorting() | |
|
||
// Sort by the NonLocalisedSort field first then the LocalisedField second both in ascending order | ||
// so the result will be opposite if the order of the columns is not maintained | ||
$objects=MixedLocalisedSortObject::get()->sort( | ||
$objects=MixedLocalisedSortObject::get()->orderBy( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes errors trying to run sql through |
||
'"FluentExtensionTest_MixedLocalisedSortObject"."LocalizedSort", '. | ||
'"FluentExtensionTest_MixedLocalisedSortObject"."NonLocalizedSort", '. | ||
'"FluentExtensionTest_MixedLocalisedSortObject"."Title"' | ||
|
@@ -289,12 +289,16 @@ public function testLocalisedCopyClassNameChange(): void | |
* @param string[] $expected | ||
* @group exclude-from-travis | ||
*/ | ||
public function testLocalisedFieldsCanBeSorted($locale, array $sortArgs, $expected) | ||
public function testLocalisedFieldsCanBeSorted($locale, array $sortArgs, $expected, $useOrderBy = false) | ||
{ | ||
FluentState::singleton()->withState(function (FluentState $newState) use ($locale, $sortArgs, $expected) { | ||
FluentState::singleton()->withState(function (FluentState $newState) use ($locale, $sortArgs, $expected, $useOrderBy) { | ||
$newState->setLocale($locale); | ||
|
||
$records = LocalisedParent::get()->sort(...$sortArgs); | ||
if ($useOrderBy) { | ||
$records = LocalisedParent::get()->orderBy(...$sortArgs); | ||
} else { | ||
$records = LocalisedParent::get()->sort(...$sortArgs); | ||
} | ||
$titles = $records->column('Title'); | ||
$this->assertEquals($expected, $titles); | ||
}); | ||
|
@@ -411,6 +415,7 @@ public function sortRecordProvider() | |
'en_US', | ||
['CONCAT((SELECT COUNT(*) FROM "FluentExtensionTest_LocalisedParent_Localised"), "FluentExtensionTest_LocalisedParent"."ID")'], | ||
['A record', 'Read about things', 'Go for a run'], | ||
true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one test case needs to be run with |
||
] | ||
]; | ||
} | ||
|
@@ -431,7 +436,7 @@ protected function hasLocalisedRecord(DataObject $record, $locale) | |
'"Locale"' => $locale, | ||
]) | ||
->execute() | ||
->first(); | ||
->record(); | ||
Comment on lines
-434
to
+439
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes this error:
|
||
|
||
return !empty($result); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
use Page; | ||
use SilverStripe\CMS\Forms\SiteTreeURLSegmentField; | ||
use SilverStripe\CMS\Model\SiteTree; | ||
use SilverStripe\Control\Controller; | ||
use SilverStripe\Control\Director; | ||
use SilverStripe\Core\Config\Config; | ||
use SilverStripe\Dev\SapphireTest; | ||
|
@@ -74,8 +75,8 @@ public function testGetLocaleInformation() | |
$this->assertEquals('English (New Zealand)', $result->getTitle()); | ||
$this->assertEquals('English', $result->getLanguageNative()); | ||
$this->assertEquals('en', $result->getLanguage()); | ||
$this->assertEquals('/newzealand/a-page/', $result->getLink()); | ||
$this->assertEquals('http://mocked/newzealand/a-page/', $result->getAbsoluteLink()); | ||
$this->assertEquals(Controller::normaliseTrailingSlash('/newzealand/a-page/'), $result->getLink()); | ||
$this->assertEquals(Controller::normaliseTrailingSlash('http://mocked/newzealand/a-page/'), $result->getAbsoluteLink()); | ||
Comment on lines
-77
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes failures which result from expecting a trailing slash when the default configuration is now to not include one. Doing it this way instead of just removing the trailing slash means the test is robust against this change. The test should be that the URL is correct and should not explicitly care if there's a trailing slash or not. |
||
$this->assertEquals('link', $result->getLinkingMode()); | ||
$this->assertEquals('newzealand', $result->getURLSegment()); | ||
}); | ||
|
@@ -179,7 +180,7 @@ function (FluentState $newState) use ($domain, $locale, $prefixDisabled, $pageNa | |
|
||
/** @var Page|FluentSiteTreeExtension $page */ | ||
$page = $this->objFromFixture(Page::class, $pageName); | ||
$this->assertEquals($url, $page->Link()); | ||
$this->assertEquals(Controller::normaliseTrailingSlash($url), $page->Link()); | ||
} | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace TractorCow\Fluent\Tests\Model; | ||
|
||
use SilverStripe\Control\Controller; | ||
use SilverStripe\Core\Config\Config; | ||
use SilverStripe\Dev\SapphireTest; | ||
use SilverStripe\Forms\CheckboxField; | ||
|
@@ -101,25 +102,25 @@ public function testGetBaseURLContainsDomainAndURLSegmentForNonDefaultLocale() | |
// es_ES has a domain but is not the default locale for that domain | ||
$result = Locale::getByLocale('es_ES')->getBaseURL(); | ||
$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'); | ||
$this->assertStringEndsWith(Controller::normaliseTrailingSlash('/es/'), $result, 'URL segment for non-default locale is in the URL'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
|
||
// Turning off domain mode removes domain but not prefix | ||
FluentState::singleton()->setIsDomainMode(false); | ||
$result = Locale::getByLocale('es_ES')->getBaseURL(); | ||
$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'); | ||
$this->assertStringEndsWith(Controller::normaliseTrailingSlash('/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->assertStringContainsString('/au/', $result); | ||
$this->assertStringEndsWith(Controller::normaliseTrailingSlash('/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->assertStringNotContainsString('/au/', $result); | ||
$this->assertStringEndsNotWith(Controller::normaliseTrailingSlash('/au/'), $result); | ||
} | ||
|
||
public function testGetBaseURLOnlyContainsDomainForPrefixDisabledDefaultLocale() | ||
|
@@ -129,13 +130,13 @@ public function testGetBaseURLOnlyContainsDomainForPrefixDisabledDefaultLocale() | |
// es_US has a domain and is the default | ||
$result = Locale::getByLocale('es_US')->getBaseURL(); | ||
$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'); | ||
$this->assertStringEndsNotWith(Controller::normaliseTrailingSlash('/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->assertStringNotContainsString('fluent.es', $result, "Domain not used"); | ||
$this->assertStringContainsString('/es-usa/', $result, 'URL Segment necessary for non-global default'); | ||
$this->assertStringEndsWith(Controller::normaliseTrailingSlash('/es-usa/'), $result, 'URL Segment necessary for non-global default'); | ||
} | ||
|
||
public function testGetSiblings() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes this error: