Merge "Hard deprecrate Language::viewPrevNext()"
[lhc/web/wiklou.git] / tests / phpunit / includes / Revision / FallbackSlotRoleHandlerTest.php
1 <?php
2
3 namespace MediaWiki\Tests\Revision;
4
5 use MediaWiki\Revision\FallbackSlotRoleHandler;
6 use MediaWikiTestCase;
7 use Title;
8
9 /**
10 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler
11 */
12 class FallbackSlotRoleHandlerTest extends MediaWikiTestCase {
13
14 /**
15 * @return Title
16 */
17 private function makeBlankTitleObject() {
18 return $this->createMock( Title::class );
19 }
20
21 /**
22 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::__construct
23 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getRole()
24 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getNameMessageKey()
25 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getDefaultModel()
26 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::getOutputLayoutHints()
27 */
28 public function testConstruction() {
29 $handler = new FallbackSlotRoleHandler( 'foo' );
30 $this->assertSame( 'foo', $handler->getRole() );
31 $this->assertSame( 'slot-name-foo', $handler->getNameMessageKey() );
32
33 $title = $this->makeBlankTitleObject();
34 $this->assertSame( CONTENT_MODEL_TEXT, $handler->getDefaultModel( $title ) );
35
36 $hints = $handler->getOutputLayoutHints();
37 $this->assertArrayHasKey( 'display', $hints );
38 $this->assertArrayHasKey( 'region', $hints );
39 $this->assertArrayHasKey( 'placement', $hints );
40 }
41
42 /**
43 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::isAllowedModel()
44 */
45 public function testIsAllowedModel() {
46 $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
47
48 // For the fallback handler, no models are allowed
49 $title = $this->makeBlankTitleObject();
50 $this->assertFalse( $handler->isAllowedModel( 'FooModel', $title ) );
51 $this->assertFalse( $handler->isAllowedModel( 'QuaxModel', $title ) );
52 }
53
54 /**
55 * @covers \MediaWiki\Revision\SlotRoleHandler::isAllowedModel()
56 */
57 public function testIsAllowedOn() {
58 $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
59
60 $title = $this->makeBlankTitleObject();
61 $this->assertFalse( $handler->isAllowedOn( $title ) );
62 }
63
64 /**
65 * @covers \MediaWiki\Revision\FallbackSlotRoleHandler::supportsArticleCount()
66 */
67 public function testSupportsArticleCount() {
68 $handler = new FallbackSlotRoleHandler( 'foo', 'FooModel' );
69
70 $this->assertFalse( $handler->supportsArticleCount() );
71 }
72
73 }