@@ -264,7 +264,7 @@ public function testText() {
264
264
265
265
public function testMenu () {
266
266
// TODO: Add test for this...
267
- $ this ->navbar ->autoActiveLink = false ;
267
+ $ this ->navbar ->config ( ' autoActiveLink ' , false ) ;
268
268
// Basic test:
269
269
$ this ->navbar ->create (null );
270
270
$ result = $ this ->navbar ->beginMenu (['class ' => 'my-menu ' ]);
@@ -304,4 +304,85 @@ public function testMenu() {
304
304
// TODO: Add more tests...
305
305
}
306
306
307
+ public function testAutoButtonLink () {
308
+ $ this ->navbar ->create (null );
309
+
310
+ // Active and outside a menu:
311
+ $ this ->navbar ->config ('autoButtonLink ' , true );
312
+ $ result = $ this ->navbar ->link ('Button ' , '/ ' );
313
+ $ expected = [
314
+ ['a ' => ['href ' => '/ ' , 'class ' => 'navbar-btn btn btn-default ' ]],
315
+ 'Button ' , '/a '
316
+ ];
317
+ $ this ->assertHtml ($ expected , $ result );
318
+
319
+ // Inactive and outside a menu:
320
+ $ this ->navbar ->config ('autoButtonLink ' , false );
321
+ $ result = $ this ->navbar ->link ('Link ' , '/ ' );
322
+ $ expected = [
323
+ ['li ' => ['class ' => 'active ' ]],
324
+ ['a ' => ['href ' => '/ ' ]], 'Link ' , '/a ' ,
325
+ '/li '
326
+ ];
327
+ $ this ->assertHtml ($ expected , $ result );
328
+
329
+ // Active and inside a menu:
330
+ $ this ->navbar ->config ('autoButtonLink ' , true );
331
+ $ this ->navbar ->beginMenu ('' );
332
+ $ result = $ this ->navbar ->link ('Link ' , '/ ' );
333
+ $ expected = [
334
+ ['li ' => ['class ' => 'active ' ]],
335
+ ['a ' => ['href ' => '/ ' ]], 'Link ' , '/a ' ,
336
+ '/li '
337
+ ];
338
+ $ this ->assertHtml ($ expected , $ result );
339
+
340
+ }
341
+
342
+ public function testAutoActiveLink () {
343
+ $ this ->navbar ->create (null );
344
+ $ this ->navbar ->beginMenu ('' );
345
+
346
+ // Active and correct link:
347
+ $ this ->navbar ->config ('autoActiveLink ' , true );
348
+ $ result = $ this ->navbar ->link ('Link ' , '/ ' );
349
+ $ expected = [
350
+ ['li ' => ['class ' => 'active ' ]],
351
+ ['a ' => ['href ' => '/ ' ]], 'Link ' , '/a ' ,
352
+ '/li '
353
+ ];
354
+ $ this ->assertHtml ($ expected , $ result );
355
+
356
+ // Active and incorrect link but more complex:
357
+ $ this ->navbar ->config ('autoActiveLink ' , true );
358
+ $ result = $ this ->navbar ->link ('Link ' , '/pages ' );
359
+ $ expected = [
360
+ ['li ' => []],
361
+ ['a ' => ['href ' => '/pages ' ]], 'Link ' , '/a ' ,
362
+ '/li '
363
+ ];
364
+ $ this ->assertHtml ($ expected , $ result );
365
+
366
+ // Unactive and correct link:
367
+ $ this ->navbar ->config ('autoActiveLink ' , false );
368
+ $ result = $ this ->navbar ->link ('Link ' , '/ ' );
369
+ $ expected = [
370
+ ['li ' => []],
371
+ ['a ' => ['href ' => '/ ' ]], 'Link ' , '/a ' ,
372
+ '/li '
373
+ ];
374
+ $ this ->assertHtml ($ expected , $ result );
375
+
376
+ // Unactive and incorrect link:
377
+ $ this ->navbar ->config ('autoActiveLink ' , false );
378
+ $ result = $ this ->navbar ->link ('Link ' , '/pages ' );
379
+ $ expected = [
380
+ ['li ' => []],
381
+ ['a ' => ['href ' => '/pages ' ]], 'Link ' , '/a ' ,
382
+ '/li '
383
+ ];
384
+ $ this ->assertHtml ($ expected , $ result );
385
+
386
+ }
387
+
307
388
};
0 commit comments