Support » Plugin: WooCommerce » WooCommerce PHPUnit test instructions fail

  • jonmoore

    (@jonathanmoorebcsorg)



    Can anyone advise on why the WooCommerce PHPUnit test instructions might fail, and any more complete documentation that could help resolution:
    https://github.com/woocommerce/woocommerce/blob/master/tests/README.md

    The instructions suggest:

    Simply change to the plugin root directory and type:
    $ phpunit

    Can anyone advise why this might not work?

    jpmpro:woocommerce jon$ phpunit
    Installing...
    Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
    Installing WooCommerce...
    
    Notice: /private/tmp/wordpress-tests-lib/includes/../data/themedir1 is not readable in /private/tmp/wordpress/wp-includes/theme.php on line 471
    
    Call Stack:
        0.0044     492280   1. {main}() /usr/local/bin/phpunit:0
        0.1121    8002480   2. PHPUnit\TextUI\Command::main(???) /usr/local/bin/phpunit:545
        0.1121    8002592   3. PHPUnit\TextUI\Command->run(???, ???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:140
        0.1121    8002592   4. PHPUnit\TextUI\Command->handleArguments(???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:151
        0.1140    8005936   5. PHPUnit\TextUI\Command->handleBootstrap(???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:730
        0.1140    8005936   6. PHPUnit\Util\Fileloader::checkAndLoad(???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:908
        0.1141    8006208   7. PHPUnit\Util\Fileloader::load(???) phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:45
        0.1144    8024688   8. include_once('/Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php') phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:61
        0.1144    8024688   9. WC_Unit_Tests_Bootstrap::instance() /Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php:140
        0.1144    8024784  10. WC_Unit_Tests_Bootstrap->__construct() /Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php:133
        0.1159    8196168  11. require_once('/private/tmp/wordpress-tests-lib/includes/bootstrap.php') /Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php:50
        1.0654    8808160  12. require_once('/private/tmp/wordpress/wp-settings.php') /private/tmp/wordpress-tests-lib/includes/bootstrap.php:92
        2.5749   42203752  13. wp_templating_constants() /private/tmp/wordpress/wp-settings.php:392
        2.5749   42203752  14. get_template_directory() /private/tmp/wordpress/wp-includes/default-constants.php:343
        2.5750   42203752  15. get_theme_root(???) /private/tmp/wordpress/wp-includes/theme.php:305
        2.5751   42203752  16. get_raw_theme_root(???, ???) /private/tmp/wordpress/wp-includes/theme.php:545
        2.5758   42203720  17. get_theme_roots() /private/tmp/wordpress/wp-includes/theme.php:644
        2.5773   42203872  18. search_theme_directories(???) /private/tmp/wordpress/wp-includes/theme.php:361
        2.5775   42204472  19. trigger_error(???, ???) /private/tmp/wordpress/wp-includes/theme.php:471
    
    Variables in local scope (#18):
      $cache_expiration = 1800
      $cached_roots = *uninitialized*
      $dir = *uninitialized*
      $dirs = FALSE
      $force = TRUE
      $found_theme = *uninitialized*
      $found_themes = array ()
      $relative_theme_roots = array ('/private/tmp/wordpress-tests-lib/includes/../data/themedir1' => '/private/tmp/wordpress-tests-lib/includes/../data/themedir1', '/themes' => '/tmp/wordpress/wp-content/themes')
      $sub_dir = *uninitialized*
      $sub_dirs = *uninitialized*
      $theme_data = *uninitialized*
      $theme_dir = *uninitialized*
      $theme_root = '/private/tmp/wordpress-tests-lib/includes/../data/themedir1'
      $theme_roots = *uninitialized*
      $wp_theme_directories = array (0 => '/private/tmp/wordpress-tests-lib/includes/../data/themedir1', 1 => '/tmp/wordpress/wp-content/themes')
    
    Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /private/tmp/wordpress-tests-lib/includes/testcase.php on line 15
    
    Call Stack:
        0.0044     492280   1. {main}() /usr/local/bin/phpunit:0
        0.1121    8002480   2. PHPUnit\TextUI\Command::main(???) /usr/local/bin/phpunit:545
        0.1121    8002592   3. PHPUnit\TextUI\Command->run(???, ???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:140
        0.1121    8002592   4. PHPUnit\TextUI\Command->handleArguments(???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:151
        0.1140    8005936   5. PHPUnit\TextUI\Command->handleBootstrap(???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:730
        0.1140    8005936   6. PHPUnit\Util\Fileloader::checkAndLoad(???) phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:908
        0.1141    8006208   7. PHPUnit\Util\Fileloader::load(???) phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:45
        0.1144    8024688   8. include_once('/Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php') phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:61
        0.1144    8024688   9. WC_Unit_Tests_Bootstrap::instance() /Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php:140
        0.1144    8024784  10. WC_Unit_Tests_Bootstrap->__construct() /Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php:133
        0.1159    8196168  11. require_once('/private/tmp/wordpress-tests-lib/includes/bootstrap.php') /Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce/tests/bootstrap.php:50
        4.2284   43815944  12. require('/private/tmp/wordpress-tests-lib/includes/testcase.php') /private/tmp/wordpress-tests-lib/includes/bootstrap.php:97

    The test installer output:

    jpmpro:woocommerce jon$ tests/bin/install.sh woo3phpunit root root localhost:8889
    + install_wp
    + '[' -d /tmp/wordpress/ ']'
    + mkdir -p /tmp/wordpress/
    + '[' latest == latest ']'
    + local ARCHIVE_NAME=latest
    + download https://wordpress.org/latest.tar.gz /tmp/wordpress.tar.gz
    ++ which curl
    + '[' /usr/local/php5/bin/curl ']'
    + curl -s https://wordpress.org/latest.tar.gz
    + tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C /tmp/wordpress/
    + download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php /tmp/wordpress//wp-content/db.php
    ++ which curl
    + '[' /usr/local/php5/bin/curl ']'
    + curl -s https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
    + install_test_suite
    ++ uname -s
    + [[ Darwin == \D\a\r\w\i\n ]]
    + local 'ioption=-i .bak'
    + '[' '!' -d /tmp/wordpress-tests-lib ']'
    + mkdir -p /tmp/wordpress-tests-lib
    + svn co --quiet https://develop.svn.wordpress.org/tags/4.7.4/tests/phpunit/includes/ /tmp/wordpress-tests-lib/includes
    + cd /tmp/wordpress-tests-lib
    + '[' '!' -f wp-tests-config.php ']'
    + download https://develop.svn.wordpress.org/tags/4.7.4/wp-tests-config-sample.php /tmp/wordpress-tests-lib/wp-tests-config.php
    ++ which curl
    + '[' /usr/local/php5/bin/curl ']'
    + curl -s https://develop.svn.wordpress.org/tags/4.7.4/wp-tests-config-sample.php
    + sed -i .bak 's:dirname( __FILE__ ) . '\''/src/'\'':'\''/tmp/wordpress/'\'':' /tmp/wordpress-tests-lib/wp-tests-config.php
    + sed -i .bak s/youremptytestdbnamehere/woo3phpunit/ /tmp/wordpress-tests-lib/wp-tests-config.php
    + sed -i .bak s/yourusernamehere/root/ /tmp/wordpress-tests-lib/wp-tests-config.php
    + sed -i .bak s/yourpasswordhere/root/ /tmp/wordpress-tests-lib/wp-tests-config.php
    + sed -i .bak 's|localhost|localhost:8889|' /tmp/wordpress-tests-lib/wp-tests-config.php
    + install_db
    + PARTS=(${DB_HOST//\:/ })
    + local PARTS
    + local DB_HOSTNAME=localhost
    + local DB_SOCK_OR_PORT=8889
    + local EXTRA=
    + '[' -z localhost ']'
    ++ echo 8889
    ++ grep -e '^[0-9]\{1,\}$'
    + '[' 8889 ']'
    + EXTRA=' --host=localhost --port=8889 --protocol=tcp'
    + mysqladmin create woo3phpunit --user=root --password=root --host=localhost --port=8889 --protocol=tcp
    mysqladmin: [Warning] Using a password on the command line interface can be insecure.

    Additional context information:

    jpmpro:woocommerce jon$ phpunit --version
    PHPUnit 6.1.2 by Sebastian Bergmann and contributors.
    jpmpro:woocommerce jon$ which php
    /Applications/MAMP/bin/php/php7.0.15/bin/php
    jpmpro:woocommerce jon$ wp --version
    WP-CLI 1.1.0
    jpmpro:woocommerce jon$ pwd
    /Applications/MAMP/htdocs/woo3test/wp-content/plugins/woocommerce
    jpmpro:woocommerce jon$ mysqlshow --user=root --password=root --host=localhost --port=8889 --protocol=tcp
    mysqlshow: [Warning] Using a password on the command line interface can be insecure.
    +--------------------+
    |     Databases      |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | woo3debug          |
    | woo3phpunit        |
    | woo3test           |
    +--------------------+
Viewing 1 replies (of 1 total)
  • jonmoore

    (@jonathanmoorebcsorg)

    The specific problem of the missing data directory can be resolved by finding it in the WordPress test repository:

    $ svn co https://develop.svn.wordpress.org/trunk/ wordpress-develop
    $ cd wordpress-develop

    as advised on make wordpress

    However this wasn’t the first error and isn’t the last.
    The next error is:

    jpmpro:woocommerce jon$ phpunit
    Installing...
    Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
    Installing WooCommerce...
    
    Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /private/tmp/wordpress-tests-lib/includes/testcase.php on line 15

    this is referenced on trac #39822 closed 2 days ago, which includes a number of changes and a new phpunit6-compat.php file.

    So, then svn/wordpress-develop/tests/phpunit/includes should also be copied to the directory /private/tmp/wordpress-tests-lib/includes which was created by the WooCommerce test installer.

Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce PHPUnit test instructions fail’ is closed to new replies.