Skip to content

Commit

Permalink
Get some more tests working
Browse files Browse the repository at this point in the history
Updating config and i18n calls
  • Loading branch information
wernerkrauss committed May 30, 2017
1 parent 492f437 commit 997459c
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 145 deletions.
4 changes: 0 additions & 4 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ SilverStripe\SiteConfig\SiteConfig:
extensions:
- SilverStripe\Subsites\Extensions\SiteConfigSubsites

SilverStripe\Reports\Report:
extensions:
- SilverStripe\Subsites\SubsiteReportWrapper

SilverStripe\AssetAdmin\Controller\AssetAdmin:
extensions:
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
Expand Down
5 changes: 4 additions & 1 deletion code/extensions/GroupSubsites.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ class GroupSubsites extends DataExtension implements PermissionProvider
*/
public function requireDefaultRecords()
{
if (!$this->owner) {
return;
}
// Migration for Group.SubsiteID data from when Groups only had a single subsite
$schema = $this->owner->getSchema();
$schema = $this->owner::getSchema();
$groupFields = DB::field_list($schema->tableName(Group::class));

// Detection of SubsiteID field is the trigger for old-style-subsiteID migration
Expand Down
4 changes: 2 additions & 2 deletions code/model/Subsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ public static function changeSubsite($subsite)
Session::set('SubsiteID', (int)$subsiteID);

// Set locale
if (is_object($subsite) && $subsite->Language != '') {
$locale = i18n::get_locale_from_lang($subsite->Language);
if (is_object($subsite) && $subsite->Language !== '') {
$locale = (new IntlLocales())->localeFromLang($subsite->Language);
if ($locale) {
i18n::set_locale($locale);
}
Expand Down
6 changes: 3 additions & 3 deletions code/pages/SubsitesVirtualPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ public function getCMSFields()
TextareaField::create(
'CustomMetaKeywords',
$this->fieldLabel('CustomMetaTitle')
)->setDescription(_t('SubsitesVirtualPage.OverrideNote')),
)->setDescription(_t('SubsitesVirtualPage.OverrideNote', 'Overrides inherited value from the source')),
'MetaKeywords'
);
$fields->addFieldToTab(
'Root.Main',
TextareaField::create(
'CustomMetaDescription',
$this->fieldLabel('CustomMetaTitle')
)->setDescription(_t('SubsitesVirtualPage.OverrideNote')),
)->setDescription(_t('SubsitesVirtualPage.OverrideNote', 'Overrides inherited value from the source')),
'MetaDescription'
);
$fields->addFieldToTab(
'Root.Main',
TextField::create(
'CustomExtraMeta',
$this->fieldLabel('CustomMetaTitle')
)->setDescription(_t('SubsitesVirtualPage.OverrideNote')),
)->setDescription(_t('SubsitesVirtualPage.OverrideNote', 'Overrides inherited value from the source')),
'ExtraMeta'
);

Expand Down
4 changes: 2 additions & 2 deletions tests/php/GroupSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class GroupSubsitesTest extends BaseSubsiteTest
protected $requireDefaultRecordsFrom = [GroupSubsites::class];
public function testTrivialFeatures()
{
$this->assertTrue(is_array(singleton('GroupSubsites')->extraStatics()));
$this->assertTrue(is_array(singleton('GroupSubsites')->providePermissions()));
$this->assertTrue(is_array(singleton(GroupSubsites::class)->extraStatics()));
$this->assertTrue(is_array(singleton(GroupSubsites::class)->providePermissions()));
$this->assertTrue(singleton(Group::class)->getCMSFields() instanceof FieldList);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/php/LeftAndMainSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testAccessChecksDontChangeCurrentSubsite()
public function testShouldChangeSubsite()
{
$l = new LeftAndMain();
Config::inst()->nest();
Config::nest();

Config::modify()->set(CMSPageEditController::class, 'treats_subsite_0_as_global', false);
$this->assertTrue($l->shouldChangeSubsite(CMSPageEditController::class, 0, 5));
Expand All @@ -96,6 +96,6 @@ public function testShouldChangeSubsite()
$this->assertTrue($l->shouldChangeSubsite(CMSPageEditController::class, 1, 5));
$this->assertFalse($l->shouldChangeSubsite(CMSPageEditController::class, 1, 1));

Config::inst()->unnest();
Config::unnest();
}
}
1 change: 0 additions & 1 deletion tests/php/SiteConfigSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use SilverStripe\Subsites\Extensions\SiteConfigSubsites;
use SilverStripe\Subsites\Model\Subsite;


class SiteConfigSubsitesTest extends BaseSubsiteTest
{
public static $fixture_file = 'subsites/tests/php/SubsiteTest.yml';
Expand Down
Loading

0 comments on commit 997459c

Please sign in to comment.