1 | <?php |
||
18 | class HtmlBreadcrumbLinksBuilderTest extends \PHPUnit_Framework_TestCase { |
||
19 | |||
20 | public function testCanConstruct() { |
||
35 | |||
36 | public function testHetHtmlForEmptyContent() { |
||
64 | |||
65 | public function testBuildBreadcrumbsForValidHierarchicalLinks() { |
||
66 | |||
67 | $byPropertyHierarchicalLinksFinder = $this->getMockBuilder( '\SBL\ByPropertyHierarchicalLinksFinder' ) |
||
68 | ->disableOriginalConstructor() |
||
69 | ->getMock(); |
||
70 | |||
71 | $byPropertyHierarchicalLinksFinder->expects( $this->once() ) |
||
72 | ->method( 'getParents' ) |
||
73 | ->will( $this->returnValue( [ new DIWikiPage( 'Foo', NS_MAIN ) ] ) ); |
||
74 | |||
75 | $byPropertyHierarchicalLinksFinder->expects( $this->once() ) |
||
76 | ->method( 'getChildren' ) |
||
77 | ->will( $this->returnValue( [ |
||
78 | new DIWikiPage( 'Bar', NS_MAIN ), |
||
79 | new DIWikiPage( 'Foobar', NS_MAIN ) ] ) ); |
||
80 | |||
81 | $bySubpageLinksFinder = $this->getMockBuilder( '\SBL\BySubpageLinksFinder' ) |
||
82 | ->disableOriginalConstructor() |
||
83 | ->getMock(); |
||
84 | |||
85 | $bySubpageLinksFinder->expects( $this->never() ) |
||
86 | ->method( 'isDiscoveryFallback' ); |
||
87 | |||
88 | $instance = new HtmlBreadcrumbLinksBuilder( |
||
89 | $byPropertyHierarchicalLinksFinder, |
||
90 | $bySubpageLinksFinder |
||
91 | ); |
||
92 | |||
93 | $instance->isRTL( false ); |
||
94 | $instance->setBreadcrumbDividerStyleClass( 'DividerStyleClass' ); |
||
95 | |||
96 | $instance->buildBreadcrumbs( Title::newFromText( __METHOD__ ) ); |
||
97 | |||
98 | $this->assertInternalType( |
||
99 | 'string', |
||
100 | $instance->getHtml() |
||
101 | ); |
||
102 | |||
103 | $this->assertContains( |
||
104 | 'dir="ltr"', |
||
105 | $instance->getHtml() |
||
106 | ); |
||
107 | |||
108 | $this->assertContains( |
||
109 | 'DividerStyleClass', |
||
110 | $instance->getHtml() |
||
111 | ); |
||
112 | } |
||
113 | |||
114 | public function testBuildBreadcrumbsForNoHierarchicalLinksButSubpageFallback() { |
||
152 | |||
153 | /** |
||
154 | * Test to ensure that no subobject is assigned from a Title that contains |
||
155 | * a fragment |
||
156 | */ |
||
157 | public function testBuildBreadcrumbsToNeverUseFragmentedPartOfTitle() { |
||
158 | |||
159 | $subject = new DIWikiPage( __METHOD__, NS_MAIN, '', '' ); |
||
160 | |||
161 | $byPropertyHierarchicalLinksFinder = $this->getMockBuilder( '\SBL\ByPropertyHierarchicalLinksFinder' ) |
||
162 | ->disableOriginalConstructor() |
||
163 | ->getMock(); |
||
164 | |||
165 | $byPropertyHierarchicalLinksFinder->expects( $this->once() ) |
||
166 | ->method( 'findLinksBySubject' ) |
||
167 | ->with( $this->equalTo( $subject ) ); |
||
168 | |||
169 | $byPropertyHierarchicalLinksFinder->expects( $this->once() ) |
||
170 | ->method( 'getParents' ) |
||
171 | ->will( $this->returnValue( [] ) ); |
||
172 | |||
173 | $byPropertyHierarchicalLinksFinder->expects( $this->once() ) |
||
174 | ->method( 'getChildren' ) |
||
175 | ->will( $this->returnValue( [] ) ); |
||
176 | |||
177 | $bySubpageLinksFinder = $this->getMockBuilder( '\SBL\BySubpageLinksFinder' ) |
||
178 | ->disableOriginalConstructor() |
||
179 | ->getMock(); |
||
180 | |||
181 | $instance = new HtmlBreadcrumbLinksBuilder( |
||
182 | $byPropertyHierarchicalLinksFinder, |
||
183 | $bySubpageLinksFinder |
||
184 | ); |
||
185 | |||
186 | $title = Title::newFromText( __METHOD__ ); |
||
187 | $title->setFragment( 'Foo' ); |
||
188 | |||
189 | $instance->buildBreadcrumbs( $title ); |
||
190 | } |
||
191 | |||
192 | public function testBuildBreadcrumbsToUseDisplayTitle() { |
||
241 | |||
242 | public function testRedirectDoesNotTryToFindBreadcrumbs() { |
||
243 | |||
270 | |||
271 | } |
||
272 |