Skip to content

Commit a8a3565

Browse files
authored
v1.2.2 - Merge pull request #5 from JoryHogeveen/dev
v1.2.2
2 parents 884e24d + 5e8e01a commit a8a3565

File tree

9 files changed

+522
-97
lines changed

9 files changed

+522
-97
lines changed

.codeclimate.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ engines:
1616
config:
1717
standard: "Wordpress-Extra"
1818
checks:
19+
# Disable: Class file names should be based on the class name with "class-" prepended.
20+
WordPress Files FileName InvalidClassFileName:
21+
enabled: false
1922
# Disable: Member variable "" is not in valid snake_case format
2023
WordPress NamingConventions ValidVariableName MemberNotSnakeCase:
2124
enabled: false
@@ -58,6 +61,9 @@ engines:
5861
# Disable: Expected 1 space after closing brace; newline found
5962
Squiz ControlStructures ControlSignature SpaceAfterCloseBrace:
6063
enabled: false
64+
# Disable: Opening brace should be on the same line as the declaration for class
65+
Generic Classes OpeningBraceSameLine BraceOnNewLine:
66+
enabled: false
6167
# Disable: There must be exactly one blank line before the tags in a doc comment
6268
Generic Commenting DocComment SpacingBeforeTags:
6369
enabled: false

.travis.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
# - WP_VERSION=bleeding-maintenance WP_MULTISITE=0
1717
- WP_VERSION=latest WP_MULTISITE=0
1818
- WP_VERSION=latest WP_MULTISITE=1
19-
19+
2020
# - WP_VERSION=latest WP_MULTISITE=0
2121
# - WP_VERSION=latest WP_MULTISITE=1
2222
# - WP_VERSION=3.7 WP_MULTISITE=0
@@ -43,14 +43,34 @@ matrix:
4343
env: WP_VERSION=latest WP_MULTISITE=0
4444
- php: 5.2
4545
env: WP_VERSION=3.7 WP_MULTISITE=0
46-
46+
47+
48+
## Cache composer bits
49+
cache:
50+
apt: true
51+
directories:
52+
- vendor
53+
- $HOME/.composer/cache
54+
4755
before_script:
48-
# Install composer packages before trying to activate themes or plugins
49-
# - composer install
56+
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != 'nightly' ]]; then
57+
phpenv config-rm xdebug.ini;
58+
fi
59+
60+
# Install composer packages before trying to activate themes or plugins
61+
- if [[ $TRAVIS_PHP_VERSION != 5.2 ]]; then
62+
composer self-update;
63+
composer install --no-interaction --prefer-source;
64+
fi
5065

5166
# - git clone https://github.com/Seravo/wordpress-test-template wp-tests
5267
- bash bin/install-wp-tests.sh test root '' localhost $WP_VERSION
5368

5469
script:
55-
- phpunit
56-
# - cd tests/spec && bundle exec rspec test.rb
70+
# Use phpunit from composer
71+
- if [[ $TRAVIS_PHP_VERSION != 5.2 ]]; then
72+
vendor/bin/phpunit;
73+
else
74+
phpunit;
75+
fi
76+
# - cd tests/spec && bundle exec rspec test.rb

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ I've built this plugin for the Genesis Framework, though it will work with any t
2121
#### `genesis_widget_column_classes`
2222
Allows you to change the available column classes
2323

24-
**Parameters:** `array` (default column classes)
24+
**Parameters:** `array` Default column classes.
25+
**Return:** `array` Array of column classes.
26+
27+
#### `genesis_widget_column_classes_capability`
28+
Change the capability required to modify column classes.
29+
Since 1.2.2
30+
31+
**Default:** `edit_theme_options`
32+
**Parameters:** `string` The default capability.
33+
**Return:** `string` The new capability.
34+
35+
You can use these filters inside your theme functions.php file or in a plugin.
2536

2637
## Installation
2738

bin/install-wp-tests.sh

Lines changed: 84 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
if [ $# -lt 3 ]; then
4-
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
4+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [force download] [skip-database-creation]"
55
exit 1
66
fi
77

@@ -10,56 +10,102 @@ DB_USER=$2
1010
DB_PASS=$3
1111
DB_HOST=${4-localhost}
1212
WP_VERSION=${5-latest}
13+
FORCE=${6-false}
14+
SKIP_DB_CREATE=${7-false}
1315

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

19+
# Placeholder for download agent
20+
# @todo replace back to wget everywhere in this file
1721
download() {
22+
1823
if [ `which curl` ]; then
1924
curl -s "$1" > "$2";
20-
elif [ `which wget` ]; then
25+
elif [ `which wget` ]; then
2126
wget -nv -O "$2" "$1"
22-
fi
27+
fi
28+
2329
}
2430

31+
# Detect version tag
32+
# Format: N.N.N
2533
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
2634
WP_TESTS_TAG="tags/$WP_VERSION"
35+
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
36+
WP_TESTS_TAG="trunk"
2737
else
2838
# http serves a single offer, whereas https serves multiple. we only want one
2939
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
3040
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
3141
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
42+
3243
if [[ -z "$LATEST_VERSION" ]]; then
3344
echo "Latest WordPress version could not be found"
3445
exit 1
3546
fi
47+
3648
WP_TESTS_TAG="tags/$LATEST_VERSION"
3749
fi
3850

51+
if [[ $WP_TESTS_TAG == *"beta"* ]]
52+
then
53+
WP_TESTS_TAG="trunk"
54+
fi
55+
3956
set -ex
4057

4158
install_wp() {
4259

60+
echo "Installing WordPress for Unit Tests"
61+
62+
if [[ $FORCE == 'true' || -z TRAVIS_JOB_ID ]]; then
63+
echo "Removing existing core WordPress directory"
64+
65+
rm -Rf $WP_CORE_DIR
66+
fi
67+
4368
if [ -d $WP_CORE_DIR ]; then
4469
return;
4570
fi
4671

72+
echo "Downloading WordPress"
73+
4774
mkdir -p $WP_CORE_DIR
4875

49-
if [ $WP_VERSION == 'latest' ]; then
50-
local ARCHIVE_NAME='latest'
76+
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
77+
mkdir -p /tmp/wordpress-nightly
78+
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
79+
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
80+
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
5181
else
52-
local ARCHIVE_NAME="wordpress-$WP_VERSION"
53-
fi
82+
if [ $WP_VERSION == 'latest' ]; then
83+
local ARCHIVE_NAME='latest'
84+
else
85+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
86+
fi
5487

55-
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
56-
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
88+
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
89+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
90+
fi
5791

5892
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
93+
94+
echo "WordPress installed"
95+
5996
}
6097

6198
install_test_suite() {
62-
# portable in-place argument for both GNU sed and Mac OSX sed
99+
100+
echo "Installing Tests Suite for Unit Tests"
101+
102+
if [[ $FORCE == 'true' || -z TRAVIS_JOB_ID ]]; then
103+
echo "Removing existing Tests Suite directory"
104+
105+
rm -Rf $WP_TESTS_DIR
106+
fi
107+
108+
# portable in-place argument for both GNU sed and Mac OS X sed
63109
if [[ $(uname -s) == 'Darwin' ]]; then
64110
local ioption='-i .bak'
65111
else
@@ -68,25 +114,39 @@ install_test_suite() {
68114

69115
# set up testing suite if it doesn't yet exist
70116
if [ ! -d $WP_TESTS_DIR ]; then
117+
echo "Downloading Tests Suite"
118+
71119
# set up testing suite
72120
mkdir -p $WP_TESTS_DIR
73-
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
121+
svn export --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes $WP_TESTS_DIR/includes
122+
svn export --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data $WP_TESTS_DIR/data
74123
fi
75124

76125
cd $WP_TESTS_DIR
77126

78127
if [ ! -f wp-tests-config.php ]; then
79128
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
80-
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
129+
# remove all forward slashes in the end
130+
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
131+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
81132
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
82133
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
83134
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
84135
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
85136
fi
86137

138+
echo "Tests Suite installed"
139+
87140
}
88141

89142
install_db() {
143+
144+
if [ ${SKIP_DB_CREATE} = "true" ]; then
145+
return 0
146+
fi
147+
148+
echo "Setting up Database for Unit Tests"
149+
90150
# parse DB_HOST for port or socket references
91151
local PARTS=(${DB_HOST//\:/ })
92152
local DB_HOSTNAME=${PARTS[0]};
@@ -103,8 +163,20 @@ install_db() {
103163
fi
104164
fi
105165

166+
if [[ $FORCE == 'true' || -z TRAVIS_JOB_ID ]]; then
167+
echo "Removing existing Database"
168+
169+
# drop database
170+
mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA -e "DROP DATABASE IF EXISTS $DB_NAME"
171+
fi
172+
173+
echo "Creating Database"
174+
106175
# create database
107176
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
177+
178+
echo "Database set up"
179+
108180
}
109181

110182
install_wp

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "JoryHogeveen/genesis-widget-column-classes",
3+
"type": "wordpress-plugin",
4+
"description": "Adds Genesis (old bootstrap) column classes to widgets.",
5+
"keywords": [],
6+
"homepage": "https://github.com/JoryHogeveen/genesis-widget-column-classes/",
7+
"license": "GPL-2.0+",
8+
"authors": [
9+
{
10+
"name": "Jory Hogeveen",
11+
"email": "[email protected]",
12+
"homepage": "https://www.keraweb.nl/",
13+
"role": "Owner"
14+
}
15+
],
16+
"require": {
17+
"composer/installers": "1.2.*",
18+
"php": ">=5.2.4"
19+
},
20+
"require-dev": {
21+
"phpmd/phpmd": "@stable",
22+
"phpunit/phpunit": "4.8.*",
23+
"mockery/mockery": "0.9.*",
24+
"squizlabs/php_codesniffer": "2.*"
25+
},
26+
"extra": {
27+
"installer-name": "genesis-widget-column-classes"
28+
}
29+
}

0 commit comments

Comments
 (0)