Skip to content

Commit 09254cd

Browse files
committed
Revert "Remove version-specific branches in tests"
This reverts commit 04119db.
1 parent f5a1f10 commit 09254cd

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

features/install-wp-tests.feature

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Feature: Scaffold install-wp-tests.sh tests
1414
"""
1515
And the return code should be 1
1616

17+
@require-php-5.6 @less-than-php-8.0
1718
Scenario: Install latest version of WordPress
1819
Given a WP install
1920
And a affirmative-response file:
@@ -132,6 +133,131 @@ Feature: Scaffold install-wp-tests.sh tests
132133
Leaving the existing database (wp_cli_test_scaffold) in place
133134
"""
134135
136+
@require-php-8.0
137+
Scenario: Install latest version of WordPress on PHP 8.0+
138+
Given a WP install
139+
And a affirmative-response file:
140+
"""
141+
Y
142+
"""
143+
And a negative-response file:
144+
"""
145+
No
146+
"""
147+
And a get-phpunit-phar-url.php file:
148+
"""
149+
<?php
150+
$version = 4;
151+
if(PHP_VERSION_ID >= 50600) {
152+
$version = 5;
153+
}
154+
if(PHP_VERSION_ID >= 70000) {
155+
$version = 6;
156+
}
157+
if(PHP_VERSION_ID >= 70100) {
158+
$version = 7;
159+
}
160+
if(PHP_VERSION_ID >= 80000) {
161+
$version = 9;
162+
}
163+
echo "https://phar.phpunit.de/phpunit-{$version}.phar";
164+
"""
165+
And I run `wp eval-file get-phpunit-phar-url.php --skip-wordpress`
166+
And save STDOUT as {PHPUNIT_PHAR_URL}
167+
And I run `wget -q -O phpunit {PHPUNIT_PHAR_URL}`
168+
And I run `chmod +x phpunit`
169+
And I run `wp plugin path`
170+
And save STDOUT as {PLUGIN_DIR}
171+
And I run `wp scaffold plugin hello-world`
172+
# This throws a warning for the password provided via command line.
173+
And I try `mysql -u{DB_USER} -p{DB_PASSWORD} -h{MYSQL_HOST} -P{MYSQL_PORT} --protocol=tcp -e "DROP DATABASE IF EXISTS wp_cli_test_scaffold"`
174+
175+
When I try `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib WP_CORE_DIR={RUN_DIR}/wordpress /usr/bin/env bash {PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh wp_cli_test_scaffold {DB_USER} {DB_PASSWORD} {DB_HOST} latest`
176+
Then the return code should be 0
177+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
178+
"""
179+
data
180+
"""
181+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
182+
"""
183+
includes
184+
"""
185+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
186+
"""
187+
wp-tests-config.php
188+
"""
189+
And the {RUN_DIR}/wordpress directory should contain:
190+
"""
191+
index.php
192+
license.txt
193+
readme.html
194+
wp-activate.php
195+
wp-admin
196+
wp-blog-header.php
197+
wp-comments-post.php
198+
wp-config-sample.php
199+
wp-content
200+
wp-cron.php
201+
wp-includes
202+
wp-links-opml.php
203+
wp-load.php
204+
wp-login.php
205+
wp-mail.php
206+
wp-settings.php
207+
wp-signup.php
208+
wp-trackback.php
209+
xmlrpc.php
210+
"""
211+
And the {PLUGIN_DIR}/hello-world/phpunit.xml.dist file should exist
212+
And STDERR should contain:
213+
"""
214+
install_test_suite
215+
"""
216+
217+
# This throws a warning for the password provided via command line.
218+
When I try `mysql -u{DB_USER} -p{DB_PASSWORD} -h{MYSQL_HOST} -P{MYSQL_PORT} --protocol=tcp -e "SHOW DATABASES"`
219+
And STDOUT should contain:
220+
"""
221+
wp_cli_test_scaffold
222+
"""
223+
224+
When I try `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
225+
Then the return code should be 1
226+
And STDOUT should contain:
227+
"""
228+
Looks like you're using PHPUnit 9.5.
229+
"""
230+
And STDOUT should contain:
231+
"""
232+
WordPress requires at least PHPUnit 5.
233+
"""
234+
And STDOUT should contain:
235+
"""
236+
and is currently only compatible with PHPUnit up to 7.x.
237+
"""
238+
239+
When I try `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib WP_CORE_DIR={RUN_DIR}/wordpress /usr/bin/env bash {PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh wp_cli_test_scaffold {DB_USER} {DB_PASSWORD} {DB_HOST} latest < affirmative-response`
240+
Then the return code should be 0
241+
And STDERR should contain:
242+
"""
243+
Reinstalling
244+
"""
245+
And STDOUT should contain:
246+
"""
247+
Recreated the database (wp_cli_test_scaffold)
248+
"""
249+
250+
When I try `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib WP_CORE_DIR={RUN_DIR}/wordpress /usr/bin/env bash {PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh wp_cli_test_scaffold {DB_USER} {DB_PASSWORD} {DB_HOST} latest < negative-response`
251+
Then the return code should be 0
252+
And STDERR should contain:
253+
"""
254+
Reinstalling
255+
"""
256+
And STDOUT should contain:
257+
"""
258+
Leaving the existing database (wp_cli_test_scaffold) in place
259+
"""
260+
135261
Scenario: Install WordPress from trunk
136262
Given a WP install
137263
And a get-phpunit-phar-url.php file:

0 commit comments

Comments
 (0)