wp-phpunit / issues

Central issues repository for wp-phpunit
0 stars 0 forks source link

Undefined constants #6

Closed andrewmclagan closed 4 years ago

andrewmclagan commented 5 years ago

PHP Notice: Undefined index: SERVER_NAME in /var/www/wordpress/wp-includes/rest-api.php on line 378

andrewmclagan commented 5 years ago

Investigating why this is the case, could be my abnormal Wordpress installation location. we have the wp-content dir outside normal location.

andrewmclagan commented 5 years ago

No sorry, replicated the setup on some of your repos that use this harness.

Undefined index: HTTP_HOST in /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/functions.php on line 4398

PHP Notice:  Undefined index: HTTP_HOST in /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/functions.php on line 4398

Notice: Undefined index: HTTP_HOST in /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/functions.php on line 4398
PHP Notice:  Undefined index: SERVER_PROTOCOL in /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/load.php on line 16

Notice: Undefined index: SERVER_PROTOCOL in /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/load.php on line 16
PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/functions.php:4398) in /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/pluggable.php on line 1219

Warning: Cannot modify header information - headers already sent by (output started at /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/functions.php:4398) in /var/www/wordpress/wp-content/plugins/XXXXX/wordpress/wp-includes/pluggable.php on line 1219

XXXX == plugin name

andrewmclagan commented 5 years ago

Not a huge issue if I disable WP_DEBUG i guess...

andrewmclagan commented 5 years ago

More:

PHP Notice:  Constant WP_LANG_DIR already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 39

Notice: Constant WP_LANG_DIR already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 39
PHP Notice:  Constant DISABLE_WP_CRON already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 45

Notice: Constant DISABLE_WP_CRON already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 45
PHP Notice:  Constant WP_MEMORY_LIMIT already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 47

Notice: Constant WP_MEMORY_LIMIT already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 47
PHP Notice:  Constant WP_MAX_MEMORY_LIMIT already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 48

Notice: Constant WP_MAX_MEMORY_LIMIT already defined in /var/www/wordpress/wp-content/plugins/XXXX/vendor/wp-phpunit/wp-phpunit/includes/bootstrap.php on line 48
andrewmclagan commented 5 years ago

Many of them are caused by loading Wordpress then attempting to define the variables...

in the wp-phpunit bootstrap file

andrewmclagan commented 5 years ago

see PR https://github.com/wp-phpunit/wp-phpunit/pull/1

andrewmclagan commented 5 years ago

Also I add the following to my config to negate the $_SERVER issues:

// $_SERVER undefined issues
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
$_SERVER['SERVER_NAME'] = '';
$_SERVER['HTTP_HOST'] = 'beamaustralia.local';
aaemnnosttv commented 5 years ago

This may be an issue with your setup, I don't see these notices in the build for the example plugin: https://travis-ci.org/wp-phpunit/example-plugin/jobs/559839044

If you have constants you wish to define, you should include them in your wp-tests-config.php.