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