Skip to content

Commit

Permalink
Merge pull request #37 from miya0001/add-tests-for-install-wp-tests
Browse files Browse the repository at this point in the history
add behat tests for install-wp-tests.sh
  • Loading branch information
danielbachhuber authored Aug 8, 2017
2 parents 4cba13e + df4e6e4 commit 2e6f08b
Showing 1 changed file with 188 additions and 0 deletions.
188 changes: 188 additions & 0 deletions features/install-wp-tests.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
Feature: Scaffold install-wp-tests.sh tests

Scenario: Help should be displayed
When I try `/usr/bin/env bash templates/install-wp-tests.sh`
Then STDOUT should contain:
"""
usage:
"""
And the return code should be 1

Scenario: Install latest version of WordPress
Given I run `echo "DROP DATABASE IF EXISTS wordpress_behat_test" | mysql -u root`
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
And I try `rm -fr /tmp/behat-wordpress`
And I run `pwd`
And save STDOUT as {WORK_DIR}
And a WP install
And I run `wp plugin path`
And save STDOUT as {PLUGIN_DIR}

When I run `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-wordpress /usr/bin/env bash {WORK_DIR}/templates/install-wp-tests.sh wordpress_behat_test root '' localhost latest`
Then the return code should be 0
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
data
"""
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
includes
"""
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
wp-tests-config.php
"""
And the /tmp/behat-wordpress directory should contain:
"""
index.php
license.txt
readme.html
wp-activate.php
wp-admin
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-content
wp-cron.php
wp-includes
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php
"""

When I run `echo 'show databases' | mysql -u root`
Then the return code should be 0
And STDOUT should contain:
"""
wordpress_behat_test
"""

When I run `wp scaffold plugin hello-world`
Then the {PLUGIN_DIR}/hello-world/phpunit.xml.dist file should exist

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

Scenario: Install WordPress from trunk
Given I run `echo "DROP DATABASE IF EXISTS wordpress_behat_test" | mysql -u root`
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
And I try `rm -fr /tmp/behat-wordpress`
And I run `pwd`
And save STDOUT as {WORK_DIR}
And a WP install
And I run `wp plugin path`
And save STDOUT as {PLUGIN_DIR}

When I run `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-wordpress /usr/bin/env bash {WORK_DIR}/templates/install-wp-tests.sh wordpress_behat_test root '' localhost trunk`
Then the return code should be 0
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
data
"""
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
includes
"""
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
wp-tests-config.php
"""
And the /tmp/behat-wordpress directory should contain:
"""
index.php
license.txt
readme.html
wp-activate.php
wp-admin
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-content
wp-cron.php
wp-includes
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php
"""
And the /tmp/behat-wordpress/wp-includes/version.php file should contain:
"""
-alpha-
"""

When I run `echo 'show databases' | mysql -u root`
Then the return code should be 0
And STDOUT should contain:
"""
wordpress_behat_test
"""

When I run `wp scaffold plugin hello-world`
Then the {PLUGIN_DIR}/hello-world/phpunit.xml.dist file should exist

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

Scenario: Install WordPress 3.7 and phpunit will not run
Given I run `echo "DROP DATABASE IF EXISTS wordpress_behat_test" | mysql -u root`
And I try `rm -fr /tmp/behat-wordpress-tests-lib`
And I try `rm -fr /tmp/behat-wordpress`
And I run `pwd`
And save STDOUT as {WORK_DIR}

When I run `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib WP_CORE_DIR=/tmp/behat-wordpress /usr/bin/env bash {WORK_DIR}/templates/install-wp-tests.sh wordpress_behat_test root '' localhost 3.7`
Then the return code should be 0
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
data
"""
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
includes
"""
And the /tmp/behat-wordpress-tests-lib directory should contain:
"""
wp-tests-config.php
"""
And the /tmp/behat-wordpress directory should contain:
"""
index.php
license.txt
readme.html
wp-activate.php
wp-admin
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-content
wp-cron.php
wp-includes
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php
"""
And the /tmp/behat-wordpress/wp-includes/version.php file should contain:
"""
3.7
"""

When I run `echo 'show databases' | mysql -u root`
Then the return code should be 0
And STDOUT should contain:
"""
wordpress_behat_test
"""

0 comments on commit 2e6f08b

Please sign in to comment.