mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Add test for URLSegment prefix set to primary subsite domain for page
This commit is contained in:
parent
3b8207d70c
commit
2b26876596
@ -5,10 +5,10 @@ namespace SilverStripe\Subsites\Tests;
|
|||||||
use Page;
|
use Page;
|
||||||
use SilverStripe\CMS\Controllers\CMSMain;
|
use SilverStripe\CMS\Controllers\CMSMain;
|
||||||
use SilverStripe\CMS\Controllers\ModelAsController;
|
use SilverStripe\CMS\Controllers\ModelAsController;
|
||||||
|
use SilverStripe\CMS\Forms\SiteTreeURLSegmentField;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Convert;
|
|
||||||
use SilverStripe\ErrorPage\ErrorPage;
|
use SilverStripe\ErrorPage\ErrorPage;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
@ -21,6 +21,7 @@ use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestClassB;
|
|||||||
use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestErrorPage;
|
use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestErrorPage;
|
||||||
use SilverStripe\Versioned\Versioned;
|
use SilverStripe\Versioned\Versioned;
|
||||||
use SilverStripe\View\SSViewer;
|
use SilverStripe\View\SSViewer;
|
||||||
|
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;
|
||||||
|
|
||||||
class SiteTreeSubsitesTest extends BaseSubsiteTest
|
class SiteTreeSubsitesTest extends BaseSubsiteTest
|
||||||
{
|
{
|
||||||
@ -33,7 +34,9 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected static $illegal_extensions = [
|
protected static $illegal_extensions = [
|
||||||
SiteTree::class => ['Translatable'] // @todo implement Translatable namespace
|
SiteTree::class => [
|
||||||
|
FluentSiteTreeExtension::class,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
@ -449,7 +452,7 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideAlternateAbsoluteLink
|
* @dataProvider provideAlternateAbsoluteLink
|
||||||
* @param name $pageFixtureName
|
* @param string $pageFixtureName
|
||||||
* @param string|null $action
|
* @param string|null $action
|
||||||
* @param string $expectedAbsoluteLink
|
* @param string $expectedAbsoluteLink
|
||||||
*/
|
*/
|
||||||
@ -465,4 +468,23 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
|
|||||||
|
|
||||||
$this->assertEquals($expectedAbsoluteLink, $result);
|
$this->assertEquals($expectedAbsoluteLink, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testURLSegmentBaseIsSetToSubsiteBaseURL()
|
||||||
|
{
|
||||||
|
// This subsite has a domain with 'one.example.org' as the primary domain
|
||||||
|
/** @var Subsite $subsite */
|
||||||
|
$subsite = $this->objFromFixture(Subsite::class, 'domaintest1');
|
||||||
|
Subsite::changeSubsite($subsite);
|
||||||
|
|
||||||
|
$page = new SiteTree();
|
||||||
|
$page->SubsiteID = $subsite->ID;
|
||||||
|
$page->write();
|
||||||
|
$fields = $page->getCMSFields();
|
||||||
|
|
||||||
|
/** @var SiteTreeURLSegmentField $urlSegmentField */
|
||||||
|
$urlSegmentField = $fields->dataFieldByName('URLSegment');
|
||||||
|
$this->assertInstanceOf(SiteTreeURLSegmentField::class, $urlSegmentField);
|
||||||
|
|
||||||
|
$this->assertSame('http://one.example.org/', $urlSegmentField->getURLPrefix());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user