Skip to content

Commit

Permalink
Merge pull request #388 from creative-commoners/pulls/2/no-trailing-s…
Browse files Browse the repository at this point in the history
…lash

MNT Update tests to not expect trailing slash
  • Loading branch information
GuySartorelli authored Jan 20, 2023
2 parents f92a4ab + 0532e30 commit 42a17bd
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit 42a17bd

Please sign in to comment.