1 | <?php |
||
16 | class PageDisplayOutputModifierTest extends \PHPUnit_Framework_TestCase { |
||
17 | |||
18 | public function testCanConstruct() { |
||
19 | |||
20 | $this->assertInstanceOf( |
||
21 | '\SBL\PageDisplayOutputModifier', |
||
22 | new PageDisplayOutputModifier() |
||
23 | ); |
||
24 | } |
||
25 | |||
26 | public function testDisabledHideSubpageParentForTitleManipulation() { |
||
27 | |||
28 | $instance = new PageDisplayOutputModifier(); |
||
29 | $instance->hideSubpageParent( false ); |
||
30 | $instance->setSubpageByNamespace( [ NS_MAIN => true ] ); |
||
31 | |||
32 | $output = $this->getMockBuilder( '\OutputPage' ) |
||
33 | ->disableOriginalConstructor() |
||
34 | ->getMock(); |
||
35 | |||
36 | $output->expects( $this->atLeastOnce() ) |
||
37 | ->method( 'getTitle' ); |
||
38 | |||
39 | $instance->modifyOutput( $output ); |
||
40 | } |
||
41 | |||
42 | public function testDisabledSubpageNamespaceForTitleManipulation() { |
||
43 | |||
44 | $instance = new PageDisplayOutputModifier(); |
||
45 | $instance->hideSubpageParent( true ); |
||
46 | $instance->setSubpageByNamespace( [ NS_MAIN => false ] ); |
||
47 | |||
48 | $title = $this->getMockBuilder( '\Title' ) |
||
49 | ->disableOriginalConstructor() |
||
50 | ->getMock(); |
||
51 | |||
52 | $title->expects( $this->once() ) |
||
53 | ->method( 'getNamespace' ) |
||
54 | ->will( $this->returnValue( NS_MAIN ) ); |
||
55 | |||
56 | $output = $this->getMockBuilder( '\OutputPage' ) |
||
57 | ->disableOriginalConstructor() |
||
58 | ->getMock(); |
||
59 | |||
60 | $output->expects( $this->atLeastOnce() ) |
||
61 | ->method( 'getTitle' ) |
||
62 | ->will( $this->returnValue( $title ) ); |
||
63 | |||
64 | $instance->modifyOutput( $output ); |
||
65 | } |
||
66 | |||
67 | public function testEnabledSubpageForTitleManipulation() { |
||
68 | |||
69 | $instance = new PageDisplayOutputModifier(); |
||
70 | $instance->hideSubpageParent( true ); |
||
71 | $instance->setSubpageByNamespace( [ NS_MAIN => true ] ); |
||
72 | |||
73 | $title = $this->getMockBuilder( '\Title' ) |
||
74 | ->disableOriginalConstructor() |
||
75 | ->getMock(); |
||
76 | |||
77 | $title->expects( $this->once() ) |
||
78 | ->method( 'isSubpage' ) |
||
79 | ->will( $this->returnValue( true ) ); |
||
80 | |||
81 | $title->expects( $this->atLeastOnce() ) |
||
82 | ->method( 'getNamespace' ) |
||
83 | ->will( $this->returnValue( NS_MAIN ) ); |
||
84 | |||
85 | $output = $this->getMockBuilder( '\OutputPage' ) |
||
86 | ->disableOriginalConstructor() |
||
87 | ->getMock(); |
||
88 | |||
89 | $output->expects( $this->atLeastOnce() ) |
||
90 | ->method( 'getTitle' ) |
||
91 | ->will( $this->returnValue( $title ) ); |
||
92 | |||
93 | $output->expects( $this->once() ) |
||
94 | ->method( 'setPageTitle' ); |
||
95 | |||
96 | $instance->modifyOutput( $output ); |
||
97 | } |
||
98 | |||
99 | public function testEnabledSubpageForTitleManipulationOnInvalidSubpage() { |
||
134 | |||
135 | } |
||
136 |