Skip to content

Commit

Permalink
chore: prepare test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
whizark committed Dec 23, 2015
1 parent e7464d8 commit ab4b00d
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service_name: travis-ci
src_dir: src
coverage_clover: build/logs/clover.xml
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ package.json export-ignore
npm-shrinkwrap.json export-ignore
.mdastrc export-ignore
composer.json export-ignore
phpunit.xml.dist export-ignore
.coveralls.yml export-ignore
tests/ export-ignore
.travis.yml export-ignore
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,67 @@ php:
- '7.0'
- hhvm

env:
- WP_VERSION=4.3 WP_MULTISITE=0
- WP_VERSION=4.3 WP_MULTISITE=1
- WP_VERSION=4.4 WP_MULTISITE=0
- WP_VERSION=4.4 WP_MULTISITE=1

matrix:
fast_finish: true
allow_failures:
- php: hhvm

cache:
directories:
- node_modules
- $HOME/.composer/cache/files

before_install:
- npm config set spin false
- npm install -g npm
- composer self-update

install:
- npm install
- composer install --prefer-source

before_script:
- BUILD_PATH="$(pwd)"
- BUILD_DIR="$(basename "$BUILD_PATH")"
- BASE_PATH=/tmp
- WP_CORE_DIR=wordpress
- WP_CORE_PATH="$BASE_PATH/$WP_CORE_DIR"
- WP_TESTS_LIB_DIR=wordpress-tests-lib
- WP_TESTS_LIB_PATH="$BASE_PATH/$WP_TESTS_LIB_DIR"
- DB_NAME=wordpress_tests
- COMPONENT_DIR=mu-plugins
- LOADER_FILE=loader/00-devaloka-loader.php
- wget -nv -O "$BASE_PATH/wordpress-$WP_VERSION.tar.gz" "https://wordpress.org/wordpress-$WP_VERSION.tar.gz"
- mkdir -p "$WP_CORE_PATH"
- tar --strip-components=1 -zxmf "$BASE_PATH/wordpress-$WP_VERSION.tar.gz" -C "$WP_CORE_PATH"
- wget -nv -O "$WP_CORE_PATH/wp-content/db.php" https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
- mkdir -p $WP_TESTS_LIB_PATH
- svn export --quiet "https://develop.svn.wordpress.org/tags/$WP_VERSION/tests/phpunit/includes/" "$WP_TESTS_LIB_PATH/includes"
- wget -nv -O "$WP_TESTS_LIB_PATH/wp-tests-config.php" "https://develop.svn.wordpress.org/tags/$WP_VERSION/wp-tests-config-sample.php"
- sed -i "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_PATH/':" "$WP_TESTS_LIB_PATH/wp-tests-config.php"
- sed -i "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_LIB_PATH/wp-tests-config.php"
- sed -i "s/yourusernamehere/travis/" "$WP_TESTS_LIB_PATH/wp-tests-config.php"
- sed -i "s/yourpasswordhere//" "$WP_TESTS_LIB_PATH/wp-tests-config.php"
- mysqladmin create "$DB_NAME" --user="root"
- mv vendor $WP_CORE_PATH/
- if [[ -e wp-content ]]; then mv -f wp-content $WP_CORE_PATH/; fi
- mkdir -p "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/$BUILD_DIR"
- cp -rf "$BUILD_PATH" "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/"
- cp -rf "$BUILD_PATH/$LOADER_FILE" "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/"
- cd "$WP_CORE_PATH/wp-content/$COMPONENT_DIR/$BUILD_DIR"

script:
- npm run-script lint-travis
- phpunit --colors --verbose --coverage-clover build/logs/clover.xml

after_script:
- "$WP_CORE_PATH/vendor/bin/coveralls --verbose --root_dir ."

notifications:
email:
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
"pimple/pimple" : "~3.0",
"symfony/event-dispatcher" : "~3.0"
},
"require-dev" : {
"phpunit/phpunit" : "^4.8 || ^5.1",
"mockery/mockery" : "^0.9.4",
"satooshi/php-coveralls": "~0.7.0"
},
"archive" : {
"exclude": [
".gitignore",
Expand All @@ -48,7 +53,8 @@
"npm-shrinkwrap.json",
".mdastrc",
"composer.json",
".travis.yml"
".travis.yml",
"tests"
]
},
"extra" : {
Expand Down
27 changes: 27 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.1/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>

<testsuites>
<testsuite name="Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
<file>./devaloka.php</file>
</whitelist>
</filter>
</phpunit>
31 changes: 31 additions & 0 deletions tests/Devaloka/DevalokaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace Tests\Devaloka;

use Mockery;
use WP_UnitTestCase;

/**
* Class DevalokaTest
*
* @package Tests\Devaloka
* @author Whizark
*/
class DevalokaTest extends WP_UnitTestCase
{
/**
* Sets up the test case.
*/
public function setUp()
{
parent::setUp();
}

public function testTestClassShouldBeLoaded()
{
}

public function tearDown()
{
Mockery::close();
}
}
10 changes: 10 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
if (getenv('WP_TESTS_LIB_PATH')) {
require getenv('WP_TESTS_LIB_PATH') . '/includes/bootstrap.php';
} else {
require '/tmp/wordpress-tests-lib/includes/bootstrap.php';
}

$loader = require ABSPATH . 'vendor/autoload.php';

$loader->add('Tests\\Devaloka\\', __DIR__ . '/Devaloka/');

0 comments on commit ab4b00d

Please sign in to comment.