Babble's PHPUnit testcase is triggering a fatal error #332

Closed
simonwheatley opened this Issue Sep 16, 2015 · 7 comments

Projects

None yet

3 participants

@simonwheatley
Contributor

Running the PHPUnit tests currently results in a fatal error, due to is_post_type_viewable() being called at a point when it is not defined.

Below is the output when I run PHPUnit.

$ ./vendor/bin/phpunit 
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 4.8.6 by Sebastian Bergmann and contributors.


Fatal error: Call to undefined function is_post_type_viewable() in /srv/www/wordpress-develop/tests/phpunit/includes/utils.php on line 365

Call Stack:
    0.0025     228016   1. {main}() /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/phpunit:0
    0.1145    1382280   2. PHPUnit_TextUI_Command::main(???) /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/phpunit:47
    0.1145    1382904   3. PHPUnit_TextUI_Command->run(array(1), bool) /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/TextUI/Command.php:100
   10.0610   31814408   4. PHPUnit_TextUI_TestRunner->doRun(class PHPUnit_Framework_TestSuite, array(5)) /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/TextUI/Command.php:148
   10.0856   32007936   5. PHPUnit_Framework_TestSuite->run(class PHPUnit_Framework_TestResult) /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:432
   10.0903   32023928   6. PHPUnit_Framework_TestSuite->run(class PHPUnit_Framework_TestResult) /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/Framework/TestSuite.php:735
   10.0937   32028240   7. PHPUnit_Framework_TestCase->run(class PHPUnit_Framework_TestResult) /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/Framework/TestSuite.php:735
   10.0938   32029880   8. PHPUnit_Framework_TestResult->run(class Test_Cookies) /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/Framework/TestCase.php:702
   10.1216   32081832   9. PHPUnit_Framework_TestCase->runBare() /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/Framework/TestResult.php:601
   10.1872   32612792  10. Babble_UnitTestCase->tearDown() /srv/www/babble/htdocs/wp-content/plugins/babble/vendor/phpunit/phpunit/src/Framework/TestCase.php:783
   10.1897   32560704  11. Babble_UnitTestCase->go_to(string(22)) /srv/www/babble/htdocs/wp-content/plugins/babble/tests/babble-testcase.php:30
   10.1897   32560840  12. WP_UnitTestCase->go_to(string(22)) /srv/www/babble/htdocs/wp-content/plugins/babble/tests/babble-testcase.php:44
   10.1898   32520536  13. _cleanup_query_vars() /srv/www/wordpress-develop/tests/phpunit/includes/testcase.php:359
@simonwheatley
Contributor

Hmmm, the function being called is in trunk and intended to be in 4.4.0… but we're running these tests on other WordPress versions, hence the breakage.

/**
 * Determines whether a post type is considered "viewable".
 *
 * For built-in post types such as posts and pages, the 'public' value will be evaluated.
 * For all others, the 'publicly_queryable' value will be used.
 *
 * @since 4.4.0
 *
 * @param object $post_type_object Post type object.
 * @return bool Whether the post type should be considered viewable.
 */
function is_post_type_viewable( $post_type_object ) {
    return $post_type_object->publicly_queryable || ( $post_type_object->_builtin && $post_type_object->public );
}
@jarednova

@simonwheatley I'm getting the same thing on a diff't project. For me it seems to be triggered by WP_UnitTestCase::go_to('/')

@DevinWalker

Well looky there!

@simonwheatley
Contributor

Fixed by #333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment