Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
miya0001 committed Apr 24, 2015
2 parents bc3fb6c + 1d509cf commit 55854d8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
2 changes: 0 additions & 2 deletions provision/site-cookbooks/vccw/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
default[:vccw][:phpunit][:src] = 'https://phar.phpunit.de/phpunit.phar'
default[:vccw][:phpunit][:link] = '/usr/local/bin/phpunit'
default[:vccw][:phpunit][:wp_test_install] = '/usr/bin/wp-test-install'
default[:vccw][:phpunit][:mysql_name] = 'wp-test'
default[:vccw][:phpunit][:wp_version] = 'latest'

default[:vccw][:composer][:install] = 'curl -sS https://getcomposer.org/installer | php'
default[:vccw][:composer][:link] = '/usr/local/bin/composer'
Expand Down
15 changes: 5 additions & 10 deletions provision/site-cookbooks/vccw/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,16 @@
end

execute "wp-test-install" do
command <<-EOH
#{node[:vccw][:phpunit][:wp_test_install]} \
#{Shellwords.shellescape(node[:vccw][:phpunit][:mysql_name])} \
root \
#{Shellwords.shellescape(node[:mysql][:server_root_password])} \
localhost \
#{Shellwords.shellescape(node[:vccw][:phpunit][:wp_version])}
EOH
user "vagrant"
group "vagrant"
command node[:vccw][:phpunit][:wp_test_install]
action :nothing
end

template node[:vccw][:phpunit][:wp_test_install] do
source "wp-test-install.sh.erb"
owner "root"
group "root"
owner "vagrant"
group "vagrant"
mode "0755"
notifies :run, "execute[wp-test-install]", :immediately
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#!/usr/bin/env bash

if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
exit 1
set -ex;

DB_NAME='wordpress_test'
DB_USER='root'
DB_PASS='wordpress'
DB_HOST='localhost'
WP_VERSION='latest'

echo "DROP DATABASE IF EXISTS $DB_NAME;" | mysql -u root -p$DB_PASS

if [ -e /tmp/wordpress ]; then
sudo rm -fr /tmp/wordpress
fi

DB_NAME=$1
DB_USER=$2
DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
if [ -e /tmp/wordpress-tests-lib ]; then
sudo rm -fr /tmp/wordpress-tests-lib
fi

if [ -e /tmp/wordpress.tar.gz ]; then
sudo rm -fr /tmp/wordpress.tar.gz
fi

WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
WP_CORE_DIR=/tmp/wordpress/
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}

set -ex

Expand All @@ -25,10 +36,10 @@ install_wp() {
local ARCHIVE_NAME="wordpress-$WP_VERSION"
fi

wget --no-check-certificate -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
wget -nv -O /tmp/wordpress.tar.gz https://wordpress.org/${ARCHIVE_NAME}.tar.gz
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR

wget --no-check-certificate -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
}

install_test_suite() {
Expand All @@ -42,9 +53,9 @@ install_test_suite() {
# set up testing suite
mkdir -p $WP_TESTS_DIR
cd $WP_TESTS_DIR
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
svn co --quiet https://develop.svn.wordpress.org/trunk/tests/phpunit/includes/

wget --no-check-certificate -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
wget -nv -O wp-tests-config.php https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
Expand All @@ -60,7 +71,7 @@ install_db() {
local EXTRA=""

if ! [ -z $DB_HOSTNAME ] ; then
if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
EXTRA=" --socket=$DB_SOCK_OR_PORT"
Expand Down

0 comments on commit 55854d8

Please sign in to comment.