Skip to content

Commit fa2717d

Browse files
committed
=> 3.1.3 Several fixes
1 parent 2a6ce8e commit fa2717d

File tree

183 files changed

+50791
-56564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+50791
-56564
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

bin/install-wp-tests.sh

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/usr/bin/env bash
2+
3+
if [ $# -lt 3 ]; then
4+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
5+
exit 1
6+
fi
7+
8+
DB_NAME=$1
9+
DB_USER=$2
10+
DB_PASS=$3
11+
DB_HOST=${4-localhost}
12+
WP_VERSION=${5-latest}
13+
SKIP_DB_CREATE=${6-false}
14+
15+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
16+
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
17+
18+
download() {
19+
if [ `which curl` ]; then
20+
curl -s "$1" > "$2";
21+
elif [ `which wget` ]; then
22+
wget -nv -O "$2" "$1"
23+
fi
24+
}
25+
26+
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
27+
WP_TESTS_TAG="tags/$WP_VERSION"
28+
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
29+
WP_TESTS_TAG="trunk"
30+
else
31+
# http serves a single offer, whereas https serves multiple. we only want one
32+
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
33+
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
34+
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
35+
if [[ -z "$LATEST_VERSION" ]]; then
36+
echo "Latest WordPress version could not be found"
37+
exit 1
38+
fi
39+
WP_TESTS_TAG="tags/$LATEST_VERSION"
40+
fi
41+
42+
set -ex
43+
44+
install_wp() {
45+
46+
if [ -d $WP_CORE_DIR ]; then
47+
return;
48+
fi
49+
50+
mkdir -p $WP_CORE_DIR
51+
52+
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
53+
mkdir -p /tmp/wordpress-nightly
54+
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
55+
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
56+
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
57+
else
58+
if [ $WP_VERSION == 'latest' ]; then
59+
local ARCHIVE_NAME='latest'
60+
else
61+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
62+
fi
63+
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
64+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
65+
fi
66+
67+
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
68+
}
69+
70+
install_test_suite() {
71+
# portable in-place argument for both GNU sed and Mac OSX sed
72+
if [[ $(uname -s) == 'Darwin' ]]; then
73+
local ioption='-i .bak'
74+
else
75+
local ioption='-i'
76+
fi
77+
78+
# set up testing suite if it doesn't yet exist
79+
if [ ! -d $WP_TESTS_DIR ]; then
80+
# set up testing suite
81+
mkdir -p $WP_TESTS_DIR
82+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
83+
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
84+
fi
85+
86+
if [ ! -f wp-tests-config.php ]; then
87+
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
88+
# remove all forward slashes in the end
89+
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
90+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
91+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
92+
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
93+
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
94+
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
95+
fi
96+
97+
}
98+
99+
install_db() {
100+
101+
if [ ${SKIP_DB_CREATE} = "true" ]; then
102+
return 0
103+
fi
104+
105+
# parse DB_HOST for port or socket references
106+
local PARTS=(${DB_HOST//\:/ })
107+
local DB_HOSTNAME=${PARTS[0]};
108+
local DB_SOCK_OR_PORT=${PARTS[1]};
109+
local EXTRA=""
110+
111+
if ! [ -z $DB_HOSTNAME ] ; then
112+
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
113+
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
114+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
115+
EXTRA=" --socket=$DB_SOCK_OR_PORT"
116+
elif ! [ -z $DB_HOSTNAME ] ; then
117+
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
118+
fi
119+
fi
120+
121+
# create database
122+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
123+
}
124+
125+
install_wp
126+
install_test_suite
127+
install_db

bin/install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
./bin/install-wp-tests.sh psource-maps-plugin root '' localhost

bin/mkctags.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#/bin/bash
2+
3+
hasctags=$(which ctags);
4+
if [ "" == "$hasctags" ]; then
5+
echo "Install ctags"
6+
exit 1
7+
fi
8+
9+
find psource-maps-plugin_DIR \
10+
-type f \
11+
-regextype posix-egrep \
12+
-regex ".*\.(php|js)" \
13+
! -path "*/.git*" \
14+
! -path "*/node_modules/*" \
15+
! -path "*/build/*" \
16+
! -path "*/wp-content/uploads/*" \
17+
! -path "*/*.min.js" \
18+
| ctags -f "psource-maps-plugin_DIR/psource-maps-plugin.tags" --fields=+KSn -L -

bin/phpcbf.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
hascbf=$(which phpcbf);
4+
if [ "" == "$hascbf" ]; then
5+
echo "Install PHP Code Beautifier"
6+
exit 1
7+
fi
8+
if [[ ! -f ./phpcs.ruleset.xml ]]; then
9+
echo "No ruleset file, aborting"
10+
exit 1
11+
fi
12+
13+
phpcbf $(find . -name "*.php") --standard=./phpcs.ruleset.xml

bin/phpcs.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
hascs=$(which phpcs);
4+
if [ "" == "$hascs" ]; then
5+
echo "Install PHP Code Sniffer"
6+
exit 1
7+
fi
8+
if [[ ! -f ./phpcs.ruleset.xml ]]; then
9+
echo "No ruleset file, aborting"
10+
exit 1
11+
fi
12+
13+
phpcs $(find . -name "*.php") --standard=./phpcs.ruleset.xml

0 commit comments

Comments
 (0)