Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logic to check compatibility of wordpress-develop-tests with WordPress #17

Closed
bobbingwide opened this issue Dec 7, 2016 · 3 comments
Assignees

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Dec 7, 2016

When I first started running my in situ PHPUnit tests under WordPress 4.7 I was still using the wordpress-develop-tests plugin built against WordPress 4.6, and oik-batch v0.8.7.

It proved to be incompatible - see the table below.
Explanation: In order to test the changes to WordPress core, the PHP Unit testing code needed to reflect the changes.

Solution: Update the wordpress-develop-tests to v4.7 AND update oik-batch ( v0.9.0 ).
v0.9.0 of oik-batch contains its own version of WP_UnitTestCase and a different version of functions.php. The alternative versions are loaded by oik-batch's tests\bootstrap.php file.

See #16 and bobbingwide/wordpress-develop-tests#2

The table below summarises what happens with different levels of WordPress, wordpress-develop-tests and oik-batch.

WordPress version wordpress-develop-tests version oik-batch Result
4.6.x v4.6 v0.8.7 OK - this works
4.6.x v4.6 v0.9.0 Error: __clone method called on non-object
4.6.x v4.7 v0.8.7 Fatal error: Cannot redeclare wp_clear_auth_cookie
4.6.x v4.7 v0.9.0 Error: __clone method called on non-object
4.7 v4.6 v0.8.7 Undefined index: merged_filters
4.7 v4.6 v0.9.0 OK - this works
4.7 v4.7 v0.8.7 Fatal error: Cannot redeclare wp_clear_auth_cookie()
4.7 v4.7 v0.9.0 OK - this works

As you can see, the changes make in v0.9.0 makes it incompatible with PHP Unit testing using WordPress 4.6.

Proposed solution

oik-batch's bootstrap code should detect the versions in use and either report it nicely or, if possible, deal with it.

Current workaround

Using the table below, checkout the Git repositories to the appropriate levels before running the tests.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 19, 2016

An additional problem arose with tables that had been created with a storage engine that's not capable of supporting transactions. i.e.. MyISAM tables. Even though the PHPUnit tests are constructed to disable auto commit and ROLLBACK changes at the end of the transaction, MyISAM tables will reflect all the changes that had been made.

Proposed solution

Detect MyISAM tables in the database and not run the tests if any are present. Optionally offer to convert the tables to InnoDB.

See stack overflow for explanations and conversion routines. E.g.

http://stackoverflow.com/questions/20148/myisam-versus-innodb

@bobbingwide
Copy link
Owner Author

Both WordPress and wordpress-develop-tests have now been updated to v4.8.
The test that has been implemented supports WordPress being at a higher level than the wordpress-develop-tests.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Oct 12, 2017

The covert_engine method() in oik-innodb.php was never completed. When I ran it for real, against qw/oikcom) I found that the routine needed updating.

Running ALTER TABLE 'oikplug_wp993.wp_commentmeta' engine='InnoDB' produced a WordPress database error [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use.

Rather than using
$query = $wpdb->prepare( "ALTER TABLE %s engine=%s", DB_NAME . "." . $result->table_name, $to_engine );
we'll just use
$query = sprintf( "ALTER TABLE %s engine=%s", $result->table_name, $to_engine );

@bobbingwide bobbingwide reopened this Oct 12, 2017
bobbingwide added a commit that referenced this issue Oct 25, 2017
bobbingwide added a commit that referenced this issue Oct 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant