+ * @covers OutputPage::addScriptFile
+ */
+ public function testAddDeprecatedScriptFileNoOp() {
+ $op = $this->newInstance();
+ $op->addScriptFile( 'ignored-script.js' );
+
+ $this->assertNotContains( 'ignored-script.js', '' . $op->getBottomScripts() );
+ }
+
+ /**
+ * @covers OutputPage::addInlineScript
+ */
+ public function testAddInlineScript() {
+ $op = $this->newInstance();
+ $op->addInlineScript( 'let foo = "bar";' );
+ $op->addInlineScript( 'alert( foo );' );
+
+ $this->assertContains(
+ "\n" . Html::inlineScript( "\nlet foo = \"bar\";\n", $op->getCSPNonce() ) . "\n" .
+ Html::inlineScript( "\nalert( foo );\n", $op->getCSPNonce() ) . "\n",
+ "\n" . $op->getBottomScripts() . "\n"
+ );
+ }
+
+ // @todo How to test filterModules(), warnModuleTargetFilter(), getModules(), etc.?
+
+ /**
+ * @covers OutputPage::getTarget
+ * @covers OutputPage::setTarget
+ */
+ public function testSetTarget() {
+ $op = $this->newInstance();
+ $op->setTarget( 'foo' );
+
+ $this->assertSame( 'foo', $op->getTarget() );
+ // @todo What else? Test some actual effect?
+ }
+
+ // @todo How to test addContentOverride(Callback)?
+
+ /**
+ * @covers OutputPage::getHeadItemsArray
+ * @covers OutputPage::addHeadItem
+ * @covers OutputPage::addHeadItems
+ * @covers OutputPage::hasHeadItem
+ */
+ public function testHeadItems() {
+ $op = $this->newInstance();
+ $op->addHeadItem( 'a', 'b' );
+ $op->addHeadItems( [ 'c' => '<d>&', 'e' => 'f', 'a' => 'q' ] );
+ $op->addHeadItem( 'e', 'g' );
+ $op->addHeadItems( 'x' );
+
+ $this->assertSame( [ 'a' => 'q', 'c' => '<d>&', 'e' => 'g', 'x' ],
+ $op->getHeadItemsArray() );
+
+ $this->assertTrue( $op->hasHeadItem( 'a' ) );
+ $this->assertTrue( $op->hasHeadItem( 'c' ) );
+ $this->assertTrue( $op->hasHeadItem( 'e' ) );
+ $this->assertTrue( $op->hasHeadItem( '0' ) );
+
+ $this->assertContains( "\nq\n<d>&\ng\nx\n",
+ '' . $op->headElement( $op->getContext()->getSkin() ) );
+ }
+
+ /**
+ * @covers OutputPage::addBodyClasses
+ */
+ public function testAddBodyClasses() {
+ $op = $this->newInstance();
+ $op->addBodyClasses( 'a' );
+ $op->addBodyClasses( 'mediawiki' );
+ $op->addBodyClasses( 'b c' );
+ $op->addBodyClasses( [ 'd', 'e' ] );
+ $op->addBodyClasses( 'a' );
+
+ $this->assertContains( '"a mediawiki b c d e ltr',
+ '' . $op->headElement( $op->getContext()->getSkin() ) );
+ }
+
+ /**
+ * @covers OutputPage::setArticleBodyOnly
+ * @covers OutputPage::getArticleBodyOnly
+ */
+ public function testArticleBodyOnly() {
+ $op = $this->newInstance();
+ $this->assertFalse( $op->getArticleBodyOnly() );
+
+ $op->setArticleBodyOnly( true );
+ $this->assertTrue( $op->getArticleBodyOnly() );
+
+ $op->addHTML( '<b>a</b>' );
+
+ $this->assertSame( '<b>a</b>', $op->output( true ) );
+ }
+
+ /**
+ * @covers OutputPage::setProperty
+ * @covers OutputPage::getProperty
+ */
+ public function testProperties() {
+ $op = $this->newInstance();
+
+ $this->assertNull( $op->getProperty( 'foo' ) );
+
+ $op->setProperty( 'foo', 'bar' );
+ $op->setProperty( 'baz', 'quz' );
+
+ $this->assertSame( 'bar', $op->getProperty( 'foo' ) );
+ $this->assertSame( 'quz', $op->getProperty( 'baz' ) );
+ }
+
+ /**
+ * @dataProvider provideCheckLastModified