33 * Class SampleTest
44 *
55 * @package Wp_Bootstrap_Navwalker
6+ *
7+ * phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_print_r -- used for returned failure messages to give some details.
68 */
79
810/**
1113 * @extends WP_UnitTestCase
1214 */
1315class Test_WP_Bootstrap_NavWalker extends WP_UnitTestCase {
14-
1516 /**
1617 * The setUp function.
1718 *
1819 * @access public
1920 * @return void
2021 */
21- function setUp () {
22+ public function setUp () {
2223
2324 parent ::setUp ();
2425
@@ -89,7 +90,7 @@ function setUp() {
8990 * @access public
9091 * @return void
9192 */
92- function test_navwalker_file_exists () {
93+ public function test_navwalker_file_exists () {
9394 $ this ->assertFileExists ( 'class-wp-bootstrap-navwalker.php ' );
9495 }
9596
@@ -99,7 +100,7 @@ function test_navwalker_file_exists() {
99100 * @access public
100101 * @return void
101102 */
102- function test_startlvl_function_exists () {
103+ public function test_startlvl_function_exists () {
103104
104105 $ wp_bootstrap_navwalker = $ this ->walker ;
105106
@@ -116,7 +117,7 @@ function test_startlvl_function_exists() {
116117 * @access public
117118 * @return void
118119 */
119- function test_start_el_function_exists () {
120+ public function test_start_el_function_exists () {
120121
121122 $ wp_bootstrap_navwalker = $ this ->walker ;
122123
@@ -133,7 +134,7 @@ function test_start_el_function_exists() {
133134 * @access public
134135 * @return void
135136 */
136- function test_display_element_function_exists () {
137+ public function test_display_element_function_exists () {
137138
138139 $ wp_bootstrap_navwalker = $ this ->walker ;
139140
@@ -145,12 +146,12 @@ function test_display_element_function_exists() {
145146 }
146147
147148 /**
148- * Test Fallback Function exists.
149+ * Test Fallback function exists.
149150 *
150151 * @access public
151152 * @return void
152153 */
153- function test_fallback_function_exists () {
154+ public function test_fallback_function_exists () {
154155
155156 $ wp_bootstrap_navwalker = $ this ->walker ;
156157
@@ -167,10 +168,10 @@ function test_fallback_function_exists() {
167168 * Expects that for logged out users both echo and return requests should
168169 * produce empty strings.
169170 *
170- * @access public
171- * @return void
171+ * @access public
172+ * @return void
172173 */
173- function test_fallback_function_output_loggedout () {
174+ public function test_fallback_function_output_loggedout () {
174175
175176 // default is to echo reults, buffer.
176177 ob_start ();
@@ -203,9 +204,9 @@ function test_fallback_function_output_loggedout() {
203204 * requesting either a return or defaulting to echo.
204205 *
205206 * @access public
206- * @return void
207+ * @return void
207208 */
208- function test_fallback_function_output_loggedin () {
209+ public function test_fallback_function_output_loggedin () {
209210
210211 // make an admin user and set it to be the current user.
211212 $ user_id = $ this ->factory ->user ->create ( array ( 'role ' => 'administrator ' ) );
@@ -218,7 +219,7 @@ function test_fallback_function_output_loggedin() {
218219
219220 // rudimentary content test - confirm it opens a div with 2 expected
220221 // values and ends by closing a div.
221- $ match = ( preg_match ('/^(<div id="a_container_id" class="a_container_class">)(.*?)(<\/div>)$/ ' , $ fallback_output_echo ) ) ? true : false ;
222+ $ match = ( preg_match ( '/^(<div id="a_container_id" class="a_container_class">)(.*?)(<\/div>)$/ ' , $ fallback_output_echo ) ) ? true : false ;
222223 $ this ->assertTrue (
223224 $ match ,
224225 'Fallback method seems to create unexpected html for logged in users in echo mode. '
@@ -243,7 +244,7 @@ function test_fallback_function_output_loggedin() {
243244 * @access public
244245 * @return void
245246 */
246- function test_seporate_linkmods_and_icons_from_classes_function_exists () {
247+ public function test_seporate_linkmods_and_icons_from_classes_function_exists () {
247248
248249 $ wp_bootstrap_navwalker = $ this ->walker ;
249250
@@ -261,9 +262,9 @@ function test_seporate_linkmods_and_icons_from_classes_function_exists() {
261262 * @depends test_seporate_linkmods_and_icons_from_classes_function_exists
262263 *
263264 * @access public
264- * @return void
265+ * @return void
265266 */
266- function test_seporate_linkmods_and_icons_from_classes_fontawesome () {
267+ public function test_seporate_linkmods_and_icons_from_classes_fontawesome () {
267268
268269 $ wp_bootstrap_navwalker = $ this ->walker ;
269270 // since we're working with private methods we need to use a reflector.
@@ -299,7 +300,7 @@ function test_seporate_linkmods_and_icons_from_classes_fontawesome() {
299300 // icon_classes should no longer be empty.
300301 $ this ->assertNotTrue ( empty ( $ icon_classes ) );
301302 // the number of items inside updated $icon_classes should match number of valids we started with.
302- $ this ->assertTrue ( count ( $ this ->some_fontawesome_classes ) === count ( $ icon_classes ), "Seems that glyphicons classes are not catptured properly... \nvalid: \n" . print_r ( $ this ->some_fontawesome_classes , true ) . "\nreturned: \n" . print_r ( $ icon_classes , true ) );
303+ $ this ->assertTrue ( count ( $ this ->some_fontawesome_classes ) === count ( $ icon_classes ), "Seems that glyphicons classes are not catptured properly... \nvalid: \n" . print_r ( $ this ->some_fontawesome_classes , true ) . "\nreturned: \n" . print_r ( $ icon_classes , true ) );
303304 // get the differences between the original classes and updated classes.
304305 $ icon_differences = array_diff ( $ this ->some_fontawesome_classes , $ icon_classes );
305306 // should be no differences thus empty array, this being TRUE also means
@@ -315,9 +316,9 @@ function test_seporate_linkmods_and_icons_from_classes_fontawesome() {
315316 * @depends test_seporate_linkmods_and_icons_from_classes_function_exists
316317 *
317318 * @access public
318- * @return void
319+ * @return void
319320 */
320- function test_seporate_linkmods_and_icons_from_classes_glyphicons () {
321+ public function test_seporate_linkmods_and_icons_from_classes_glyphicons () {
321322
322323 $ wp_bootstrap_navwalker = $ this ->walker ;
323324 // since we're working with private methods we need to use a reflector.
@@ -353,7 +354,7 @@ function test_seporate_linkmods_and_icons_from_classes_glyphicons() {
353354 // icon_classes should no longer be empty.
354355 $ this ->assertNotTrue ( empty ( $ icon_classes ) );
355356 // the number of items inside updated $icon_classes should match number of valids we started with.
356- $ this ->assertTrue ( count ( $ this ->some_glyphicons_classes ) === count ( $ icon_classes ), "Seems that glyphicons classes are not catptured properly... \nvalid: \n" . print_r ( $ this ->some_glyphicons_classes , true ) . "\nreturned: \n" . print_r ( $ icon_classes , true ) );
357+ $ this ->assertTrue ( count ( $ this ->some_glyphicons_classes ) === count ( $ icon_classes ), "Seems that glyphicons classes are not catptured properly... \nvalid: \n" . print_r ( $ this ->some_glyphicons_classes , true ) . "\nreturned: \n" . print_r ( $ icon_classes , true ) );
357358 // get the differences between the original classes and updated classes.
358359 $ icon_differences = array_diff ( $ this ->some_glyphicons_classes , $ icon_classes );
359360 // should be no differences thus empty array, this being TRUE also means
@@ -369,9 +370,9 @@ function test_seporate_linkmods_and_icons_from_classes_glyphicons() {
369370 * @depends test_seporate_linkmods_and_icons_from_classes_function_exists
370371 *
371372 * @access public
372- * @return void
373+ * @return void
373374 */
374- function test_seporate_linkmods_and_icons_from_classes_linkmods () {
375+ public function test_seporate_linkmods_and_icons_from_classes_linkmods () {
375376
376377 $ wp_bootstrap_navwalker = $ this ->walker ;
377378 // since we're working with private methods we need to use a reflector.
@@ -410,23 +411,24 @@ function test_seporate_linkmods_and_icons_from_classes_linkmods() {
410411
411412 $ num_of_items_left = count ( $ this ->valid_linkmod_classes ) - count ( $ linkmod_classes ) - count ( $ this ->valid_linkmod_typeflags );
412413 // the number of items inside updated array should match [what we started with - minus the linkmods for inside dropdowns].
413- $ this ->assertNotTrue ( (bool ) $ num_of_items_left ,
414- "Seems that the linkmod classes are not catptured properly when outside of dropdowns... \nvalid: \n" . print_r ( $ this ->valid_linkmod_classes , true ) . "\nreturned: \n" . print_r ( $ linkmod_classes , true ) );
414+ $ this ->assertNotTrue (
415+ (bool ) $ num_of_items_left ,
416+ "Seems that the linkmod classes are not catptured properly when outside of dropdowns... \nvalid: \n" . print_r ( $ this ->valid_linkmod_classes , true ) . "\nreturned: \n" . print_r ( $ linkmod_classes , true )
417+ );
415418 // get the differences between the original classes and updated classes.
416419 $ linkmod_differences = array_diff ( $ this ->valid_linkmod_classes , $ linkmod_classes , $ this ->valid_linkmod_typeflags );
417420
418421 // should be no differences thus empty array, this being TRUE also means
419422 // that text was exact match in the updated array vs the original.
420423 $ this ->assertTrue ( empty ( $ linkmod_differences ) );
421424
422-
423425 // repeat some of the above tests but this time with depth = 1 so that we catch classes intended for inside dropdowns.
424- $ depth = 1 ;
426+ $ depth = 1 ;
425427 $ linkmod_classes_d = array ();
426428 $ icon_classes_d = array ();
427- $ returned_array_d = $ method_open ->invokeArgs ( $ wp_bootstrap_navwalker , array ( $ linkmod_array , &$ linkmod_classes_d , &$ icon_classes_d , $ depth ) );
429+ $ returned_array_d = $ method_open ->invokeArgs ( $ wp_bootstrap_navwalker , array ( $ linkmod_array , &$ linkmod_classes_d , &$ icon_classes_d , $ depth ) );
428430
429- $ this ->assertTrue ( count ( $ this ->valid_linkmod_classes ) === count ( $ linkmod_classes_d ), "Seems that the linkmod classes are not catptured properly when inside dropdowns... \nvalid: \n" . print_r ( $ this ->valid_linkmod_classes , true ) . "\nreturned: \n" . print_r ( $ linkmod_classes , true ) );
431+ $ this ->assertTrue ( count ( $ this ->valid_linkmod_classes ) === count ( $ linkmod_classes_d ), "Seems that the linkmod classes are not catptured properly when inside dropdowns... \nvalid: \n" . print_r ( $ this ->valid_linkmod_classes , true ) . "\nreturned: \n" . print_r ( $ linkmod_classes , true ) );
430432 $ linkmod_differences_d = array_diff ( $ this ->valid_linkmod_classes , $ linkmod_classes_d );
431433 $ this ->assertTrue ( empty ( $ linkmod_differences_d ), 'There are differences between the matched classnames and the valid classnames. ' );
432434
@@ -443,9 +445,9 @@ function test_seporate_linkmods_and_icons_from_classes_linkmods() {
443445 * @depends test_seporate_linkmods_and_icons_from_classes_linkmods
444446 *
445447 * @access public
446- * @return void
448+ * @return void
447449 */
448- function test_seporate_linkmods_and_icons_from_classes_fulltest () {
450+ public function test_seporate_linkmods_and_icons_from_classes_fulltest () {
449451
450452 $ wp_bootstrap_navwalker = $ this ->walker ;
451453 // since we're working with private methods we need to use a reflector.
@@ -476,21 +478,21 @@ function test_seporate_linkmods_and_icons_from_classes_fulltest() {
476478 shuffle ( $ classname_array );
477479
478480 // need a depth of 1 to ensure that our linkmods classes for inside dropdowns are also captured.
479- $ depth = 1 ;
481+ $ depth = 1 ;
480482 $ returned_array = $ method_open ->invokeArgs ( $ wp_bootstrap_navwalker , array ( $ classname_array , &$ linkmod_classes , &$ icon_classes , $ depth ) );
481483
482484 // linkmod_classes NOT should be empty and returned_array should not.
483- $ this ->assertTrue ( ( ! empty ( $ linkmod_classes ) && ! empty ( $ returned_array ) ), 'Either the linkmod array of the returned non matching classes array is empty when they shoud not be. ' );
485+ $ this ->assertTrue ( ( ! empty ( $ linkmod_classes ) && ! empty ( $ returned_array ) ), 'Either the linkmod array or the returned non matching classes array is empty when they shoud not be. ' );
484486 // starting arrays should no longer be empty.
485487 $ this ->assertNotTrue ( empty ( $ icon_classes ), 'Did not catch any icons. ' );
486488 $ this ->assertNotTrue ( empty ( $ linkmod_classes ), 'Did not catch any linkmods. ' );
487489
488490 // icons compair.
489- $ this ->assertTrue ( count ( $ icons_array ) === count ( $ icon_classes ), "Seems that icon classes are not catptured properly... valid: \n" . print_r ( $ icons_array , true ) . "returned: \n" . print_r ( $ icon_classes , true ) );
491+ $ this ->assertTrue ( count ( $ icons_array ) === count ( $ icon_classes ), "Seems that icon classes are not catptured properly... valid: \n" . print_r ( $ icons_array , true ) . "returned: \n" . print_r ( $ icon_classes , true ) );
490492 $ icon_differences = array_diff ( $ icons_array , $ icon_classes );
491493 $ this ->assertTrue ( empty ( $ icon_differences ), 'Seems that we did not catch all of the icon classes. ' );
492494 // linkmod compair.
493- $ this ->assertTrue ( count ( $ linkmod_array ) === count ( $ linkmod_classes ), "Seems that linkmod classes are not catptured properly... valid: \n" . print_r ( $ linkmod_array , true ) . "returned: \n" . print_r ( $ linkmod_classes , true ) );
495+ $ this ->assertTrue ( count ( $ linkmod_array ) === count ( $ linkmod_classes ), "Seems that linkmod classes are not catptured properly... valid: \n" . print_r ( $ linkmod_array , true ) . "returned: \n" . print_r ( $ linkmod_classes , true ) );
494496 $ linkmod_differences = array_diff ( $ icons_array , $ icon_classes );
495497 $ this ->assertTrue ( empty ( $ linkmod_differences ), 'Seems that we did not catch all of the linkmod classes. ' );
496498 // extra classes string matches checks.
@@ -505,7 +507,7 @@ function test_seporate_linkmods_and_icons_from_classes_fulltest() {
505507 * @access public
506508 * @return void
507509 */
508- function test_get_linkmod_type_function_exists () {
510+ public function test_get_linkmod_type_function_exists () {
509511
510512 $ wp_bootstrap_navwalker = $ this ->walker ;
511513
@@ -522,7 +524,7 @@ function test_get_linkmod_type_function_exists() {
522524 * @access public
523525 * @return void
524526 */
525- function test_update_atts_for_linkmod_type_function_exists () {
527+ public function test_update_atts_for_linkmod_type_function_exists () {
526528
527529 $ wp_bootstrap_navwalker = $ this ->walker ;
528530
@@ -539,7 +541,7 @@ function test_update_atts_for_linkmod_type_function_exists() {
539541 * @access public
540542 * @return void
541543 */
542- function test_linkmod_element_open_function_exists () {
544+ public function test_linkmod_element_open_function_exists () {
543545
544546 $ wp_bootstrap_navwalker = $ this ->walker ;
545547
@@ -556,7 +558,7 @@ function test_linkmod_element_open_function_exists() {
556558 * @access public
557559 * @return void
558560 */
559- function test_linkmod_element_close_function_exists () {
561+ public function test_linkmod_element_close_function_exists () {
560562
561563 $ wp_bootstrap_navwalker = $ this ->walker ;
562564
@@ -572,9 +574,9 @@ function test_linkmod_element_close_function_exists() {
572574 * some different linkmod types.
573575 *
574576 * @access public
575- * @return void
577+ * @return void
576578 */
577- function test_linkmod_elements_open_and_close_successfully () {
579+ public function test_linkmod_elements_open_and_close_successfully () {
578580
579581 $ wp_bootstrap_navwalker = $ this ->walker ;
580582
0 commit comments