];
}
+ public function tearDown() {
+ MWTimestamp::setFakeTime( false );
+
+ parent::tearDown();
+ }
+
/**
* Test to make sure ParserOutput::isLinkInternal behaves properly
* @dataProvider provideIsLinkInternal
// phpcs:enable
}
+ /**
+ * @covers ParserOutput::hasText
+ */
+ public function testHasText() {
+ $po = new ParserOutput();
+ $this->assertTrue( $po->hasText() );
+
+ $po = new ParserOutput( null );
+ $this->assertFalse( $po->hasText() );
+
+ $po = new ParserOutput( '' );
+ $this->assertTrue( $po->hasText() );
+
+ $po = new ParserOutput( null );
+ $po->setText( '' );
+ $this->assertTrue( $po->hasText() );
+ }
+
+ /**
+ * @covers ParserOutput::getText
+ */
+ public function testGetText_failsIfNoText() {
+ $po = new ParserOutput( null );
+
+ $this->setExpectedException( LogicException::class );
+ $po->getText();
+ }
+
+ /**
+ * @covers ParserOutput::getRawText
+ */
+ public function testGetRawText_failsIfNoText() {
+ $po = new ParserOutput( null );
+
+ $this->setExpectedException( LogicException::class );
+ $po->getRawText();
+ }
+
public function provideMergeHtmlMetaDataFrom() {
// title text ------------
$a = new ParserOutput();
}
}
+ /**
+ * @covers ParserOutput::getCacheTime
+ * @covers ParserOutput::setCacheTime
+ */
+ public function testGetCacheTime() {
+ $clock = MWTimestamp::convert( TS_UNIX, '20100101000000' );
+ MWTimestamp::setFakeTime( function () use ( &$clock ) {
+ return $clock++;
+ } );
+
+ $po = new ParserOutput();
+ $time = $po->getCacheTime();
+
+ // Use current (fake) time per default. Ignore the last digit.
+ // Subsequent calls must yield the exact same timestamp as the first.
+ $this->assertStringStartsWith( '2010010100000', $time );
+ $this->assertSame( $time, $po->getCacheTime() );
+
+ // After setting, the getter must return the time that was set.
+ $time = '20110606112233';
+ $po->setCacheTime( $time );
+ $this->assertSame( $time, $po->getCacheTime() );
+
+ // support -1 as a marker for "not cacheable"
+ $time = -1;
+ $po->setCacheTime( $time );
+ $this->assertSame( $time, $po->getCacheTime() );
+ }
+
}