Skip to content

Commit

Permalink
Add test for URLSegment prefix set to primary subsite domain for page
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed May 31, 2019
1 parent 3b8207d commit 2b26876
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tests/php/SiteTreeSubsitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Page;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Controllers\ModelAsController;
use SilverStripe\CMS\Forms\SiteTreeURLSegmentField;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Director;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\ErrorPage\ErrorPage;
use SilverStripe\Forms\FieldList;
use SilverStripe\Security\Member;
Expand All @@ -21,6 +21,7 @@
use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestErrorPage;
use SilverStripe\Versioned\Versioned;
use SilverStripe\View\SSViewer;
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;

class SiteTreeSubsitesTest extends BaseSubsiteTest
{
Expand All @@ -33,7 +34,9 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
];

protected static $illegal_extensions = [
SiteTree::class => ['Translatable'] // @todo implement Translatable namespace
SiteTree::class => [
FluentSiteTreeExtension::class,
],
];

protected function setUp()
Expand Down Expand Up @@ -449,7 +452,7 @@ public function provideAlternateAbsoluteLink()

/**
* @dataProvider provideAlternateAbsoluteLink
* @param name $pageFixtureName
* @param string $pageFixtureName
* @param string|null $action
* @param string $expectedAbsoluteLink
*/
Expand All @@ -465,4 +468,23 @@ public function testAlternateAbsoluteLink($pageFixtureName, $action, $expectedAb

$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());
}
}

0 comments on commit 2b26876

Please sign in to comment.