Skip to content

Commit

Permalink
Issue #156 - update tests for WordPress 5.5 and PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Aug 26, 2020
1 parent 700a798 commit 974c44c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 16 deletions.
18 changes: 11 additions & 7 deletions includes/bw_register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down
24 changes: 19 additions & 5 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,27 +18,41 @@ Plugins required to be activated:
- oik-css
- us-tides
- oik-user
- oik-bob-bing-wide

Themes to be available:
- genesis-oik

Syntax:

```
cd <path-to-wp-content-plugins>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:

- 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.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<script src='http://example.com/issue-68.js?ver=1.0'>
<script src='http://example.com/issue-68.js?ver=1.0' id='issue-68-js'>
</script>

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
&lt;p class=&quot;bw_wtf&quot; lang=&quot;HTML&quot; escaped=&quot;true&quot; style=&quot;display:none;&quot;&gt;&#091;bw_wtf&#093; &#045; nothing to see&lt;/p&gt;
&lt;/div&gt;
</p>
<p lang="HTML" escaped="true">&lt;script type=&#039;text/javascript&#039; src=&#039;https://qw/src/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp&#039;&gt;&lt;/script&gt;
&lt;script type=&#039;text/javascript&#039; src=&#039;https://qw/src/wp-includes/js/jquery/jquery-migrate.js?ver=1.4.1&#039;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;jQuery( function() { jQuery( &quot;div.bw_wtf&quot; ).hover( function() { jQuery(&quot;p.bw_wtf&quot;).slideToggle( ); } ); });&lt;/script&gt;</p>
<p lang="HTML" escaped="true">&lt;script type=&#039;text/javascript&#039; src=&#039;https://qw/src/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp&#039; id=&#039;jquery-js&#039;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;jQuery( function() { jQuery( &quot;div.bw_wtf&quot; ).hover( function() { jQuery(&quot;p.bw_wtf&quot;).slideToggle( ); } ); });&lt;/script&gt;</p>
4 changes: 4 additions & 0 deletions tests/test-oik-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down
23 changes: 23 additions & 0 deletions tests/test-shortcodes-oik-slideshows.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down

0 comments on commit 974c44c

Please sign in to comment.