-
Notifications
You must be signed in to change notification settings - Fork 56
/
travis.sh
executable file
·128 lines (102 loc) · 3.93 KB
/
travis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env bash
# Install WordPress.
install-wordpress() {
mkdir -p "$WP_DEVELOP_DIR" # /tmp/wordpress
if [[ $WP_VERSION == 'develop' ]]; then
WP_VERSION=master
fi
WP_VERSION=4.9
# Clone the WordPress develop repo. https://github.com/WordPress/wordpress-develop
git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ "$WP_DEVELOP_DIR"
# Set up tests config.
cd "$WP_DEVELOP_DIR"
# Contains:
# ...
# ./src
# ./tests
# ./tools
# ./wp-cli.yml
# ./wp-config-sample.php
# ./wp-tests-config-sample.php
cp wp-tests-config-sample.php wp-config.php # duplicate file to have ./wp-config.php
# Search & replace:
# – Database
sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-config.php #DB
sed -i "s/yourusernamehere/root/" wp-config.php #user
sed -i "s/yourpasswordhere//" wp-config.php #pass
# – Configure WordPress for access through a web server.
sed -i "s/'example.org'/'$WP_CEPT_SERVER'/" wp-config.php
# 1 - Disable default ABSPATH
sed -i "s/define( 'ABSPATH'/\/\//" wp-config.php
# 2 - The next code is missing from wp-config, but required for WP-CLI to run.
echo "
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/src/');
" >> wp-config.php
# Set up database.
mysql -e 'CREATE DATABASE wordpress_test;' -uroot
# Install WordPress via PHP unit-test installer.
php tests/phpunit/includes/install.php wp-config.php "$WP_MULTISITE"
# Support multisite.
if [[ $WP_MULTISITE = 1 ]]; then
# Update the config to enable multisite.
echo "
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
\$GLOBALS['base'] = '/';
" >> wp-config.php
fi
# Update the config to actually load WordPress.
# Installed wordPress located in /tmp/wordpress/src ($WP_CORE_DIR)
# when wp-config.php in /tmp/wordpress
echo "require_once(ABSPATH . 'wp-settings.php');" >> wp-config.php
# Output file content in terminal:
# cat wp-config.php
# $WP_CORE_DIR
# /tmp/wordpress/src
# /tmp/wordpress/src/index.php
# /tmp/wordpress/src/license.txt
# /tmp/wordpress/src/readme.html
# /tmp/wordpress/src/wp-activate.php
# /tmp/wordpress/src/wp-admin
# /tmp/wordpress/src/wp-blog-header.php
# /tmp/wordpress/src/wp-comments-post.php
# /tmp/wordpress/src/wp-content
# /tmp/wordpress/src/wp-content/themes/
# /tmp/wordpress/src/wp-content/themes/index.php
# /tmp/wordpress/src/wp-content/themes/twentyeleven
# /tmp/wordpress/src/wp-content/themes/twentyfifteen
# /tmp/wordpress/src/wp-content/themes/twentyfourteen
# /tmp/wordpress/src/wp-content/themes/twentyseventeen
# /tmp/wordpress/src/wp-content/themes/twentysixteen
# /tmp/wordpress/src/wp-content/themes/twentyten
# /tmp/wordpress/src/wp-content/themes/twentythirteen
# /tmp/wordpress/src/wp-content/themes/twentytwelve
# /tmp/wordpress/src/wp-content/themes/default
# /tmp/wordpress/src/wp-cron.php
# /tmp/wordpress/src/wp-includes
# /tmp/wordpress/src/wp-links-opml.php
# /tmp/wordpress/src/wp-load.php
# /tmp/wordpress/src/wp-login.php
# /tmp/wordpress/src/wp-mail.php
# /tmp/wordpress/src/wp-settings.php
# /tmp/wordpress/src/wp-signup.php
# /tmp/wordpress/src/wp-trackback.php
# /tmp/wordpress/src/xmlrpc.php
# Set up default theme.
ln -s "$WP_CORE_DIR/wp-content/themes/twentyseventeen" "$WP_CORE_DIR/wp-content/themes/default"
# $HOME = /home/travis
# Copy plugin from the travis buid folder to the WordPress install > plugins.
ln -s "$TRAVIS_BUILD_DIR" "$WP_CORE_DIR"/wp-content/plugins/live-composer-page-builder
# echo "????? THEMES ----------------------"
# echo "$WP_CORE_DIR/wp-content/themes/"
# find "$WP_CORE_DIR/wp-content/themes" -maxdepth 1 # list files in current dirrectory
# echo "----------------------"
# echo "????? PLUGINS ----------------------"
# echo "$WP_CORE_DIR/wp-content/plugins/"
# find "$WP_CORE_DIR/wp-content/plugins" -maxdepth 1 # list files in current dirrectory
# echo "----------------------"
cd -
}
# EOF