From 974c44cd86f98371c0956fff1601da1d1e90ffc2 Mon Sep 17 00:00:00 2001
From: Herb Miller
Date: Wed, 26 Aug 2020 22:12:16 +0100
Subject: [PATCH] Issue #156 - update tests for WordPress 5.5 and PHP 7.4
---
includes/bw_register.php | 18 ++++++++------
tests/README.md | 24 +++++++++++++++----
...w_report_scripts_after_enqueue_script.html | 2 +-
...bw_wtf_example_snippet_includes_bw_jq.html | 5 ++--
tests/test-oik-admin.php | 4 ++++
tests/test-shortcodes-oik-slideshows.php | 23 ++++++++++++++++++
6 files changed, 60 insertions(+), 16 deletions(-)
diff --git a/includes/bw_register.php b/includes/bw_register.php
index a3e9070..1f1744d 100644
--- a/includes/bw_register.php
+++ b/includes/bw_register.php
@@ -340,14 +340,18 @@ function bw_default_taxonomy_args( $taxonomy, $arg ) {
* @param mixed $args - array of arguments passed to register_taxonomy()
*/
function bw_register_taxonomy( $taxonomy, $object_type=NULL, $args=NULL ) {
- //bw_trace2( $args );
- if ( !bw_query_taxonomy( $taxonomy ) ) {
- register_taxonomy( $taxonomy, $object_type, $args );
- } else {
- register_taxonomy_for_object_type( $taxonomy, $object_type );
+ //bw_trace2( $args );
+ if ( !bw_query_taxonomy( $taxonomy ) ) {
+ register_taxonomy( $taxonomy, $object_type, $args );
+ } else {
+ register_taxonomy_for_object_type( $taxonomy, $object_type );
+ }
+ if ( $args ) {
+ $field_title=bw_array_get( $args['labels'], 'name', $taxonomy );
+ } else {
+ $field_title = $taxonomy;
}
- $field_title = bw_array_get( $args['labels'], 'name', $taxonomy );
- bw_register_field( $taxonomy, "taxonomy", $field_title, $args );
+ bw_register_field( $taxonomy, "taxonomy", $field_title, $args );
}
/**
diff --git a/tests/README.md b/tests/README.md
index 2701c59..e3a6f72 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -6,8 +6,8 @@ See [How I’m testing the internationalization and localization of my WordPress
# Dependencies
Requires:
-- PHPUnit 6.2 or higher
-- WordPress 4.9 or higher
+- PHPUnit 8.4.1 or higher
+- WordPress 5.5 or higher
- wordpress-develop-tests
- oik-batch - for oik-phpunit.php
- WordPress language files for the bb_BB locale
@@ -18,20 +18,33 @@ Plugins required to be activated:
- oik-css
- us-tides
- oik-user
+- oik-bob-bing-wide
Themes to be available:
- genesis-oik
Syntax:
+```
cd oik
pu
+```
-where pu invokes
+where `pu` invokes
-set PHPUNIT=c:\apache\htdocs\phpLibraries\phpunit\phpunit-6.5.13.phar
+```
+set PHPUNIT=c:\apache\htdocs\phpLibraries\phpunit\phpunit-8.4.1.phar
php ..\..\plugins\oik-batch\oik-phpunit.php "--verbose" "--disallow-test-output" "--stop-on-error" "--stop-on-failure" "--log-junit=phpunit.json" %*
+```
+Prior to running the tests run
+
+```
+prepu
+```
+
+where `prepu` attempts to prepare the environment for running PHPUnit tests.
+It uses `WP-cli` to activate the required plugins and sets the language to `en_GB`
## Notes
In order for the tests to run to completion in multiple environments some settings must have particular values:
@@ -39,6 +52,7 @@ In order for the tests to run to completion in multiple environments some settin
- oik-css: Disable automatic paragraph creation should be unchecked
- SCRIPT_DEBUG needs to be true
- wp-mail-smtp: should not be activated
-- oik: PayPal country should be set to United Kingdom
+- oik: PayPal country should be set to: United Kingdom
These settings allow the PhpUnit tests for oik-libs to run to completion as well.
+
diff --git a/tests/data/en_GB/test_bw_report_scripts_after_enqueue_script.html b/tests/data/en_GB/test_bw_report_scripts_after_enqueue_script.html
index 23093cc..13331af 100644
--- a/tests/data/en_GB/test_bw_report_scripts_after_enqueue_script.html
+++ b/tests/data/en_GB/test_bw_report_scripts_after_enqueue_script.html
@@ -1,3 +1,3 @@
-
diff --git a/tests/data/en_GB/test_bw_wtf_example_snippet_includes_bw_jq.html b/tests/data/en_GB/test_bw_wtf_example_snippet_includes_bw_jq.html
index ec7e15b..a5448b4 100644
--- a/tests/data/en_GB/test_bw_wtf_example_snippet_includes_bw_jq.html
+++ b/tests/data/en_GB/test_bw_wtf_example_snippet_includes_bw_jq.html
@@ -11,6 +11,5 @@
<p class="bw_wtf" lang="HTML" escaped="true" style="display:none;">[bw_wtf] - nothing to see</p>
</div>
-<script type='text/javascript' src='https://qw/src/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp'></script>
-<script type='text/javascript' src='https://qw/src/wp-includes/js/jquery/jquery-migrate.js?ver=1.4.1'></script>
-<script type="text/javascript">jQuery( function() { jQuery( "div.bw_wtf" ).hover( function() { jQuery("p.bw_wtf").slideToggle( ); } ); });</script>
+<script type='text/javascript' src='https://qw/src/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp' id='jquery-js'></script>
+<script type="text/javascript">jQuery( function() { jQuery( "div.bw_wtf" ).hover( function() { jQuery("p.bw_wtf").slideToggle( ); } ); });</script>
\ No newline at end of file
diff --git a/tests/test-oik-admin.php b/tests/test-oik-admin.php
index 9587f02..4cae03d 100644
--- a/tests/test-oik-admin.php
+++ b/tests/test-oik-admin.php
@@ -400,6 +400,8 @@ function test_oik_plugins_do_page() {
* Test oik_plugins_add_settings
*/
function test_oik_plugins_add_settings() {
+ global $bw_plugin;
+ $bw_plugin = [ 'plugin' => null, 'server' => null, 'apikey' => null ];
$html = bw_ret( oik_plugins_add_settings() );
$this->assertNotNull( $html );
$html = $this->replace_admin_url( $html );
@@ -899,6 +901,8 @@ function test_oik_themes_do_page_bb_BB() {
function test_oik_themes_add_settings_bb_BB() {
$this->switch_to_locale( "bb_BB" );
+ global $bw_theme;
+ $bw_theme = [ 'theme' => null, 'server' => null, 'apikey' => null ];
$html = bw_ret( oik_themes_add_settings() );
$this->assertNotNull( $html );
//$html = $this->replace_admin_url( $html );
diff --git a/tests/test-shortcodes-oik-slideshows.php b/tests/test-shortcodes-oik-slideshows.php
index 12bfeab..eee4a6c 100644
--- a/tests/test-shortcodes-oik-slideshows.php
+++ b/tests/test-shortcodes-oik-slideshows.php
@@ -29,9 +29,31 @@ function test_portfolio_slideshow__help_bb_BB() {
$this->assertArrayEqualsFile( $html );
$this->switch_to_locale( "en_GB" );
}
+
+ function set_global_ps_options() {
+ global $ps_options;
+ $ps_options = [];
+ $ps_options['size'] = null;
+ $ps_options['nowrap'] = null;
+ $ps_options['speed'] = null;
+ $ps_options['trans'] = null;
+ $ps_options['timeout'] = null;
+ $ps_options['exclude_featured'] = null;
+ $ps_options['autoplay'] = null;
+ $ps_options['pagerpos'] = null;
+ $ps_options['navpos'] = null;
+ $ps_options['showcaps'] = null;
+ $ps_options['showtitles'] = null;
+ $ps_options['showdesc'] = null;
+ $ps_options['click'] = null;
+ $ps_options['target'] = null;
+ $ps_options['centered'] = null;
+
+ }
function test_portfolio_slideshow__syntax() {
//$this->setExpectedDeprecated( "bw_translate" );
+ $this->set_global_ps_options();
$this->switch_to_locale( "en_GB" );
$array = portfolio_slideshow__syntax();
$html = $this->arraytohtml( $array, true );
@@ -40,6 +62,7 @@ function test_portfolio_slideshow__syntax() {
}
function test_portfolio_slideshow__syntax_bb_BB() {
+ $this->set_global_ps_options();
$this->switch_to_locale( "bb_BB" );
$array = portfolio_slideshow__syntax();
$html = $this->arraytohtml( $array, true );