scaffold-command
scaffold-command copied to clipboard
Bitbucket CI Tests do not work correctly
The Bitbucket CI Tests added with the wp scaffold plugin-tests
command do not work correctly.
I always get following error with phpcs test.
<1s
+ phpcs
ERROR: Referenced sniff "PHPCompatibilityWP" does not exist
Run "phpcs --help" for usage information
When I try to skip the phpcs test (commenting it out) I get another error with the phpunit test:
+ phpunit
wp_die called
Message : <h1>Error establishing a database connection</h1>
<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can’t contact the database server at <code>127.0.0.1</code>. This could mean your host’s database server is down.</p>
<ul>
<li>Are you sure you have the correct username and password?</li>
<li>Are you sure that you have typed the correct hostname?</li>
<li>Are you sure that the database server is running?</li>
</ul>
<p>If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="https://wordpress.org/support/">WordPress Support Forums</a>.</p>
Title :
Steps to reproduce:
- Create a new plugin with the
wp scaffold plugin my-test-plugin
command - Add plugin tests for bitbucket with the
wp scaffold plugin-tests my-test-plugin --ci=bitbucket
command - Add a remote bitbucket repository with pipelines enabled
- Push to remote
- Open Bitbucket pipelines for the repository.
I didn't edit any of the plugin files, i only used wp cli to add a blank plugin with bitbucket CI-tests
I'm using WP-CLI version 2.1.0
I am also experiencing this issue.
I was able to solve the problem.
On the .phpcs.xml.dist
, comment the PHPCompatibilityWP
rule
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<!-- <rule ref="PHPCompatibilityWP"/> -->
On the bitbucket-pipelines.yml, update the database definition similar below:
definitions:
services:
database:
image: mysql:5.7
environment:
MYSQL_DATABASE: 'sample_database'
MYSQL_ROOT_PASSWORD: 'root'
On the bitbucket-pipelines.yml, update the "# Run PHPUnit" section to:
# Run PHPUnit
- bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest
PHPUnit cannot access the database due to permission. PHPUnit should be the one to create the database.