2019-11-07 09:05:14 +00:00
|
|
|
<?php
|
|
|
|
|
2019-11-12 10:45:13 +00:00
|
|
|
namespace Cite\Tests;
|
|
|
|
|
2019-11-19 14:12:11 +00:00
|
|
|
use Cite\Cite;
|
2019-11-19 10:29:33 +00:00
|
|
|
use Language;
|
2019-11-12 10:45:13 +00:00
|
|
|
use Parser;
|
2019-11-19 10:29:33 +00:00
|
|
|
use ParserOptions;
|
2019-11-12 10:45:13 +00:00
|
|
|
use ParserOutput;
|
|
|
|
use StripState;
|
2019-11-07 09:05:14 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-19 14:12:11 +00:00
|
|
|
* @coversDefaultClass \Cite\Cite
|
2019-11-19 10:31:08 +00:00
|
|
|
*
|
|
|
|
* @license GPL-2.0-or-later
|
2019-11-07 09:05:14 +00:00
|
|
|
*/
|
2019-11-12 10:45:13 +00:00
|
|
|
class CiteTest extends \MediaWikiIntegrationTestCase {
|
2019-11-07 09:05:14 +00:00
|
|
|
|
|
|
|
protected function setUp() : void {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->setMwGlobals( [
|
2019-11-07 12:14:05 +00:00
|
|
|
'wgCiteBookReferencing' => true,
|
2019-11-07 09:05:14 +00:00
|
|
|
] );
|
|
|
|
}
|
|
|
|
|
2019-11-08 11:59:09 +00:00
|
|
|
/**
|
2019-11-12 10:45:13 +00:00
|
|
|
* @covers ::guardedRef
|
2019-11-08 11:59:09 +00:00
|
|
|
*/
|
2019-11-08 14:46:52 +00:00
|
|
|
public function testBookExtendsPageProperty() {
|
2019-11-08 11:59:09 +00:00
|
|
|
$mockOutput = $this->createMock( ParserOutput::class );
|
2019-11-12 12:06:39 +00:00
|
|
|
$mockOutput->expects( $this->once() )
|
|
|
|
->method( 'setProperty' )
|
|
|
|
->with( Cite::BOOK_REF_PROPERTY, true );
|
|
|
|
|
2019-11-19 10:29:33 +00:00
|
|
|
$parserOptions = $this->createMock( ParserOptions::class );
|
|
|
|
$parserOptions->method( 'getUserLangObj' )
|
|
|
|
->willReturn( $this->createMock( Language::class ) );
|
|
|
|
|
2019-11-08 11:59:09 +00:00
|
|
|
$mockParser = $this->createMock( Parser::class );
|
2019-11-28 10:15:19 +00:00
|
|
|
$mockParser->method( 'recursiveTagParse' )
|
|
|
|
->willReturn( '' );
|
2019-11-19 10:29:33 +00:00
|
|
|
$mockParser->method( 'getOptions' )
|
|
|
|
->willReturn( $parserOptions );
|
2019-11-08 11:59:09 +00:00
|
|
|
$mockParser->method( 'getOutput' )
|
|
|
|
->willReturn( $mockOutput );
|
2019-11-04 16:16:07 +00:00
|
|
|
$mockParser->method( 'getStripState' )
|
|
|
|
->willReturn( $this->createMock( StripState::class ) );
|
2019-11-08 11:59:09 +00:00
|
|
|
|
|
|
|
$cite = new Cite();
|
2019-11-12 12:06:39 +00:00
|
|
|
$cite->ref( 'contentA', [ 'name' => 'a' ], $mockParser );
|
|
|
|
$cite->ref( 'contentB', [ Cite::BOOK_REF_ATTRIBUTE => 'a' ], $mockParser );
|
2019-11-08 11:59:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 09:05:14 +00:00
|
|
|
}
|