@@ -93,6 +93,10 @@ public function testTryAddImageForNoLanguageMatch() {
9393 ->disableOriginalConstructor ()
9494 ->getMock ();
9595
96+ $ interlanguageLinksLookup ->expects ( $ this ->atLeastOnce () )
97+ ->method ( 'hasSilAnnotationFor ' )
98+ ->will ( $ this ->returnValue ( true ) );
99+
96100 $ interlanguageLinksLookup ->expects ( $ this ->at ( 0 ) )
97101 ->method ( 'findPageLanguageForTarget ' )
98102 ->will ( $ this ->returnValue ( 'no ' ) );
@@ -115,7 +119,7 @@ public function testTryAddImageForNoLanguageMatch() {
115119 );
116120 }
117121
118- public function testTryAddSubcategoryForNoInterlanguageLinksLookup () {
122+ public function testAddSubcategoryForNoInterlanguageLinksLookup () {
119123
120124 $ title = Title::newFromText ( 'Foo ' , NS_CATEGORY );
121125
@@ -147,6 +151,10 @@ public function testTryAddSubcategoryForNoLanguageMatch() {
147151 ->disableOriginalConstructor ()
148152 ->getMock ();
149153
154+ $ interlanguageLinksLookup ->expects ( $ this ->atLeastOnce () )
155+ ->method ( 'hasSilAnnotationFor ' )
156+ ->will ( $ this ->returnValue ( true ) );
157+
150158 $ interlanguageLinksLookup ->expects ( $ this ->at ( 0 ) )
151159 ->method ( 'findPageLanguageForTarget ' )
152160 ->will ( $ this ->returnValue ( 'no ' ) );
@@ -186,6 +194,10 @@ public function testAddPageForEmptyLanguage() {
186194 ->disableOriginalConstructor ()
187195 ->getMock ();
188196
197+ $ interlanguageLinksLookup ->expects ( $ this ->atLeastOnce () )
198+ ->method ( 'hasSilAnnotationFor ' )
199+ ->will ( $ this ->returnValue ( true ) );
200+
189201 $ interlanguageLinksLookup ->expects ( $ this ->atLeastOnce () )
190202 ->method ( 'findPageLanguageForTarget ' )
191203 ->with ( $ this ->equalTo ( $ title ) )
@@ -205,7 +217,7 @@ public function testAddPageForEmptyLanguage() {
205217 );
206218 }
207219
208- public function testTryAddPageForLanguageMatch () {
220+ public function testAddPageForLanguageMatch () {
209221
210222 $ title = Title::newFromText ( 'Foo ' , NS_CATEGORY );
211223 $ target = Title::newFromText ( 'Bar ' );
@@ -214,12 +226,16 @@ public function testTryAddPageForLanguageMatch() {
214226 ->disableOriginalConstructor ()
215227 ->getMock ();
216228
217- $ interlanguageLinksLookup ->expects ( $ this ->at ( 0 ) )
229+ $ interlanguageLinksLookup ->expects ( $ this ->atLeastOnce () )
230+ ->method ( 'hasSilAnnotationFor ' )
231+ ->will ( $ this ->returnValue ( true ) );
232+
233+ $ interlanguageLinksLookup ->expects ( $ this ->at ( 1 ) )
218234 ->method ( 'findPageLanguageForTarget ' )
219235 ->with ( $ this ->equalTo ( $ title ) )
220236 ->will ( $ this ->returnValue ( 'vi ' ) );
221237
222- $ interlanguageLinksLookup ->expects ( $ this ->at ( 1 ) )
238+ $ interlanguageLinksLookup ->expects ( $ this ->at ( 2 ) )
223239 ->method ( 'findPageLanguageForTarget ' )
224240 ->with ( $ this ->equalTo ( $ target ) )
225241 ->will ( $ this ->returnValue ( 'vi ' ) );
@@ -247,12 +263,16 @@ public function testTryAddPageForNoLanguageMatch() {
247263 ->disableOriginalConstructor ()
248264 ->getMock ();
249265
250- $ interlanguageLinksLookup ->expects ( $ this ->at ( 0 ) )
266+ $ interlanguageLinksLookup ->expects ( $ this ->atLeastOnce () )
267+ ->method ( 'hasSilAnnotationFor ' )
268+ ->will ( $ this ->returnValue ( true ) );
269+
270+ $ interlanguageLinksLookup ->expects ( $ this ->at ( 1 ) )
251271 ->method ( 'findPageLanguageForTarget ' )
252272 ->with ( $ this ->equalTo ( $ title ) )
253273 ->will ( $ this ->returnValue ( 'vi ' ) );
254274
255- $ interlanguageLinksLookup ->expects ( $ this ->at ( 1 ) )
275+ $ interlanguageLinksLookup ->expects ( $ this ->at ( 2 ) )
256276 ->method ( 'findPageLanguageForTarget ' )
257277 ->with ( $ this ->equalTo ( $ target ) )
258278 ->will ( $ this ->returnValue ( 'en ' ) );
@@ -271,4 +291,31 @@ public function testTryAddPageForNoLanguageMatch() {
271291 );
272292 }
273293
294+ public function testTryAddPageForNoAnnotationMatch () {
295+
296+ $ title = Title::newFromText ( 'Foo ' , NS_CATEGORY );
297+ $ target = Title::newFromText ( 'Bar ' );
298+
299+ $ interlanguageLinksLookup = $ this ->getMockBuilder ( '\SIL\InterlanguageLinksLookup ' )
300+ ->disableOriginalConstructor ()
301+ ->getMock ();
302+
303+ $ interlanguageLinksLookup ->expects ( $ this ->atLeastOnce () )
304+ ->method ( 'hasSilAnnotationFor ' )
305+ ->will ( $ this ->returnValue ( false ) );
306+
307+ $ title ->interlanguageLinksLookup = $ interlanguageLinksLookup ;
308+
309+ $ instance = new ByLanguageCategoryViewer (
310+ $ title ,
311+ $ this ->context
312+ );
313+
314+ $ instance ->addPage ( $ target , 'B ' , '' );
315+
316+ $ this ->assertEmpty (
317+ $ instance ->articles
318+ );
319+ }
320+
274321}
0 commit comments