Skip to content

Commit 9fe8ed8

Browse files
committed
Additional test scenario
1 parent 528162d commit 9fe8ed8

File tree

1 file changed

+120
-1
lines changed

1 file changed

+120
-1
lines changed

features/install-wp-tests.feature

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Feature: Scaffold install-wp-tests.sh tests
134134
"""
135135
136136
@require-php-8.0 @less-than-wp-5.8
137-
Scenario: Install latest version of WordPress on PHP 8.0+
137+
Scenario: Install latest version of WordPress on PHP 8.0+ and WordPress less then 5.8
138138
Given a WP install
139139
And a affirmative-response file:
140140
"""
@@ -264,6 +264,125 @@ Feature: Scaffold install-wp-tests.sh tests
264264
Leaving the existing database (wp_cli_test_scaffold) in place
265265
"""
266266
267+
@require-php-8.0 @require-wp-5.8
268+
Scenario: Install latest version of WordPress on PHP 8.0+ and WordPress above 5.8
269+
Given a WP install
270+
And a affirmative-response file:
271+
"""
272+
Y
273+
"""
274+
And a negative-response file:
275+
"""
276+
No
277+
"""
278+
And a get-phpunit-phar-url.php file:
279+
"""
280+
<?php
281+
$version = 4;
282+
if(PHP_VERSION_ID >= 50600) {
283+
$version = 5;
284+
}
285+
if(PHP_VERSION_ID >= 70000) {
286+
$version = 6;
287+
}
288+
if(PHP_VERSION_ID >= 70100) {
289+
$version = 7;
290+
}
291+
if(PHP_VERSION_ID >= 80000) {
292+
$version = 9;
293+
}
294+
echo "https://phar.phpunit.de/phpunit-{$version}.phar";
295+
"""
296+
And I run `wp eval-file get-phpunit-phar-url.php --skip-wordpress`
297+
And save STDOUT as {PHPUNIT_PHAR_URL}
298+
And I run `wget -q -O phpunit {PHPUNIT_PHAR_URL}`
299+
And I run `chmod +x phpunit`
300+
And I run `wp plugin path`
301+
And save STDOUT as {PLUGIN_DIR}
302+
And I run `wp scaffold plugin hello-world`
303+
# This throws a warning for the password provided via command line.
304+
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"`
305+
306+
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`
307+
Then the return code should be 0
308+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
309+
"""
310+
data
311+
"""
312+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
313+
"""
314+
includes
315+
"""
316+
And the {RUN_DIR}/wordpress-tests-lib directory should contain:
317+
"""
318+
wp-tests-config.php
319+
"""
320+
And the {RUN_DIR}/wordpress directory should contain:
321+
"""
322+
index.php
323+
license.txt
324+
readme.html
325+
wp-activate.php
326+
wp-admin
327+
wp-blog-header.php
328+
wp-comments-post.php
329+
wp-config-sample.php
330+
wp-content
331+
wp-cron.php
332+
wp-includes
333+
wp-links-opml.php
334+
wp-load.php
335+
wp-login.php
336+
wp-mail.php
337+
wp-settings.php
338+
wp-signup.php
339+
wp-trackback.php
340+
xmlrpc.php
341+
"""
342+
And the {PLUGIN_DIR}/hello-world/phpunit.xml.dist file should exist
343+
And STDERR should contain:
344+
"""
345+
install_test_suite
346+
"""
347+
348+
# This throws a warning for the password provided via command line.
349+
When I try `mysql -u{DB_USER} -p{DB_PASSWORD} -h{MYSQL_HOST} -P{MYSQL_PORT} --protocol=tcp -e "SHOW DATABASES"`
350+
And STDOUT should contain:
351+
"""
352+
wp_cli_test_scaffold
353+
"""
354+
355+
When I run `mkdir polyfills && composer init --name=test/package --require="yoast/phpunit-polyfills:^1" --no-interaction --quiet --working-dir=polyfills`
356+
Then the return code should be 0
357+
358+
When I run `composer install --no-interaction --working-dir=polyfills --quiet`
359+
Then the return code should be 0
360+
361+
When I run `WP_TESTS_DIR={RUN_DIR}/wordpress-tests-lib WP_TESTS_PHPUNIT_POLYFILLS_PATH={RUN_DIR}/polyfills/vendor/yoast/phpunit-polyfills ./phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
362+
Then the return code should be 0
363+
364+
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`
365+
Then the return code should be 0
366+
And STDERR should contain:
367+
"""
368+
Reinstalling
369+
"""
370+
And STDOUT should contain:
371+
"""
372+
Recreated the database (wp_cli_test_scaffold)
373+
"""
374+
375+
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`
376+
Then the return code should be 0
377+
And STDERR should contain:
378+
"""
379+
Reinstalling
380+
"""
381+
And STDOUT should contain:
382+
"""
383+
Leaving the existing database (wp_cli_test_scaffold) in place
384+
"""
385+
267386
Scenario: Install WordPress from trunk
268387
Given a WP install
269388
And a get-phpunit-phar-url.php file:

0 commit comments

Comments
 (0)