aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/RequestContextTest.php
diff options
context:
space:
mode:
authorDaniel Friesen <daniel@nadir-seen-fire.com>2012-10-24 07:32:46 -0700
committerDaniel Friesen <daniel@nadir-seen-fire.com>2012-10-24 08:17:27 -0700
commit0b6b78d13a97a43e17c287aaafe6ce64abfe9f91 (patch)
tree81f0259dc1ec447e81fd96f3f46a93d12fc04e72 /tests/phpunit/includes/RequestContextTest.php
parent1fc39609eb8e2eee31fdd49c7bb084557622f61e (diff)
downloadmediawikicore-0b6b78d13a97a43e17c287aaafe6ce64abfe9f91.tar.gz
mediawikicore-0b6b78d13a97a43e17c287aaafe6ce64abfe9f91.zip
It should not be possible for a RequestContext's WikiPage and Title to be different.
Looks like someone messed with RequestContext when I wasn't looking at it. WikiPage is a representation of the Title. It should not be possible for wikipage to point to a different title than the context's title. Fix this issue by unsetting WikiPage when setting title and updating title when setting wikipage. Change-Id: I40471b12d08763cb1b47b8382f96d8db94b4f319
Diffstat (limited to 'tests/phpunit/includes/RequestContextTest.php')
-rw-r--r--tests/phpunit/includes/RequestContextTest.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/phpunit/includes/RequestContextTest.php b/tests/phpunit/includes/RequestContextTest.php
new file mode 100644
index 000000000000..48cf6dc65092
--- /dev/null
+++ b/tests/phpunit/includes/RequestContextTest.php
@@ -0,0 +1,28 @@
+<?php
+
+class RequestContextTest extends MediaWikiTestCase {
+
+ /**
+ * Test the relationship between title and wikipage in RequestContext
+ */
+ public function testWikiPageTitle() {
+ $context = new RequestContext();
+
+ $curTitle = Title::newFromText( "A" );
+ $context->setTitle( $curTitle );
+ $this->assertTrue( $curTitle->equals( $context->getWikiPage()->getTitle() ),
+ "When a title is first set WikiPage should be created on-demand for that title." );
+
+ $curTitle = Title::newFromText( "B" );
+ $context->setWikiPage( WikiPage::factory( $curTitle ) );
+ $this->assertTrue( $curTitle->equals( $context->getTitle() ),
+ "Title must be updated when a new WikiPage is provided." );
+
+ $curTitle = Title::newFromText( "C" );
+ $context->setTitle( $curTitle );
+ $this->assertTrue( $curTitle->equals( $context->getWikiPage()->getTitle() ),
+ "When a title is updated the WikiPage should be purged and recreated on-demand with the new title." );
+
+ }
+
+}