Skip to content

Commit dcb19de

Browse files
committed
Merge branch 'master' into patch-1
2 parents e437db9 + 604e6c7 commit dcb19de

File tree

5 files changed

+79
-13
lines changed

5 files changed

+79
-13
lines changed

.travis.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
sudo: false
2-
dist: trusty
1+
os: linux
2+
dist: xenial
33

44
language: php
5-
php: 7.3
5+
php: 7.4
6+
7+
services:
8+
- mysql
69

710
notifications:
811
email:
@@ -22,6 +25,9 @@ env:
2225
- PATH="$TRAVIS_BUILD_DIR/vendor/bin:$PATH"
2326
- WP_CLI_BIN_DIR="$TRAVIS_BUILD_DIR/vendor/bin"
2427

28+
services:
29+
- mysql
30+
2531
before_install:
2632
- |
2733
# Remove Xdebug for a huge performance increase:
@@ -51,7 +57,7 @@ jobs:
5157
- composer phpcs
5258
env: BUILD=sniff
5359
- stage: test
54-
php: 7.4snapshot
60+
php: 7.4
5561
env: WP_VERSION=latest
5662
- stage: test
5763
php: 7.3
@@ -71,14 +77,11 @@ jobs:
7177
- stage: test
7278
php: 5.6
7379
env: WP_VERSION=3.7.11
80+
dist: trusty
7481
- stage: test
7582
php: 5.6
7683
env: WP_VERSION=trunk
7784
- stage: test
78-
php: 5.4
7985
dist: precise
86+
php: 5.4
8087
env: WP_VERSION=5.1
81-
allow_failures:
82-
- stage: test
83-
php: 7.4snapshot
84-
env: WP_VERSION=latest

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"require": {
1515
"php": "^5.4 || ^7.0",
16-
"wp-cli/wp-cli": "^2"
16+
"wp-cli/wp-cli": "dev-master"
1717
},
1818
"require-dev": {
1919
"wp-cli/extension-command": "^1.2 || ^2",

features/install-wp-tests.feature

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ Feature: Scaffold install-wp-tests.sh tests
1717
@require-php-5.6
1818
Scenario: Install latest version of WordPress
1919
Given a WP install
20+
And a affirmative-response file:
21+
"""
22+
Y
23+
"""
24+
And a negative-response file:
25+
"""
26+
No
27+
"""
2028
And I run `wp plugin path`
2129
And save STDOUT as {PLUGIN_DIR}
2230
And I run `wp scaffold plugin hello-world`
@@ -76,6 +84,28 @@ Feature: Scaffold install-wp-tests.sh tests
7684
When I run `WP_TESTS_DIR=/tmp/behat-wordpress-tests-lib phpunit -c {PLUGIN_DIR}/hello-world/phpunit.xml.dist`
7785
Then the return code should be 0
7886

87+
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 wp_cli_test password1 localhost latest < affirmative-response`
88+
Then the return code should be 0
89+
And STDERR should contain:
90+
"""
91+
Reinstalling
92+
"""
93+
And STDOUT should contain:
94+
"""
95+
Recreated the database (wp_cli_test_scaffold)
96+
"""
97+
98+
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 wp_cli_test password1 localhost latest < negative-response`
99+
Then the return code should be 0
100+
And STDERR should contain:
101+
"""
102+
Reinstalling
103+
"""
104+
And STDOUT should contain:
105+
"""
106+
Leaving the existing database (wp_cli_test_scaffold) in place
107+
"""
108+
79109
@require-php-5.6
80110
Scenario: Install WordPress from trunk
81111
Given a WP install

features/scaffold.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Feature: WordPress code scaffolding
4848
"""
4949
And the return code should be 1
5050

51+
@require-wp-4.6
5152
Scenario: Scaffold a child theme and network enable it
5253
Given a WP multisite install
5354

@@ -309,6 +310,7 @@ Feature: WordPress code scaffolding
309310
Plugin 'hello-world' activated.
310311
"""
311312
313+
@require-wp-4.6
312314
Scenario: Scaffold a plugin and network activate it
313315
Given a WP multisite install
314316
When I run `wp scaffold plugin hello-world --activate-network`
@@ -333,6 +335,7 @@ Feature: WordPress code scaffolding
333335
"""
334336
And the return code should be 1
335337
338+
@require-php-5.6 @require-wp-4.6
336339
Scenario: Scaffold starter code for a theme
337340
Given a WP install
338341
Given I run `wp theme path`
@@ -347,6 +350,7 @@ Feature: WordPress code scaffolding
347350
And the {THEME_DIR}/starter-theme/style.css file should exist
348351
And the {THEME_DIR}/starter-theme/.editorconfig file should exist
349352
353+
@require-php-5.6 @require-wp-4.6
350354
Scenario: Scaffold starter code for a theme with sass
351355
Given a WP install
352356
Given I run `wp theme path`
@@ -360,6 +364,7 @@ Feature: WordPress code scaffolding
360364
"""
361365
And the {THEME_DIR}/starter-theme/sass directory should exist
362366
367+
@require-php-5.6 @require-wp-4.6
363368
Scenario: Scaffold starter code for a WooCommerce theme
364369
Given a WP install
365370
Given I run `wp theme path`
@@ -374,6 +379,7 @@ Feature: WordPress code scaffolding
374379
And the {THEME_DIR}/starter-theme/woocommerce.css file should exist
375380
And the {THEME_DIR}/starter-theme/inc/woocommerce.php file should exist
376381
382+
@require-php-5.6 @require-wp-4.6
377383
Scenario: Scaffold starter code for a theme and activate it
378384
Given a WP install
379385
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
@@ -490,6 +496,7 @@ Feature: WordPress code scaffolding
490496
env: WP_VERSION=latest
491497
"""
492498
499+
@require-php-5.6 @require-wp-4.6
493500
Scenario: Scaffold starter code for a theme and network enable it
494501
Given a WP multisite install
495502
# Allow for warnings to be generated due to https://github.com/wp-cli/scaffold-command/issues/181
@@ -499,6 +506,7 @@ Feature: WordPress code scaffolding
499506
Success: Network enabled the 'Starter-theme' theme.
500507
"""
501508
509+
@require-php-5.6 @require-wp-4.6
502510
Scenario: Scaffold starter code for a theme, but can't unzip theme files
503511
Given a WP install
504512
And a misconfigured WP_CONTENT_DIR constant directory

templates/install-wp-tests.sh

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ install_test_suite() {
107107
if [ ! -d $WP_TESTS_DIR ]; then
108108
# set up testing suite
109109
mkdir -p $WP_TESTS_DIR
110-
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
111-
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
110+
svn co --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
111+
svn co --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
112112
fi
113113

114114
if [ ! -f wp-tests-config.php ]; then
115115
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
116116
# remove all forward slashes in the end
117117
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
118118
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
119+
sed $ioption "s:__DIR__ . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
119120
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
120121
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
121122
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
@@ -124,6 +125,23 @@ install_test_suite() {
124125

125126
}
126127

128+
recreate_db() {
129+
shopt -s nocasematch
130+
if [[ $1 =~ ^(y|yes)$ ]]
131+
then
132+
mysqladmin drop $DB_NAME -f --user="$DB_USER" --password="$DB_PASS"$EXTRA
133+
create_db
134+
echo "Recreated the database ($DB_NAME)."
135+
else
136+
echo "Leaving the existing database ($DB_NAME) in place."
137+
fi
138+
shopt -u nocasematch
139+
}
140+
141+
create_db() {
142+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
143+
}
144+
127145
install_db() {
128146

129147
if [ ${SKIP_DB_CREATE} = "true" ]; then
@@ -147,7 +165,14 @@ install_db() {
147165
fi
148166

149167
# create database
150-
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
168+
if [ $(mysql --user="$DB_USER" --password="$DB_PASS" --execute='show databases;' | grep ^$DB_NAME$) ]
169+
then
170+
echo "Reinstalling will delete the existing test database ($DB_NAME)"
171+
read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB
172+
recreate_db $DELETE_EXISTING_DB
173+
else
174+
create_db
175+
fi
151176
}
152177

153178
install_wp

0 commit comments

Comments
 (0)