diff --git a/.dev-lib b/.dev-lib new file mode 100644 index 0000000..80b05c2 --- /dev/null +++ b/.dev-lib @@ -0,0 +1,10 @@ +PROJECT_TYPE=theme +WPCS_STANDARD=phpcs.xml.dist +PATH_EXCLUDES_PATTERN='^(.*/)?(vendor|node_modules)/.*' +DEV_LIB_SKIP=yuicompressor,codeception,grunt,jshint + +# Run integration tests when the DEV_LIB_ONLY is set to phpunit +# This is the only flag we can use to change the config file +if [ 'phpunit' == "$DEV_LIB_ONLY" ]; then + PHPUNIT_CONFIG=tests/phpunit/integration/phpunit.xml.dist +fi diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c951f00 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[{.jshintrc,*.json,*.yml}] +indent_style = space +indent_size = 2 + +[{*.txt,wp-config-sample.php}] +end_of_line = crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb6572b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.DS_Store +composer.lock +/node_modules/ +/vendor/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9c4c2a1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +language: php +sudo: false + +cache: + directories: + node_modules + vendor + +addons: + apt: + packages: + - libxml2-utils + +matrix: + include: + - php: '5.6' + - php: '7.0' + - php: '7.1' + - php: '7.2' + +install: + - composer install + - export DEV_LIB_PATH=vendor/xwp/wp-dev-lib + - source $DEV_LIB_PATH/travis.install.sh + +script: + - source bin/travis.sh + +after_script: + - source $DEV_LIB_PATH/travis.after_script.sh diff --git a/bin/install-pre-commit-hook.sh b/bin/install-pre-commit-hook.sh new file mode 100755 index 0000000..d517cb3 --- /dev/null +++ b/bin/install-pre-commit-hook.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Link pre-commit hook for a repo in the directory supplied as an argument, or the parent repo of this file. +# +# USAGES: +# $ /path/to/install-pre-commit-hook.sh +# $ /path/to/install-pre-commit-hook.sh wp-content/themes/my-theme + +set -e + +# Check if Perl is installed +command -v perl >/dev/null 2>&1 || { echo >&2 "Perl is not installed, and is required by this script. See how to install it on http://learn.perl.org/installing"; exit 1; } + +# Store the initial directory to return back to it later +OLDPWD=$(pwd) + +# Navigate to the script directory +cd "$(dirname $0)" + +# Get full path of the script directory +BINDIR=$(pwd) + +# Get back to the calling directory +cd - &> /dev/null + +# If passed a destination, switch to it to get the full path and then .git/hooks directory +if [ ! -z "$1" ]; then + cd $1 + DEST=$(pwd) +fi + +# Get the hooks directory of the current git repo +cd "$(git rev-parse --git-dir)/hooks" + +# Get relative path to the original file from within the hooks directory +RELPATH=$( perl -e 'use File::Spec; print File::Spec->abs2rel(@ARGV)' "$BINDIR/pre-commit" "$(pwd)" ) + +if [ -z "$RELPATH" ]; then + echo 'Could not determine the relative path, Sorry. Try symlinking the file manually.' + exit 1 +fi + +echo "## Placing pre-commit file in $(pwd) from $RELPATH" +ln -s "$RELPATH" . + +# Return back to the calling directory +cd "$OLDPWD" &> /dev/null diff --git a/bin/pre-commit b/bin/pre-commit new file mode 100755 index 0000000..0c7be46 --- /dev/null +++ b/bin/pre-commit @@ -0,0 +1,17 @@ +#!/bin/bash +DEV_LIB_HOOK_PATH='./vendor/xwp/wp-dev-lib/pre-commit' + +# Exit if the dev lib isn't installed +if [ ! -f $DEV_LIB_HOOK_PATH ]; then + echo "Oops, the Dev Library is not install, please run composer install!" +else + # Run sniffers and unit tests. + export PATH="./vendor/bin:$PATH" + export WP_TESTS_DIR='exclude' + $DEV_LIB_HOOK_PATH + + # Run integration tests. + export WP_TESTS_DIR='' + export DEV_LIB_ONLY=phpunit + $DEV_LIB_HOOK_PATH +fi diff --git a/bin/travis.sh b/bin/travis.sh new file mode 100644 index 0000000..b7346ad --- /dev/null +++ b/bin/travis.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +export PATH="./vendor/bin:$PATH" + +# Exit if the dev lib isn't installed +if [ ! -f $DEV_LIB_TRAVIS_PATH ]; then + echo "Oops, the Dev Library is not install, please run composer install!" +else + echo "## Checking files, scope $CHECK_SCOPE:" + if [[ $CHECK_SCOPE != "all" ]]; then + cat "$TEMP_DIRECTORY/paths-scope" + fi + + # Run sniffers. + lint_js_files + lint_php_files + + # Run unit tests. + echo '## Running unit tests:' + phpunit --testsuite unit + + # Run integration tests. + echo '## Running integration tests:' + export PHPUNIT_CONFIG=tests/phpunit/integration/phpunit.xml.dist + run_phpunit_travisci +fi diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..acc06c4 --- /dev/null +++ b/composer.json @@ -0,0 +1,68 @@ +{ + "name": "beans/beans-child", + "description": "Beans theme starter child theme.", + "type": "wordpress-theme", + "license": "GPL-2.0+", + "homepage": "http://www.getbeans.io/", + "support": { + "issues": "https://github.com/Getbeans/Beans-Starter-Child-Theme/issues", + "source": "https://github.com/Getbeans/Beans-Starter-Child-Theme" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "exclude-from-classmap": [ + "/tests/" + ] + }, + "autoload-dev": { + "psr-4": { + "Beans\\Child\\Tests\\": "tests/" + } + }, + "repositories": [ + { + "type": "package", + "package": { + "name": "xwp/wp-dev-lib", + "version": "1.0.1", + "source": { + "url": "https://github.com/xwp/wp-dev-lib.git", + "type": "git", + "reference": "master" + } + } + } + ], + "require": { + "php": "^5.6|^7", + "composer/installers": "^1.4", + "roave/security-advisories": "dev-master" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", + "sirbrillig/phpcs-variable-analysis": "^2.0", + "wimg/php-compatibility": "^8.0", + "wp-coding-standards/wpcs": "^0.14.0", + "phpunit/phpunit": "~4.8 || ~5.7.9", + "brain/monkey": "^2.0", + "mikey179/vfsStream": "^1.6", + "xwp/wp-dev-lib": "^1.0.1" + }, + "config": { + "sort-order": true + }, + "scripts": { + "install-codestandards": [ + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run" + ], + "phpcs-src": "\"vendor/bin/phpcs\"", + "phpcs-tests": "\"vendor/bin/phpcs\" --runtime-set testVersion 5.6 tests/phpunit/", + "phpcs": [ + "@phpcs-src", + "@phpcs-tests" + ], + "test-unit": "\"vendor/bin/phpunit\" --testsuite unit", + "test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/phpunit/integration/phpunit.xml.dist" + } +} diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..1c58472 --- /dev/null +++ b/functions.php @@ -0,0 +1,28 @@ +Appearance->Settings option. + */ +beans_add_action( __NAMESPACE__ . '\enqueue_uikit_assets', 'beans_uikit_enqueue_scripts', function() { + // To remove if you are using style.css only. + beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/style.less', 'less' ); + + // To remove if you are using style.less only. + beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/style.css', 'less' ); +} ); diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..1a5238b --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,32 @@ + + + The code standard for Beans Child. + + . + + + node_modules/* + */vendor/* + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..30a69a2 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,27 @@ + + + + + + ./tests/phpunit/unit/ + + + + + + . + + + diff --git a/screenshot.jpg b/screenshot.jpg new file mode 100644 index 0000000..15a5f61 Binary files /dev/null and b/screenshot.jpg differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..ff74e4e --- /dev/null +++ b/style.css @@ -0,0 +1,11 @@ +/* +Theme Name: Beans child +Description: Starter Child Theme for the Beans Theme. +Author: Beans +Author URI: http://www.getbeans.io +Template: tm-beans +Version: 1.0.0 +Text Domain: beans-child +License: GNU General Public License v2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html +*/ diff --git a/style.less b/style.less new file mode 100644 index 0000000..d4a71e7 --- /dev/null +++ b/style.less @@ -0,0 +1,4 @@ +/* + * In this file, you may style your site using CSS or LESS as well as overwrite UIkit LESS variables. + * Make sure to enable development mode via the Admin->Appearance->Settings option while working on your website. LESS will then be processed on the fly. + */ diff --git a/tests/phpunit/integration/bootstrap.php b/tests/phpunit/integration/bootstrap.php new file mode 100644 index 0000000..ef9a8eb --- /dev/null +++ b/tests/phpunit/integration/bootstrap.php @@ -0,0 +1,52 @@ + + + + + + . + + + diff --git a/tests/phpunit/integration/sample/integrationSample.php b/tests/phpunit/integration/sample/integrationSample.php new file mode 100644 index 0000000..b76b535 --- /dev/null +++ b/tests/phpunit/integration/sample/integrationSample.php @@ -0,0 +1,30 @@ +assertTrue( true ); + } +} diff --git a/tests/phpunit/unit/bootstrap.php b/tests/phpunit/unit/bootstrap.php new file mode 100644 index 0000000..7e1f3a3 --- /dev/null +++ b/tests/phpunit/unit/bootstrap.php @@ -0,0 +1,33 @@ +alias( function ( $path ) { + $path = str_replace( '\\', '/', $path ); + $path = preg_replace( '|(?<=.)/+|', '/', $path ); + + if ( ':' === substr( $path, 1, 1 ) ) { + $path = ucfirst( $path ); + } + + return $path; + } ); + + Functions\when( 'wp_json_encode' )->alias( function ( $array ) { + // @codingStandardsIgnoreLine - WordPress.WP.AlternativeFunctions.json_encode_json_encode - we are mocking the function here. + return json_encode( $array ); + } ); + } + + /** + * Cleans up the test environment after each test. + */ + protected function tearDown() { + Monkey\tearDown(); + parent::tearDown(); + } +} diff --git a/tests/phpunit/unit/sample/unitSample.php b/tests/phpunit/unit/sample/unitSample.php new file mode 100644 index 0000000..042d253 --- /dev/null +++ b/tests/phpunit/unit/sample/unitSample.php @@ -0,0 +1,31 @@ +assertTrue( true ); + } +}