-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Edwin Siebel
committed
Jun 28, 2018
1 parent
fb833a8
commit cc00a4a
Showing
69 changed files
with
7,546 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# ----------------------------------------------------------------- | ||
# .gitignore for WordPress | ||
# Bare Minimum Git | ||
# http://ironco.de/bare-minimum-git/ | ||
# ver 20150227 | ||
# | ||
# This file is tailored for a WordPress project | ||
# using the default directory structure | ||
# | ||
# This file specifies intentionally untracked files to ignore | ||
# http://git-scm.com/docs/gitignore | ||
# | ||
# NOTES: | ||
# The purpose of gitignore files is to ensure that certain files not | ||
# tracked by Git remain untracked. | ||
# | ||
# To ignore uncommitted changes in a file that is already tracked, | ||
# use `git update-index --assume-unchanged`. | ||
# | ||
# To stop tracking a file that is currently tracked, | ||
# use `git rm --cached` | ||
# | ||
# Change Log: | ||
# 20150227 Ignore hello.php plugin. props @damienfa | ||
# 20150227 Change theme ignore to wildcard twenty*. props @Z33 | ||
# 20140606 Add .editorconfig as a tracked file | ||
# 20140404 Ignore database, compiled, and packaged files | ||
# 20140404 Header Information Updated | ||
# 20140402 Initially Published | ||
# | ||
# ----------------------------------------------------------------- | ||
|
||
# ignore all files starting with . | ||
.* | ||
|
||
# track this file .gitignore (i.e. do NOT ignore it) | ||
!.gitignore | ||
|
||
# Eslint | ||
!.eslintrc | ||
!.eslintignore | ||
|
||
# track .editorconfig file (i.e. do NOT ignore it) | ||
!.editorconfig | ||
|
||
# track readme.md in the root (i.e. do NOT ignore it) | ||
!readme.md | ||
|
||
# ignore all files that start with ~ | ||
~* | ||
|
||
# ignore OS generated files | ||
ehthumbs.db | ||
Thumbs.db | ||
|
||
# ignore Editor files | ||
*.sublime-project | ||
*.sublime-workspace | ||
*.komodoproject | ||
|
||
# ignore log files and databases | ||
*.log | ||
*.sql | ||
*.sqlite | ||
|
||
# ignore compiled files | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
|
||
# ignore packaged files | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
|
||
# ignore node/grunt dependency directories | ||
node_modules/ | ||
|
||
# bower | ||
bower_components | ||
|
||
code-coverage | ||
|
||
# no map files | ||
*.map | ||
|
||
vendor | ||
!/src/vendor | ||
|
||
tests/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace OWC\OpenPub\Base; | ||
|
||
class Autoloader | ||
{ | ||
|
||
/** | ||
* Autoloader constructor. | ||
* PSR autoloader | ||
*/ | ||
public function __construct() | ||
{ | ||
spl_autoload_register(function ($className) { | ||
$baseDir = __DIR__.'/src/'; | ||
$namespace = str_replace("\\", "/", __NAMESPACE__); | ||
$className = str_replace("\\", "/", $className); | ||
$class = $baseDir.(empty($namespace) ? "" : $namespace."/").$className.'.php'; | ||
$class = str_replace('/OWC/OpenPub/Base/OWC/OpenPub/Base/', '/Base/', $class); | ||
if (file_exists($class)) { | ||
require_once($class); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ $# -lt 3 ]; then | ||
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]" | ||
exit 1 | ||
fi | ||
|
||
DB_NAME=$1 | ||
DB_USER=$2 | ||
DB_PASS=$3 | ||
DB_HOST=${4-localhost} | ||
WP_VERSION=${5-latest} | ||
SKIP_DB_CREATE=${6-false} | ||
|
||
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} | ||
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} | ||
|
||
download() { | ||
if [ `which curl` ]; then | ||
curl -s "$1" > "$2"; | ||
elif [ `which wget` ]; then | ||
wget -nv -O "$2" "$1" | ||
fi | ||
} | ||
|
||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then | ||
WP_TESTS_TAG="$WP_VERSION" | ||
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then | ||
WP_TESTS_TAG="trunk" | ||
else | ||
# http serves a single offer, whereas https serves multiple. we only want one | ||
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json | ||
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json | ||
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') | ||
if [[ -z "$LATEST_VERSION" ]]; then | ||
echo "Latest WordPress version could not be found" | ||
exit 1 | ||
fi | ||
WP_TESTS_TAG="$LATEST_VERSION" | ||
fi | ||
|
||
set -ex | ||
|
||
install_wp() { | ||
|
||
if [ -d $WP_CORE_DIR ]; then | ||
return; | ||
fi | ||
|
||
mkdir -p $WP_CORE_DIR | ||
|
||
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then | ||
mkdir -p /tmp/wordpress-nightly | ||
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip | ||
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/ | ||
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR | ||
else | ||
if [ $WP_VERSION == 'latest' ]; then | ||
local ARCHIVE_NAME='latest' | ||
else | ||
local ARCHIVE_NAME="wordpress-$WP_VERSION" | ||
fi | ||
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz | ||
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR | ||
fi | ||
|
||
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php | ||
} | ||
|
||
install_test_suite() { | ||
# portable in-place argument for both GNU sed and Mac OSX sed | ||
if [[ $(uname -s) == 'Darwin' ]]; then | ||
local ioption='-i .bak' | ||
else | ||
local ioption='-i' | ||
fi | ||
|
||
# set up testing suite if it doesn't yet exist | ||
if [ ! -d $WP_TESTS_DIR ]; then | ||
# set up testing suite | ||
mkdir -p $WP_TESTS_DIR | ||
git clone --depth=50 --branch="${WP_TESTS_TAG}" https://github.com/WordPress/wordpress-develop ${WP_TESTS_DIR}_2 | ||
mv ${WP_TESTS_DIR}_2/tests/phpunit/includes/ ${WP_TESTS_DIR}/includes | ||
mv ${WP_TESTS_DIR}_2/tests/phpunit/data/ ${WP_TESTS_DIR}/data | ||
rm -rf ${WP_TESTS_DIR}_2/ | ||
fi | ||
|
||
if [ ! -f wp-tests-config.php ]; then | ||
download https://develop.svn.wordpress.org/tags/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php | ||
# remove all forward slashes in the end | ||
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") | ||
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php | ||
fi | ||
|
||
} | ||
|
||
install_db() { | ||
|
||
if [ ${SKIP_DB_CREATE} = "true" ]; then | ||
return 0 | ||
fi | ||
|
||
# parse DB_HOST for port or socket references | ||
local PARTS=(${DB_HOST//\:/ }) | ||
local DB_HOSTNAME=${PARTS[0]}; | ||
local DB_SOCK_OR_PORT=${PARTS[1]}; | ||
local EXTRA="" | ||
|
||
if ! [ -z $DB_HOSTNAME ] ; 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" | ||
elif ! [ -z $DB_HOSTNAME ] ; then | ||
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" | ||
fi | ||
fi | ||
|
||
# create database | ||
if [ ! -d /var/lib/mysql/${DB_NAME} ] ; then | ||
mysqladmin create ${DB_NAME} --user="${DB_USER}" --password="${DB_PASS}"${EXTRA} | ||
fi | ||
} | ||
|
||
install_wp | ||
install_test_suite | ||
install_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
image: oktupol/bitbucket-pipelines-php71 | ||
|
||
pipelines: | ||
branches: | ||
master: | ||
- step: | ||
name: unit test | ||
caches: | ||
- composer | ||
- vendor-directory | ||
script: | ||
- composer install --no-interaction --no-progress --prefer-dist --ignore-platform-reqs | ||
- ./vendor/bin/phpunit --testsuite "OWC OpenPub Base Plugin Test Suite" | ||
|
||
definitions: | ||
caches: | ||
vendor-directory: vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "plugin/openpub-base", | ||
"description": "OpenPub base plugin", | ||
"authors": [ | ||
{ | ||
"name": "Edwin Siebel", | ||
"email": "[email protected]", | ||
"homepage": "https://www.yarddigital.nl" | ||
} | ||
], | ||
"type": "wordpress-plugin", | ||
"require": { | ||
"php": ">=7.0" | ||
}, | ||
"require-dev": { | ||
"mockery/mockery": "1.0.*", | ||
"phpunit/phpunit": "~6.0", | ||
"10up/wp_mock": "dev-master", | ||
"phpmd/phpmd": "@stable" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"OWC\\OpenPub\\Base\\": "./src/Base", | ||
"OWC\\OpenPub\\Base\\Tests\\": "./tests" | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.