• Resolved mysti9uemirage

    (@mysti9uemirage)


    I’m following this tutorial: https://pippinsplugins.com/unit-tests-wordpress-plugins-setting-up-testing-suite/
    I got to the point where I ran sh bin/install-wp-tests.sh hl_market_tracker_tests root '' localhost latest and it generated a %Temp%\wordpress and %Temp%\wordpress-tests-lib folder. However, when I run phpunit,

    I got

    Fatal error: require_once(): Failed opening required '/tmp/wordpress//wp-includes/class-phpmailer.php' (include_path='C:\xampp\php\PEAR') in C:\Users\Duy\AppData\Local\Temp\wordpress-tests-lib\includes\mock-mailer.php on line 2
    
    Call Stack:
        0.4183     347496   1. {main}() C:\xampp\php\phpunit:0
        0.4228     526008   2. PHPUnit_TextUI_Command::main() C:\xampp\php\phpunit:46
        0.4228     528312   3. PHPUnit_TextUI_Command->run() C:\xampp\php\pear\PHPUnit\TextUI\Command.php:129
        0.4228     528312   4. PHPUnit_TextUI_Command->handleArguments() C:\xampp\php\pear\PHPUnit\TextUI\Command.php:138
        0.4260     781328   5. PHPUnit_TextUI_Command->handleBootstrap() C:\xampp\php\pear\PHPUnit\TextUI\Command.php:606
        0.4263     786608   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\xampp\php\pear\PHPUnit\TextUI\Command.php:778
        0.4269     786720   7. PHPUnit_Util_Fileloader::load() C:\xampp\php\pear\PHPUnit\Util\Fileloader.php:76
        0.4271     790832   8. include_once('C:\xampp\apps\summit\htdocs\wp-content\plugins\hl-market-tracker\tests\bootstrap.php') C:\xampp\php\pear\PHPUnit\Util\Fileloader.php:92
        0.4288     861336   9. require('C:\Users\Duy\AppData\Local\Temp\wordpress-tests-lib\includes\bootstrap.php') C:\xampp\apps\summit\htdocs\wp-content\plugins\hl-market-tracker\tests\bootstrap.php:31
        0.4296     878272  10. require_once('C:\Users\Duy\AppData\Local\Temp\wordpress-tests-lib\includes\mock-mailer.php') C:\Users\Duy\AppData\Local\Temp\wordpress-tests-lib\includes\bootstrap.php:60

    The reason for that was that
    C:\Users\Duy\AppData\Local\Temp\wordpress-tests-lib\includes\mock-mailer.php on line 2
    has require_once( ABSPATH . ‘/wp-includes/class-phpmailer.php’ );
    However, class-phpmailer was in wordpress/wp-includes and it was trying to find it in /tmp/wordpress//wp-includes/class-phpmailer.php

    If I changed ABSPATH in mock-mailer to have the correct path, then it will work. Is this something wrong with the library? I’m trying to run PHPUnit to test my WP plugin and I have XAAMP on Windows. Thank you.

Viewing 1 replies (of 1 total)
  • Thread Starter mysti9uemirage

    (@mysti9uemirage)

    Edit define (‘ABSPATH’ … in wordpress-test-lib\wp-tests-config.php to point to the correct path instead of ‘tmp/wordpress/’

Viewing 1 replies (of 1 total)
  • The topic ‘WP-CLI install-wp-tests required files cannot be found’ is closed to new replies.