Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dev-lib
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.DS_Store
composer.lock
/node_modules/
/vendor/
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions bin/install-pre-commit-hook.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions bin/pre-commit
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions bin/travis.sh
Original file line number Diff line number Diff line change
@@ -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
68 changes: 68 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
28 changes: 28 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Beans Child
*
* @package Beans\Child
*/

namespace Beans\Child;

// Include Beans. Do not remove the line below.
require_once get_template_directory() . '/lib/init.php';

/**
* Enqueue LESS and CSS style to the UIkit compiler.
*
* IMPORTANT: The function below enqueue both the style.less and style.css to the UIkit compiler. Remove one of the
* two enqueuer according to your needs
*
* To make sure the compiler re-compile your LESS or CSS on the fly (on page reload), make sure to enable development
* mode via the Admin->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' );
} );
32 changes: 32 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<ruleset name="Beans Child">
<description>The code standard for Beans Child.</description>

<file>.</file>

<!-- Ignore these directories -->
<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- PHP only. We'll use other validators for JS, CSS, etc. -->
<arg name="extensions" value="php"/>

<!-- WordPress Rules -->
<rule ref="WordPress">
<exclude name="WordPress.VIP"/>
</rule>

<rule ref="WordPress.Files.FileName">
<properties>
<property name="is_theme" value="true"/>
<property name="strict_class_file_names" value="false"/>
</properties>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
</rule>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="beans-child" />
</properties>
</rule>
</ruleset>
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="https://schema.phpunit.de/6.3/phpunit.xsd"
bootstrap="tests/phpunit/unit/bootstrap.php"
backupGlobals="false"
colors="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true">

<testsuites>
<testsuite name="unit">
<directory suffix=".php">./tests/phpunit/unit/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">.</directory>
</whitelist>
</filter>
</phpunit>
Binary file added screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -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
*/
4 changes: 4 additions & 0 deletions style.less
Original file line number Diff line number Diff line change
@@ -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.
*/
52 changes: 52 additions & 0 deletions tests/phpunit/integration/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Bootstraps the WordPress Integration Tests
*
* @package Beans\Child\Tests\Integration
* @since 1.5.0
* @link http://www.getbeans.io
* @license GNU-2.0+
*
* @group integrationtests
*/

if ( ! file_exists( '../../../wp-content' ) ) {
return;
}

define( 'BEANS_THEME_DIR', dirname( dirname( dirname( __DIR__ ) ) ) );
define( 'WP_CONTENT_DIR', dirname( dirname( dirname( getcwd() ) ) ) . '/wp-content/' ); // @codingStandardsIgnoreLine.

if ( defined( 'WP_CONTENT_DIR' ) && ! defined( 'WP_PLUGIN_DIR' ) ) {
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . 'plugins/' ); // @codingStandardsIgnoreLine.
}

$beans_tests_dir = getenv( 'WP_TESTS_DIR' );

// Travis CI & Vagrant SSH tests directory.
if ( empty( $beans_tests_dir ) ) {
$beans_tests_dir = '/tmp/wordpress-tests';
}

// Relative path to Core tests directory.
if ( ! file_exists( $beans_tests_dir . '/includes/' ) ) {
$beans_tests_dir = '../../../../tests/phpunit';
}

if ( ! file_exists( $beans_tests_dir . '/includes/' ) ) {
trigger_error( 'Unable to locate wordpress-tests-lib', E_USER_ERROR ); // @codingStandardsIgnoreLine.
}

// Give access to tests_add_filter() function.
require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php';

/**
* Loads theme.
*/
tests_add_filter( 'setup_theme', function() {
register_theme_directory( WP_CONTENT_DIR . '/themes' );
switch_theme( basename( BEANS_THEME_DIR ) );
} );

// Start up the WP testing environment.
require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';
Loading