diff --git a/.env b/.env
index fda527930d..63ae0f1962 100644
a
|
b
|
LOCAL_PHP=latest |
18 | 18 | # Whether or not to enable XDebug. |
19 | 19 | LOCAL_PHP_XDEBUG=false |
20 | 20 | |
| 21 | # Whether or not to enable Memcached. |
| 22 | LOCAL_PHP_MEMCACHED=false |
| 23 | |
21 | 24 | # The MySQL version to use. See https://hub.docker.com/_/mysql/ for valid versions. |
22 | 25 | LOCAL_MYSQL=5.7 |
23 | 26 | |
diff --git a/.travis.yml b/.travis.yml
index 15ed25bd35..4e083c87e9 100644
a
|
b
|
cache: |
17 | 17 | |
18 | 18 | env: |
19 | 19 | global: |
20 | | - LOCAL_DIR=build |
| 20 | - LOCAL_DIR: build |
21 | 21 | |
22 | 22 | matrix: |
23 | 23 | include: |
24 | 24 | - env: WP_TRAVISCI=test:e2e |
| 25 | name: E2E Tests |
25 | 26 | - env: WP_TRAVISCI=travis:phpcs |
| 27 | name: PHP Linting |
26 | 28 | - env: WP_TRAVISCI=travis:js |
| 29 | name: JS Tests |
27 | 30 | - env: LOCAL_PHP=7.3-fpm WP_TRAVISCI=test:php |
28 | | - php: 7.3 |
29 | | dist: trusty |
30 | | env: WP_TRAVIS_OBJECT_CACHE=true WP_TRAVISCI=travis:phpunit |
31 | | services: memcached |
| 31 | name: "PHPUnit Tests: PHP 7.3" |
| 32 | - env: LOCAL_PHP=7.3-fpm LOCAL_PHP_MEMCACHED=true WP_TRAVISCI=test:php |
| 33 | name: "PHPUnit Tests: PHP 7.3 with Memcached" |
32 | 34 | - env: LOCAL_PHP=7.2-fpm WP_TRAVISCI=test:php |
| 35 | name: "PHPUnit Tests: PHP 7.2" |
33 | 36 | - env: LOCAL_PHP=7.1-fpm WP_TRAVISCI=test:php |
| 37 | name: "PHPUnit Tests: PHP 7.1" |
34 | 38 | - env: LOCAL_PHP=7.0-fpm WP_TEST_REPORTER=true WP_TRAVISCI=test:php |
| 39 | name: "PHPUnit Tests: PHP 7.0" |
35 | 40 | - env: LOCAL_PHP=5.6-fpm WP_TRAVISCI=test:php |
36 | | - php: 7.4snapshot |
37 | | dist: trusty |
38 | | env: WP_TRAVISCI=travis:phpunit |
39 | | - php: nightly |
40 | | dist: trusty |
41 | | env: WP_TRAVISCI=travis:phpunit |
| 41 | name: "PHPUnit Tests: PHP 5.6" |
| 42 | - env: LOCAL_PHP=7.4-fpm WP_TRAVISCI=test:php |
| 43 | name: "PHPUnit Tests: PHP 7.4" |
| 44 | - env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php |
| 45 | name: "PHPUnit Tests: PHP 8.0" |
42 | 46 | allow_failures: |
43 | | - php: 7.4snapshot |
44 | | - php: nightly |
| 47 | - env: LOCAL_PHP=7.4-fpm WP_TRAVISCI=test:php |
| 48 | - env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php |
45 | 49 | fast_finish: true |
46 | 50 | |
47 | 51 | before_install: |
48 | | - | |
49 | | if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then |
50 | | mysql -u root -e "CREATE DATABASE wordpress_tests;" |
51 | | cp wp-tests-config-sample.php wp-tests-config.php |
52 | | sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php |
53 | | sed -i "s/yourusernamehere/root/" wp-tests-config.php |
54 | | sed -i "s/yourpasswordhere//" wp-tests-config.php |
55 | | travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer |
56 | | fi |
57 | 52 | - | |
58 | 53 | if [[ "$WP_TRAVISCI" == "test:php" ]]; then |
59 | 54 | cp wp-tests-config-sample.php wp-tests-config.php |
… |
… |
before_install: |
61 | 56 | sed -i "s/yourusernamehere/root/" wp-tests-config.php |
62 | 57 | sed -i "s/yourpasswordhere/password/" wp-tests-config.php |
63 | 58 | sed -i "s/localhost/mysql/" wp-tests-config.php |
| 59 | echo "define( 'FS_METHOD', 'direct' );" >> wp-tests-config.php |
64 | 60 | travis_retry svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer |
65 | 61 | fi |
66 | 62 | - | |
… |
… |
before_install: |
68 | 64 | curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > docker-compose |
69 | 65 | chmod +x docker-compose |
70 | 66 | sudo mv docker-compose /usr/local/bin |
71 | | - | |
72 | | if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then |
73 | | cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php |
74 | | echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini |
75 | | fi |
76 | 67 | |
77 | 68 | before_script: |
78 | 69 | - | |
… |
… |
before_script: |
107 | 98 | if [[ "$WP_TRAVISCI" == "test:e2e" ]] || [[ "$WP_TRAVISCI" == "test:php" ]]; then |
108 | 99 | npm run env:start |
109 | 100 | npm run build |
| 101 | docker-compose -f tools/local-env/docker-compose.yml run --rm mysql mysql --version |
| 102 | docker-compose -f tools/local-env/docker-compose.yml run --rm php php --version |
| 103 | docker-compose -f tools/local-env/docker-compose.yml run --rm php php -m |
| 104 | docker-compose -f tools/local-env/docker-compose.yml -f tools/local-env/docker-compose.scripts.yml run --rm phpunit phpunit --version |
| 105 | fi |
| 106 | - | |
| 107 | if [[ "$LOCAL_PHP_MEMCACHED" == "true" ]]; then |
| 108 | cp tests/phpunit/includes/object-cache.php build/wp-content/object-cache.php |
| 109 | docker run --name memcached --net local-env_wpdevnet -d memcached |
110 | 110 | fi |
111 | 111 | - | |
112 | 112 | if [[ "$WP_TRAVISCI" == "test:e2e" ]]; then |
113 | 113 | npm run env:install |
114 | 114 | fi |
115 | | - mysql --version |
116 | | - phpenv versions |
117 | | - php --version |
118 | | - php -m |
119 | 115 | - npm --version |
120 | 116 | - node --version |
121 | | - which phpunit |
122 | | - phpunit --version |
123 | 117 | - curl --version |
124 | 118 | - git --version |
125 | 119 | - svn --version |
… |
… |
script: |
130 | 124 | if [[ "$WP_TRAVISCI" == "test:e2e" ]]; then |
131 | 125 | npm run test:e2e |
132 | 126 | elif [[ "$WP_TRAVISCI" == "test:php" ]]; then |
133 | | npm run test:php -- -- -- --verbose -c phpunit.xml.dist |
134 | | npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group ajax |
135 | | npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml |
136 | | npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml --group ms-files |
137 | | npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group external-http |
| 127 | npm run test:php -- -- -- --verbose -c phpunit.xml.dist && |
| 128 | npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group ajax && |
| 129 | npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml && |
| 130 | npm run test:php -- -- -- --verbose -c tests/phpunit/multisite.xml --group ms-files && |
| 131 | npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group external-http && |
138 | 132 | npm run test:php -- -- -- --verbose -c phpunit.xml.dist --group restapi-jsclient |
139 | 133 | else |
140 | 134 | npm run grunt $WP_TRAVISCI |
diff --git a/package.json b/package.json
index 023b269d48..8ab2c53cea 100644
a
|
b
|
|
147 | 147 | "env:cli": "dotenv npm run env:__cli-next", |
148 | 148 | "env:__cli-next": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml run --rm cli", |
149 | 149 | "env:logs": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml logs", |
| 150 | "env:pull": "dotenv npm run env:__pull-next", |
| 151 | "env:__pull-next": "docker-compose -f ./tools/local-env/docker-compose.yml -f ./tools/local-env/docker-compose.scripts.yml pull", |
150 | 152 | "test:e2e": "dotenv npm run test:__e2e-next", |
151 | 153 | "test:__e2e-next": "cross-var cross-env WP_BASE_URL=http://localhost:$LOCAL_PORT wp-scripts test-e2e --config tests/e2e/jest.config.js", |
152 | 154 | "test:php": "dotenv npm run test:__php-next", |
diff --git a/tests/phpunit/includes/object-cache.php b/tests/phpunit/includes/object-cache.php
index 8fcc4f9261..c97ccb8d64 100644
a
|
b
|
class WP_Object_Cache { |
835 | 835 | if ( isset( $memcached_servers ) ) { |
836 | 836 | $this->servers = $memcached_servers; |
837 | 837 | } else { |
838 | | $this->servers = array( array( '127.0.0.1', 11211 ) ); |
| 838 | $this->servers = array( array( 'memcached', 11211 ) ); |
839 | 839 | } |
840 | 840 | |
841 | 841 | $this->addServers( $this->servers ); |
diff --git a/tests/phpunit/tests/ajax/CustomizeMenus.php b/tests/phpunit/tests/ajax/CustomizeMenus.php
index bca0bdcc64..bb092cdad4 100644
a
|
b
|
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
54 | 54 | |
55 | 55 | if ( 'administrator' !== $role ) { |
56 | 56 | // If we're not an admin, we should get a wp_die(-1). |
57 | | $this->setExpectedException( 'WPAjaxDieStopException' ); |
| 57 | $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); |
58 | 58 | } |
59 | 59 | |
60 | 60 | wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) ); |
… |
… |
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { |
443 | 443 | |
444 | 444 | if ( 'administrator' !== $role ) { |
445 | 445 | // If we're not an admin, we should get a wp_die(-1). |
446 | | $this->setExpectedException( 'WPAjaxDieStopException' ); |
| 446 | $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); |
447 | 447 | } |
448 | 448 | |
449 | 449 | wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) ); |
diff --git a/tools/local-env/docker-compose.scripts.yml b/tools/local-env/docker-compose.scripts.yml
index 1f42a5261b..f5a5153545 100644
a
|
b
|
services: |
13 | 13 | |
14 | 14 | environment: |
15 | 15 | LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false} |
| 16 | LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false} |
16 | 17 | |
17 | 18 | volumes: |
18 | 19 | - ../../:/var/www |
… |
… |
services: |
31 | 32 | |
32 | 33 | environment: |
33 | 34 | LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false} |
| 35 | LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false} |
34 | 36 | |
35 | 37 | volumes: |
36 | 38 | - ./phpunit-config.ini:/usr/local/etc/php/conf.d/phpunit-config.ini |
diff --git a/tools/local-env/docker-compose.yml b/tools/local-env/docker-compose.yml
index 32021df1df..ddbec7fe47 100644
a
|
b
|
services: |
38 | 38 | |
39 | 39 | environment: |
40 | 40 | LOCAL_PHP_XDEBUG: ${LOCAL_PHP_XDEBUG-false} |
| 41 | LOCAL_PHP_MEMCACHED: ${LOCAL_PHP_MEMCACHED-false} |
41 | 42 | |
42 | 43 | volumes: |
43 | 44 | - ./php-config.ini:/usr/local/etc/php/conf.d/php-config.ini |