Skip to content

Commit 5b2bf64

Browse files
committed
Remove test destinction between PHP <8 and >=8
1 parent fea4ec8 commit 5b2bf64

File tree

1 file changed

+34
-139
lines changed

1 file changed

+34
-139
lines changed

features/install-wp-tests.feature

Lines changed: 34 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,22 @@ Feature: Scaffold install-wp-tests.sh tests
5252
And I run `wp scaffold plugin hello-world`
5353
# This throws a warning for the password provided via command line.
5454
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"`
55-
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
56-
And I try `rm -fr /tmp/behat-wordpress`
5755

58-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-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`
56+
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`
5957
Then the return code should be 0
60-
And the /tmp/behat-wordpress-tests-lib directory should contain:
58+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
6159
"""
6260
data
6361
"""
64-
And the /tmp/behat-wordpress-tests-lib directory should contain:
62+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
6563
"""
6664
includes
6765
"""
68-
And the /tmp/behat-wordpress-tests-lib directory should contain:
66+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
6967
"""
7068
wp-tests-config.php
7169
"""
72-
And the /tmp/behat-wordpress directory should contain:
70+
And the {RUN_DIR}/wordpress directory should contain:
7371
"""
7472
index.php
7573
license.txt
@@ -104,10 +102,10 @@ Feature: Scaffold install-wp-tests.sh tests
104102
wp_cli_test_scaffold
105103
"""
106104

107-
When I run `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
105+
When I run `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
108106
Then the return code should be 0
109107

110-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-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`
108+
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`
111109
Then the return code should be 0
112110
And STDERR should contain:
113111
"""
@@ -118,7 +116,7 @@ Feature: Scaffold install-wp-tests.sh tests
118116
Recreated the database (wp_cli_test_scaffold)
119117
"""
120118
121-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-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`
119+
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`
122120
Then the return code should be 0
123121
And STDERR should contain:
124122
"""
@@ -167,24 +165,22 @@ Feature: Scaffold install-wp-tests.sh tests
167165
And I run `wp scaffold plugin hello-world`
168166
# This throws a warning for the password provided via command line.
169167
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"`
170-
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
171-
And I try `rm -fr /tmp/behat-wordpress`
172168
173-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-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`
169+
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`
174170
Then the return code should be 0
175-
And the /tmp/behat-wordpress-tests-lib directory should contain:
171+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
176172
"""
177173
data
178174
"""
179-
And the /tmp/behat-wordpress-tests-lib directory should contain:
175+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
180176
"""
181177
includes
182178
"""
183-
And the /tmp/behat-wordpress-tests-lib directory should contain:
179+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
184180
"""
185181
wp-tests-config.php
186182
"""
187-
And the /tmp/behat-wordpress directory should contain:
183+
And the {RUN_DIR}/wordpress directory should contain:
188184
"""
189185
index.php
190186
license.txt
@@ -219,14 +215,14 @@ Feature: Scaffold install-wp-tests.sh tests
219215
wp_cli_test_scaffold
220216
"""
221217
222-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
218+
When I try `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
223219
Then the return code should be 1
224220
And STDOUT should contain:
225221
"""
226222
The scaffolded tests cannot currently be run on PHP 8.0+. See https://github.com/wp-cli/scaffold-command/issues/285
227223
"""
228224
229-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-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`
225+
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`
230226
Then the return code should be 0
231227
And STDERR should contain:
232228
"""
@@ -237,7 +233,7 @@ Feature: Scaffold install-wp-tests.sh tests
237233
Recreated the database (wp_cli_test_scaffold)
238234
"""
239235
240-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-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`
236+
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`
241237
Then the return code should be 0
242238
And STDERR should contain:
243239
"""
@@ -248,7 +244,6 @@ Feature: Scaffold install-wp-tests.sh tests
248244
Leaving the existing database (wp_cli_test_scaffold) in place
249245
"""
250246
251-
@require-php-5.6 @less-than-php-8.0
252247
Scenario: Install WordPress from trunk
253248
Given a WP install
254249
And a get-phpunit-phar-url.php file:
@@ -278,39 +273,37 @@ Feature: Scaffold install-wp-tests.sh tests
278273
And I run `wp scaffold plugin hello-world`
279274
# This throws a warning for the password provided via command line.
280275
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"`
281-
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
282-
And I try `rm -fr /tmp/behat-wordpress`
283276
284-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-wordpress /usr/bin/env bash {PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh wp_cli_test_scaffold {DB_USER} {DB_PASSWORD} {DB_HOST} trunk`
277+
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} trunk`
285278
Then the return code should be 0
286-
And the /tmp/behat-wordpress-tests-lib directory should contain:
279+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
287280
"""
288281
data
289282
"""
290-
And the /tmp/behat-wordpress-tests-lib directory should contain:
283+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
291284
"""
292285
includes
293286
"""
294-
And the /tmp/behat-wordpress-tests-lib directory should contain:
287+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
295288
"""
296289
wp-tests-config.php
297290
"""
298-
And the /tmp/behat-wordpress directory should contain:
291+
And the {RUN_DIR}/wordpress directory should contain:
299292
"""
300293
index.php
301294
"""
302295
303296
# WP 5.0+: js
304297
305-
And the /tmp/behat-wordpress directory should contain:
298+
And the {RUN_DIR}/wordpress directory should contain:
306299
"""
307300
license.txt
308301
readme.html
309302
"""
310303
311304
# WP 5.0+: styles
312305
313-
And the /tmp/behat-wordpress directory should contain:
306+
And the {RUN_DIR}/wordpress directory should contain:
314307
"""
315308
wp-activate.php
316309
wp-admin
@@ -329,7 +322,7 @@ Feature: Scaffold install-wp-tests.sh tests
329322
wp-trackback.php
330323
xmlrpc.php
331324
"""
332-
And the contents of the /tmp/behat-wordpress/wp-includes/version.php file should match /\-(alpha|beta[0-9]+|RC[0-9]+)\-/
325+
And the contents of the {RUN_DIR}/wordpress/wp-includes/version.php file should match /\-(alpha|beta[0-9]+|RC[0-9]+)\-/
333326
And the {PLUGIN_DIR}/hello-world/phpunit.xml.dist file should exist
334327
And STDERR should contain:
335328
"""
@@ -343,110 +336,14 @@ Feature: Scaffold install-wp-tests.sh tests
343336
wp_cli_test_scaffold
344337
"""
345338
346-
When I run `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
339+
When I run `composer init --no-interaction --quiet --name=wp-cli/test-scenario --require="yoast/phpunit-polyfills=^1.0.1" --working-dir={RUN_DIR}/wordpress-tests-lib`
347340
Then the return code should be 0
348341
349-
@require-php-8.0
350-
Scenario: Install WordPress from trunk for PHP 8.0+
351-
Given a WP install
352-
And a get-phpunit-phar-url.php file:
353-
"""
354-
<?php
355-
$version = 4;
356-
if(PHP_VERSION_ID >= 50600) {
357-
$version = 5;
358-
}
359-
if(PHP_VERSION_ID >= 70000) {
360-
$version = 6;
361-
}
362-
if(PHP_VERSION_ID >= 70100) {
363-
$version = 7;
364-
}
365-
if(PHP_VERSION_ID >= 80000) {
366-
$version = 9;
367-
}
368-
echo "https://phar.phpunit.de/phpunit-{$version}.phar";
369-
"""
370-
And I run `wp eval-file get-phpunit-phar-url.php --skip-wordpress`
371-
And save STDOUT as {PHPUNIT_PHAR_URL}
372-
And I run `wget -q -O phpunit {PHPUNIT_PHAR_URL}`
373-
And I run `chmod +x phpunit`
374-
And I run `wp plugin path`
375-
And save STDOUT as {PLUGIN_DIR}
376-
And I run `wp scaffold plugin hello-world`
377-
# This throws a warning for the password provided via command line.
378-
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"`
379-
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
380-
And I try `rm -fr /tmp/behat-wordpress`
381-
382-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-wordpress /usr/bin/env bash {PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh wp_cli_test_scaffold {DB_USER} {DB_PASSWORD} {DB_HOST} trunk`
342+
When I run `composer install --no-interaction --quiet --working-dir={RUN_DIR}/wordpress-tests-lib`
383343
Then the return code should be 0
384-
And the /tmp/behat-wordpress-tests-lib directory should contain:
385-
"""
386-
data
387-
"""
388-
And the /tmp/behat-wordpress-tests-lib directory should contain:
389-
"""
390-
includes
391-
"""
392-
And the /tmp/behat-wordpress-tests-lib directory should contain:
393-
"""
394-
wp-tests-config.php
395-
"""
396-
And the /tmp/behat-wordpress directory should contain:
397-
"""
398-
index.php
399-
"""
400-
401-
# WP 5.0+: js
402344
403-
And the /tmp/behat-wordpress directory should contain:
404-
"""
405-
license.txt
406-
readme.html
407-
"""
408-
409-
# WP 5.0+: styles
410-
411-
And the /tmp/behat-wordpress directory should contain:
412-
"""
413-
wp-activate.php
414-
wp-admin
415-
wp-blog-header.php
416-
wp-comments-post.php
417-
wp-config-sample.php
418-
wp-content
419-
wp-cron.php
420-
wp-includes
421-
wp-links-opml.php
422-
wp-load.php
423-
wp-login.php
424-
wp-mail.php
425-
wp-settings.php
426-
wp-signup.php
427-
wp-trackback.php
428-
xmlrpc.php
429-
"""
430-
And the contents of the /tmp/behat-wordpress/wp-includes/version.php file should match /\-(alpha|beta[0-9]+|RC[0-9]+)\-/
431-
And the {PLUGIN_DIR}/hello-world/phpunit.xml.dist file should exist
432-
And STDERR should contain:
433-
"""
434-
install_test_suite
435-
"""
436-
437-
# This throws a warning for the password provided via command line.
438-
When I try `mysql -u{DB_USER} -p{DB_PASSWORD} -h{MYSQL_HOST} -P{MYSQL_PORT} --protocol=tcp -e "SHOW DATABASES"`
439-
And STDOUT should contain:
440-
"""
441-
wp_cli_test_scaffold
442-
"""
443-
444-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
445-
Then the return code should be 1
446-
And STDOUT should contain:
447-
"""
448-
The scaffolded tests cannot currently be run on PHP 8.0+. See https://github.com/wp-cli/scaffold-command/issues/285
449-
"""
345+
When I run `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib WP_TESTS_PHPUNIT_POLYFILLS_PATH={RUN_DIR}/wordpress-tests-lib/vendor/yoast/phpunit-polyfills ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
346+
Then the return code should be 0
450347
451348
Scenario: Install WordPress 3.7 and phpunit will not run
452349
Given a WP install
@@ -455,24 +352,22 @@ Feature: Scaffold install-wp-tests.sh tests
455352
And I run `wp scaffold plugin hello-world`
456353
# This throws a warning for the password provided via command line.
457354
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"`
458-
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
459-
And I try `rm -fr /tmp/behat-wordpress`
460355
461-
When I try `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-wordpress /usr/bin/env bash {PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh wp_cli_test_scaffold {DB_USER} {DB_PASSWORD} {DB_HOST} 3.7`
356+
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} 3.7`
462357
Then the return code should be 0
463-
And the /tmp/behat-wordpress-tests-lib directory should contain:
358+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
464359
"""
465360
data
466361
"""
467-
And the /tmp/behat-wordpress-tests-lib directory should contain:
362+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
468363
"""
469364
includes
470365
"""
471-
And the /tmp/behat-wordpress-tests-lib directory should contain:
366+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
472367
"""
473368
wp-tests-config.php
474369
"""
475-
And the /tmp/behat-wordpress directory should contain:
370+
And the {RUN_DIR}/wordpress directory should contain:
476371
"""
477372
index.php
478373
license.txt
@@ -494,7 +389,7 @@ Feature: Scaffold install-wp-tests.sh tests
494389
wp-trackback.php
495390
xmlrpc.php
496391
"""
497-
And the /tmp/behat-wordpress/wp-includes/version.php file should contain:
392+
And the {RUN_DIR}/wordpress/wp-includes/version.php file should contain:
498393
"""
499394
3.7
500395
"""

0 commit comments

Comments
 (0)