Skip to content

Commit c0cb7af

Browse files
committed
basic outbox support
1 parent 120d571 commit c0cb7af

File tree

7 files changed

+313
-0
lines changed

7 files changed

+313
-0
lines changed

.svnignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.DS_Store
2+
.editorconfig
3+
.git
4+
.gitignore
5+
.travis.yml
6+
.codeclimate.yml
7+
.data
8+
Gruntfile.js
9+
LINGUAS
10+
Makefile
11+
README.md
12+
readme.md
13+
CODE_OF_CONDUCT.md
14+
LICENSE.md
15+
_site
16+
bin
17+
composer.json
18+
composer.lock
19+
docker-compose.yml
20+
gulpfile.js
21+
package.json
22+
node_modules
23+
npm-debug.log
24+
phpcs.xml
25+
package.json
26+
package-lock.json
27+
phpunit.xml
28+
phpunit.xml.dist
29+
tests
30+
node_modules
31+
vendor

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
language: php
2+
3+
notifications:
4+
email:
5+
on_success: never
6+
on_failure: change
7+
8+
php:
9+
- 5.6
10+
- 7
11+
12+
after_success: bash bin/deploy.sh
13+
14+
env:
15+
matrix:
16+
- WP_VERSION=latest WP_MULTISITE=0
17+
- WP_VERSION=nightly WP_MULTISITE=0
18+
19+
global:
20+
- SVN_REPO: https://plugins.svn.wordpress.org/activitystream-extension/
21+
- GH_REF: https://github.com/pfefferle/wordpress-activitystream-extension.git
22+
- secure: "mNWrMScJrvoABY89j7eWG33cQnaIzvZ5q32bMhZO5kVVqiCI+XVKZuf7vC2DdSeF7BHTgh9PdkkkAzhW/6yhOT1IEXfRMF/5U1JrWbGkN5ByKH0cdxbExmuxKd1sSRC3zxkL7LYoE8vVhR6SXwuqyqa9uBNphJPvV+c6dHNwIjawPbJMlakUXc6a3hZSJbScn5F1a293jgc4Oe2souC1Hds/RTw2igoDdGqY1GC9J6EpXeCETltQcd1HKi+KD2kG47gBWb1B9JTKfkXH7x93wGYUq2JMb0FRzaCe/JzKcEkeyqdZgg/8IkxigY7uRxECF+amu+g5iO4fWPt4KgtoBno1+q4M3T9YHOZ4tv9iJ7Z9jjO/zraeIcXCC0mHP8m3Wqg4D4LWOWtCL+r/iCPIZN/26fQjOtH3MIrpWYEIw6BTrCMRxxYaf7ipc0xzw1rL8IJWRWyMYt21LinuQqAF8K8NMgQPXRbUJ0o6MThyBZuo15otz95cIoXc7ofJcZvEnBe3kwylUKSrO8QCrbfscMzd7wu1KXBDWGWM8jQA0PDN0cYLBIJuqrrLO9w0b3nhsqkuwbmOJG9yIySUkKQMKFIJ6rn7O2qWibNKMGoJWtyM+NOmJ4TlbyOGwSRtjxInUTUlecCZ9WoIwMb1JcB7YH8XAmeMAuRrooPOEx3n8xo="
23+
24+
matrix:
25+
include:
26+
- php: 5.6
27+
env: WP_VERSION=latest WP_MULTISITE=0 WP_PULUGIN_DEPLOY=1
28+
29+
before_script:
30+
- export PATH="$HOME/.composer/vendor/bin:$PATH"
31+
- |
32+
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
33+
composer global require "phpunit/phpunit=5.7.*"
34+
elif [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then
35+
composer global require "phpunit/phpunit=4.8.*"
36+
fi
37+
- bash bin/install-wp-tests.sh wordpress root '' localhost $WP_VERSION
38+
39+
script: phpunit

bin/deploy.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [[ "false" != "$TRAVIS_PULL_REQUEST" ]]; then
6+
echo "Not deploying pull requests."
7+
exit
8+
fi
9+
10+
if [[ ! $WP_PLUGIN_DEPLOY ]]; then
11+
echo "Not deploying."
12+
exit
13+
fi
14+
15+
if [[ ! $SVN_REPO ]]; then
16+
echo "SVN repo is not specified."
17+
exit
18+
fi
19+
20+
# Untrailing slash of SVN_REPO path
21+
SVN_REPO=`echo $SVN_REPO | sed -e "s/\/$//"`
22+
# Git repository
23+
GH_REF=https://github.com/${TRAVIS_REPO_SLUG}.git
24+
25+
echo "Starting deploy..."
26+
27+
mkdir build
28+
29+
cd build
30+
BASE_DIR=$(pwd)
31+
32+
echo "Checking out trunk from $SVN_REPO ..."
33+
svn co -q $SVN_REPO/trunk
34+
35+
echo "Getting clone from $GH_REF to $SVN_REPO ..."
36+
git clone -q $GH_REF ./git
37+
38+
cd ./git
39+
40+
if [ -e "bin/build.sh" ]; then
41+
echo "Starting bin/build.sh."
42+
bash bin/build.sh
43+
fi
44+
45+
cd $BASE_DIR
46+
47+
echo "Syncing git repository to svn"
48+
rsync -a --exclude=".svn" --checksum --delete ./git/ ./trunk/
49+
rm -fr ./git
50+
51+
cd ./trunk
52+
53+
if [ -e ".distignore" ]; then
54+
echo "svn propset form .distignore"
55+
svn propset -q -R svn:ignore -F .distignore .
56+
57+
else
58+
if [ -e ".svnignore" ]; then
59+
echo "svn propset"
60+
svn propset -q -R svn:ignore -F .svnignore .
61+
fi
62+
fi
63+
64+
echo "Run svn add"
65+
svn st | grep '^!' | sed -e 's/\![ ]*/svn del -q /g' | sh
66+
echo "Run svn del"
67+
svn st | grep '^?' | sed -e 's/\?[ ]*/svn add -q /g' | sh
68+
69+
# If tag number and credentials are provided, commit to trunk.
70+
if [[ $TRAVIS_TAG && $SVN_USER && $SVN_PASS ]]; then
71+
if [[ ! -d tags/$TRAVIS_TAG ]]; then
72+
echo "Commit to $SVN_REPO."
73+
svn commit -m "commit version $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null
74+
echo "Take snapshot of $TRAVIS_TAG"
75+
svn copy $SVN_REPO/trunk $SVN_REPO/tags/$TRAVIS_TAG -m "Take snapshot of $TRAVIS_TAG" --username $SVN_USER --password $SVN_PASS --non-interactive 2>/dev/null
76+
else
77+
echo "tags/$TRAVIS_TAG already exists."
78+
fi
79+
else
80+
echo "Nothing to commit and check \`svn st\`."
81+
svn st
82+
fi

bin/install-wp-tests.sh

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

phpunit.xml.dist

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<phpunit
2+
bootstrap="tests/bootstrap.php"
3+
backupGlobals="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
>
9+
<testsuites>
10+
<testsuite>
11+
<directory prefix="test-" suffix=".php">./tests/</directory>
12+
</testsuite>
13+
</testsuites>
14+
</phpunit>

tests/bootstrap.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
error_reporting( E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING );
4+
5+
define( 'WP_DEBUG', false );
6+
7+
$_tests_dir = getenv( 'WP_TESTS_DIR' );
8+
if ( ! $_tests_dir ) {
9+
$_tests_dir = '/tmp/wordpress-tests-lib';
10+
}
11+
12+
require_once $_tests_dir . '/includes/functions.php';
13+
14+
function _manually_load_plugin() {
15+
require dirname( dirname( __FILE__ ) ) . '/activitystream-extension.php';
16+
}
17+
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
18+
19+
require $_tests_dir . '/includes/bootstrap.php';
20+
21+
error_reporting( E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING );

tests/test.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
class Test extends WP_UnitTestCase {
3+
public function test() {
4+
$this->assertTrue( true );
5+
}
6+
}

0 commit comments

Comments
 (0)