Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
add docker dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Jul 13, 2016
1 parent d2cb600 commit de84d9e
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 349 deletions.
1 change: 1 addition & 0 deletions .docker
Submodule .docker added at d492ff
5 changes: 2 additions & 3 deletions .gitignore
Expand Up @@ -15,7 +15,6 @@ assets/js/admin-settings.build.js
assets/js/admin-settings.min.js
assets/js/admin-system-status.build.js
assets/js/admin-system-status.min.js



composer.lock
.data
.html
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "styleguide"]
path = styleguide
url = https://github.com/kilbot/WooCommerce-POS-StyleGuide.git
[submodule ".docker"]
path = .docker
url = git@github.com:kilbot/WooCommerce-Dev-Docker.git
80 changes: 12 additions & 68 deletions .travis.yml
@@ -1,77 +1,21 @@
language: php
sudo: required

php:
- 5.4
- 7.0
language: node

services:
- docker

env:
matrix:
- WP_VERSION=latest WP_MULTISITE=0
# - WP_VERSION=latest WP_MULTISITE=1
# - WP_VERSION=3.8 WP_MULTISITE=0
# - WP_VERSION=3.8 WP_MULTISITE=1
global:
- secure: SccpWdqY0BXjqH9075hcdunMpjxdk+mo5dTtFNzmlbJf/y+VuQOF8zezYdPbJOvTtNjRTeMzn3F5on0fa+RlXkt+VjbNRBR1slGwPB71ncQDFIbPR/qht81Jkg/SXZMde0rVdhHdYfGfB7HPAbcD42OiAeNxsj8n2pkmzYXRxj0=
- PHP_VERSION=54 WP_VERSION=latest WP_MULTISITE=0
- PHP_VERSION=55 WP_VERSION=latest WP_MULTISITE=0
- PHP_VERSION=56 WP_VERSION=latest WP_MULTISITE=0
- PHP_VERSION=70 WP_VERSION=latest WP_MULTISITE=0

addons:
hosts:
- woopos.dev

before_install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install stable
- git submodule update --init --recursive

install:
# install wordpress & woocommerce & test theme
- bash tests/unit/php/bin/install.sh woopos_tests root '' localhost $WP_VERSION
- mkdir /tmp/wordpress/wp-content/plugins/woocommerce-pos/
- mv * .[^.]* /tmp/wordpress/wp-content/plugins/woocommerce-pos/
- mv /tmp/wordpress/* ./
- git clone https://github.com/kilbot/WooCommerce-POS-Test-Theme.git wp-content/themes/WooCommerce-POS-Test-Theme
- git clone https://github.com/kilbot/WooCommerce-POS-Test-Plugin.git wp-content/plugins/woocommerce-pos-test
# apache
- sudo apt-get update
- sudo apt-get install apache2 libapache2-mod-fastcgi
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf;
- if [ "`phpenv version-name`" == "7.0" ] ; then sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf; fi
- sudo a2enmod rewrite actions fastcgi alias
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
# configure apache virtual hosts
- sudo cp -f ./wp-content/plugins/woocommerce-pos/tests/integration/php/bin/travis-ci-apache /etc/apache2/sites-available/default
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default
- sudo service apache2 restart

before_script:
# wp-cli
- curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
- chmod +x wp-cli.phar
- sudo mv wp-cli.phar /usr/local/bin/wp
- wp --info
- wp core config --dbname=woopos_tests --dbuser=root
- wp core install --url=woopos.dev --title=WooCommercePOS --admin_user=admin --admin_password=password --admin_email=support@woopos.com.au
- wp rewrite structure '/%year%/%monthnum%/%postname%'
- wp plugin activate woocommerce-pos
- wp plugin activate woocommerce-pos-test
- wp plugin install woocommerce --activate
- wp plugin install wordpress-importer --activate
- wp import wp-content/plugins/woocommerce/dummy-data/dummy-data.xml --authors=create
- wp option update woocommerce_api_enabled yes
- cp wp-content/plugins/woocommerce-pos/tests/integration/php/bin/wp-cli.yml ./
- wp rewrite flush --hard
# grunt-cli
- cd wp-content/plugins/woocommerce-pos/
- npm install -g grunt-cli
- npm install
- composer install
- npm run build

script:
- grunt test
- phpunit -c tests/unit/php/phpunit.xml
- phpunit -c tests/integration/php/phpunit.xml
# - ./node_modules/.bin/pioneer

after_success:
# - if [ "`phpenv version-name`" == "7.0" ] ; then phpunit -c phpunit.xml.dist && php vendor/bin/coveralls -v && grunt coverage; fi
- if [ "`phpenv version-name`" == "7.0" ] ; then grunt coverage; fi
- if [ $TRAVIS_PHP_VERSION = '7.0' ] && [ $TRAVIS_BRANCH = 'master' ] && [ $TRAVIS_PULL_REQUEST = 'false' ]; then sh apigen/generate-api.sh; fi
- npm run unittest:js
- npm run composer && npm run unittest:php$PHP_VERSION
5 changes: 4 additions & 1 deletion Gruntfile.js
Expand Up @@ -419,8 +419,11 @@ module.exports = function(grunt) {
// test
grunt.registerTask('test', 'Run unit tests', ['symlink', 'simplemocha']);

// build
grunt.registerTask('build', 'Build projects', ['compass', 'cssmin', 'jshint', 'test', 'webpack:dev', 'uglify']);

// dev
grunt.registerTask('dev', 'Development build', ['compass', 'cssmin', 'jshint', 'test', 'webpack:dev', 'uglify', 'watch']);
grunt.registerTask('dev', 'Development build', ['build', 'watch']);

// deploy
grunt.registerTask('deploy', 'Production build', ['test', 'makepot', 'webpack:deploy', 'js_locales', 'uglify', 'copy', 'compress', 'clean']);
Expand Down
4 changes: 2 additions & 2 deletions includes/api/settings.php
Expand Up @@ -14,7 +14,7 @@
use WC_API_Resource;
use WC_API_Server;
use WC_POS\Admin\Settings as Admin_Settings;
use WC_POS\Admin\Settings\Gateways;
use WC_POS\Admin\Settings\Gateways as Admin_Settings_Gateways;
use WC_POS\Admin\Status;

class Settings extends WC_API_Resource {
Expand Down Expand Up @@ -165,7 +165,7 @@ private function get_settings_handler( $id ){
// special case: gateway_
$gateway_id = preg_replace( '/^gateway_/', '', strtolower( $id ), 1, $count );
if($count) {
return new Gateways( $gateway_id );
return new Admin_Settings_Gateways( $gateway_id );
}

// special case: receipt_
Expand Down
22 changes: 15 additions & 7 deletions package.json
Expand Up @@ -3,13 +3,21 @@
"description": "A simple front-end for taking WooCommerce orders at the Point of Sale.",
"version": "0.5.0-beta",
"scripts": {
"test": "grunt test",
"dev": "grunt dev",
"deploy": "grunt deploy",
"tests-install": "bash tests/unit/php/bin/install.sh",
"clean-install": "bash tests/integration/php/bin/install.sh",
"test-php-unit": "phpunit -c tests/unit/php/phpunit.xml",
"test-php-integration": "phpunit -c tests/integration/php/phpunit.xml"
"start": "docker-compose -f .docker/docker-compose.yml up -d",
"stop": "docker-compose -f .docker/docker-compose.yml kill",
"build": "npm run build-assets && npm run build-docker",
"dev": "npm run build && node_modules/.bin/grunt dev --force",
"deploy": "npm install && node_modules/.bin/grunt grunt deploy",
"unittest:js": "npm install && node_modules/.bin/grunt test",
"unittest:php54": "docker exec php54 phpunit -c latest/wp-content/plugins/woocommerce-pos/tests/unit/php/phpunit.xml",
"unittest:php55": "docker exec php55 phpunit -c latest/wp-content/plugins/woocommerce-pos/tests/unit/php/phpunit.xml",
"unittest:php56": "docker exec php56 phpunit -c latest/wp-content/plugins/woocommerce-pos/tests/unit/php/phpunit.xml",
"unittest:php70": "docker exec php70 phpunit -c latest/wp-content/plugins/woocommerce-pos/tests/unit/php/phpunit.xml",
"tests-db": "docker exec mysql57 mysql --password=$MYSQL_ROOT_PASSWORD -Bse \"CREATE DATABASE IF NOT EXISTS $MYSQL_TESTS_DATABASE;\"",
"build-assets": "npm install && node_modules/.bin/grunt build --force",
"build-docker": "docker-compose -f .docker/docker-compose.yml build && npm run start",
"teardown-docker": "npm run stop && docker rm $(docker ps -a -q) && rm -rf .data && rm -rf .html",
"composer": "docker exec php56 composer install -d latest/wp-content/plugins/woocommerce-pos/"
},
"repository": {
"type": "git",
Expand Down
48 changes: 0 additions & 48 deletions tests/integration/php/bin/install.sh

This file was deleted.

22 changes: 0 additions & 22 deletions tests/integration/php/bin/travis-ci-apache

This file was deleted.

2 changes: 0 additions & 2 deletions tests/integration/php/bin/wp-cli.yml

This file was deleted.

50 changes: 1 addition & 49 deletions tests/integration/php/bootstrap.php
Expand Up @@ -2,8 +2,6 @@

namespace WC_POS;

use WC_Tax;

class Integration_Tests {

public function __construct(){
Expand All @@ -12,7 +10,6 @@ public function __construct(){
error_reporting( E_ALL );

$this->includes();
$this->setup();
register_shutdown_function( array( $this, 'shutdown' ) );
}

Expand All @@ -22,55 +19,10 @@ public function __construct(){
*/
public function includes(){
require_once(__DIR__.'/../../../../../../wp-load.php');
require_once 'vendor/autoload.php';
require_once 'vendor/autoload.php'; // required to load Guzzle
require_once 'framework/testcase.php';
}

public function setup(){
$this->import_dummy_tax();
}

/**
* copy of import function: WC_Tax_Rate_Importer->import()
* https://github.com/woothemes/woocommerce/blob/master/includes/admin/importers/class-wc-tax-rate-importer.php
*/
private function import_dummy_tax(){

// clear tax rate tables
global $wpdb;
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rates");
$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}woocommerce_tax_rate_locations");

$taxes = array(
array('GB','*','*','*','20.0000','VAT',1,1,1,''),
array('GB','*','*','*','5.0000','VAT',1,1,1,'reduced-rate'),
array('GB','*','*','*','0.0000','VAT',1,1,1,'zero-rate'),
array('US','*','*','*','10.0000','US',1,1,1,''),
array('US','AL','12345; 123456','*','2.0000','US AL',2,1,1,'')
);

$loop = 0;

foreach ( $taxes as $tax ) {
list( $country, $state, $postcode, $city, $rate, $name, $priority, $compound, $shipping, $class ) = $tax;
$tax_rate = array(
'tax_rate_country' => $country,
'tax_rate_state' => $state,
'tax_rate' => $rate,
'tax_rate_name' => $name,
'tax_rate_priority' => $priority,
'tax_rate_compound' => $compound ? 1 : 0,
'tax_rate_shipping' => $shipping ? 1 : 0,
'tax_rate_order' => $loop ++,
'tax_rate_class' => $class
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
WC_Tax::_update_tax_rate_postcodes( $tax_rate_id, wc_clean( $postcode ) );
WC_Tax::_update_tax_rate_cities( $tax_rate_id, wc_clean( $city ) );
}

}

/**
* runs after all tests are complete
*/
Expand Down

0 comments on commit de84d9e

Please sign in to comment.