Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Update tests to not expect trailing slash #388

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions tests/php/VersionedStateExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ public function testUpdateLinkAddsStageParamsInDraftMode()
Versioned::set_stage(Versioned::DRAFT);
$controller = new VersionedStateExtensionTest\TestController();
$link = $controller->Link('?some=var');
$this->assertEquals('my_controller/?some=var&stage=' . Versioned::DRAFT, $link);
$this->assertEquals('my_controller?some=var&stage=' . Versioned::DRAFT, $link);
}

public function testUpdateLinkAddsStageParamsOnlyOnceInDraftMode()
{
Versioned::set_stage(Versioned::DRAFT);
$controller = new VersionedStateExtensionTest\TestController();
$link = $controller->Link('?some=var&stage=' . Versioned::LIVE);
$this->assertEquals('my_controller/?some=var&stage=' . Versioned::LIVE, $link);
$this->assertEquals('my_controller?some=var&stage=' . Versioned::LIVE, $link);
}

public function testUpdateLinkDoesNotAddStageParamsInLiveMode()
{
Versioned::set_stage(Versioned::LIVE);
$controller = new VersionedStateExtensionTest\TestController();
$link = $controller->Link('?some=var');
$this->assertEquals('my_controller/?some=var', $link);
$this->assertEquals('my_controller?some=var', $link);
}

public function testUpdateLinkRespectsQueryArgs()
Expand All @@ -47,20 +47,20 @@ public function testUpdateLinkRespectsQueryArgs()
$obj2 = new VersionedStateExtensionTest\LinkableObject();
$obj2->URLSegment = 'helloworld';
$obj2->write();
$this->assertEquals('item/helloworld/?stage=Stage', $obj2->Link());
$this->assertEquals('item/helloworld?stage=Stage', $obj2->Link());

// Objects selected in stage also have stage=Stage link
$obj1ID = $this->idFromFixture(VersionedStateExtensionTest\LinkableObject::class, 'object1');
/** @var VersionedStateExtensionTest\LinkableObject $obj1 */
$obj1 = VersionedStateExtensionTest\LinkableObject::get()->byID($obj1ID);
$this->assertEquals('item/myobject/?stage=Stage', $obj1->Link());
$this->assertEquals('item/myobject?stage=Stage', $obj1->Link());

// Selecting live-specific version of this object should NOT have stage=Stage querystring
// This is intentional so we can create cross-stage links
/** @var VersionedStateExtensionTest\LinkableObject $obj1Live */
$obj1Live = Versioned::get_by_stage(VersionedStateExtensionTest\LinkableObject::class, Versioned::LIVE)
->byID($obj1ID);
$this->assertEquals('item/myobject/', $obj1Live->Link());
$this->assertEquals('item/myobject', $obj1Live->Link());
}

public function testDontUpdateLeftAndMainLinks()
Expand Down