Title: Cannot unit test with phpunit
Last modified: November 2, 2018

---

# Cannot unit test with phpunit

 *  Resolved [termel](https://wordpress.org/support/users/munger41/)
 * (@munger41)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/cannot-unit-test-with-phpunit/)
 * Hi,
 * I am new to wp-cli and phpunit and following the tutorial in order to create 
   first php tests for my plugin on a Ubuntu box : [https://make.wordpress.org/cli/handbook/plugin-unit-tests/](https://make.wordpress.org/cli/handbook/plugin-unit-tests/)
 * I made the whole tutorial but when luanching the command phpunit i get the following
   errors:
 *     ```
       root@maxiserver:/var/www/mysite.com/wp-content/plugins/my-plugin# phpunit
       Installing...
       Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
       PHP Warning:  require(/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin/.php): failed to open stream: No such file or directory in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
   
       Warning: require(/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin/.php): failed to open stream: No such file or directory in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
       PHP Fatal error:  require(): Failed opening required '/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin/.php' (include_path='.:/usr/share/php') in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
   
       Fatal error: require(): Failed opening required '/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin/.php' (include_path='.:/usr/share/php') in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
       ```
   
 * And yes the bootstrap.php file contains a strange function :
 *     ```
       function _manually_load_plugin() {
               require dirname( dirname( __FILE__ ) ) . '/my-plugin/.php';
       } 
       ```
   
 * Did the scaffold command worked properly ?
 * `wp scaffold plugin-tests my-plugin`
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [termel](https://wordpress.org/support/users/munger41/)
 * (@munger41)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/cannot-unit-test-with-phpunit/#post-10842176)
 * Ok, i had to rerun wp scaffold plugin-tests my-plugin command from the root of
   my wordpress folder (it’s not told in the official link).
    But the problem stays
   the same unless the php file path is now correct:
 *     ```
       root@maxiserver:/var/www/mysite.com/wp-content/plugins/my-plugin# phpunit
       Installing...
       Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
       PHP Warning:  require(/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin.php): failed to open stream: No such file or directory in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
   
       Warning: require(/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin.php): failed to open stream: No such file or directory in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
       PHP Fatal error:  require(): Failed opening required '/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin.php' (include_path='.:/usr/share/php') in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
   
       Fatal error: require(): Failed opening required '/var/www/mysite.com/wp-content/plugins/my-plugin/my-plugin.php' (include_path='.:/usr/share/php') in /var/www/mysite.com/wp-content/plugins/my-plugin/tests/bootstrap.php on line 26
       ```
   
 * Any idea ?
 *  Thread Starter [termel](https://wordpress.org/support/users/munger41/)
 * (@munger41)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/cannot-unit-test-with-phpunit/#post-10842325)
 * Ok, the problem was that the main plugin file was different from the plugin directory.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cannot unit test with phpunit’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 1 participant
 * Last reply from: [termel](https://wordpress.org/support/users/munger41/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/cannot-unit-test-with-phpunit/#post-10842325)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
