Skip to content

Commit

Permalink
Merge master to fix conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
FelicianoTech committed Feb 27, 2018
2 parents e87d596 + 2a3fa7a commit 0e6c729
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 1 deletion.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.travis.yml
behat.yml
.circleci/config.yml
bitbucket-pipelines.yml
bin/
features/
utils/
Expand Down
57 changes: 57 additions & 0 deletions features/scaffold-plugin-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Feature: Scaffold plugin unit tests
And the {PLUGIN_DIR}/hello-world/phpcs.xml.dist file should exist
And the {PLUGIN_DIR}/hello-world/circle.yml file should not exist
And the {PLUGIN_DIR}/hello-world/.circleci directory should not exist
And the {PLUGIN_DIR}/hello-world/bitbucket-pipelines.yml file should not exist
And the {PLUGIN_DIR}/hello-world/.gitlab-ci.yml file should not exist
And the {PLUGIN_DIR}/hello-world/.travis.yml file should contain:
"""
Expand Down Expand Up @@ -153,6 +154,62 @@ Feature: Scaffold plugin unit tests
MYSQL_DATABASE
"""

Scenario: Scaffold plugin tests with Bitbucket Pipelines as the provider
Given a WP install
And I run `wp scaffold plugin hello-world --skip-tests`

When I run `wp plugin path hello-world --dir`
Then save STDOUT as {PLUGIN_DIR}

When I run `wp scaffold plugin-tests hello-world --ci=bitbucket`
Then STDOUT should not be empty
And the {PLUGIN_DIR}/.travis.yml file should not exist
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
"""
pipelines:
default:
"""
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
"""
- step:
image: php:5.6
name: "PHP 5.6"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends
"""
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
"""
- step:
image: php:7.0
name: "PHP 7.0"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends
"""
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
"""
- step:
image: php:7.1
name: "PHP 7.1"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends
"""
And the {PLUGIN_DIR}/bitbucket-pipelines.yml file should contain:
"""
definitions:
services:
database:
image: mysql:latest
environment:
MYSQL_DATABASE: 'wordpress_tests'
MYSQL_ROOT_PASSWORD: 'root'
"""

Scenario: Scaffold plugin tests with invalid slug
Given a WP install
Then the {RUN_DIR}/wp-content/plugins/hello.php file should exist
Expand Down
51 changes: 51 additions & 0 deletions features/scaffold-theme-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Feature: Scaffold theme unit tests
And the {THEME_DIR}/p2child/phpcs.xml.dist file should exist
And the {THEME_DIR}/p2child/circle.yml file should not exist
And the {THEME_DIR}/p2child/.circleci directory should not exist
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should not exist
And the {THEME_DIR}/p2child/.gitlab-ci.yml file should not exist
And the {THEME_DIR}/p2child/.travis.yml file should contain:
"""
Expand Down Expand Up @@ -152,6 +153,56 @@ Feature: Scaffold theme unit tests
MYSQL_DATABASE
"""

Scenario: Scaffold theme tests with Bitbucket Pipelines as the provider
When I run `wp scaffold theme-tests p2child --ci=bitbucket`
Then STDOUT should not be empty
And the {THEME_DIR}/p2child/.travis.yml file should not exist
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should contain:
"""
pipelines:
default:
"""
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should contain:
"""
- step:
image: php:5.6
name: "PHP 5.6"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends
"""
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should contain:
"""
- step:
image: php:7.0
name: "PHP 7.0"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends
"""
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should contain:
"""
- step:
image: php:7.1
name: "PHP 7.1"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends
"""
And the {THEME_DIR}/p2child/bitbucket-pipelines.yml file should contain:
"""
definitions:
services:
database:
image: mysql:latest
environment:
MYSQL_DATABASE: 'wordpress_tests'
MYSQL_ROOT_PASSWORD: 'root'
"""

Scenario: Scaffold theme tests with invalid slug

When I try `wp scaffold theme-tests .`
Expand Down
5 changes: 5 additions & 0 deletions src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ function plugin( $args, $assoc_args ) {
* - travis
* - circle
* - gitlab
* - bitbucket
* ---
*
* [--force]
Expand Down Expand Up @@ -773,6 +774,7 @@ public function plugin_tests( $args, $assoc_args ) {
* - travis
* - circle
* - gitlab
* - bitbucket
* ---
*
* [--force]
Expand Down Expand Up @@ -868,7 +870,10 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) {
$files_to_create["{$target_dir}/.circleci/config.yml"] = self::mustache_render( 'plugin-circle.mustache', compact( 'wp_versions_to_test' ) );
} else if ( 'gitlab' === $assoc_args['ci'] ) {
$files_to_create["{$target_dir}/.gitlab-ci.yml"] = self::mustache_render( 'plugin-gitlab.mustache' );
} else if ( 'bitbucket' === $assoc_args['ci'] ) {
$files_to_create["{$target_dir}/bitbucket-pipelines.yml"] = self::mustache_render( 'plugin-bitbucket.mustache' );
}

$files_written = $this->create_files( $files_to_create, $force );

$to_copy = array(
Expand Down
105 changes: 105 additions & 0 deletions templates/plugin-bitbucket.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
pipelines:
default:
- step:
image: php:5.6
name: "PHP 5.6"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends

# Install PHPCS
- curl -o /usr/local/bin/phpcs -fSL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar && chmod +x /usr/local/bin/phpcs
- phpcs --version

# Install WordPress Coding Standards
- WPCS_VERSION=0.14.1
- curl -o wpcs.tar.gz -fSL "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/archive/${WPCS_VERSION}.tar.gz"
- mkdir -p /var/wpcs && tar -xzf wpcs.tar.gz --directory /var/wpcs --strip-components 1 && rm wpcs.tar.gz
- phpcs --config-set show_progress 1 && phpcs --config-set colors 1 && phpcs --config-set installed_paths /var/wpcs

## Run PHPCS
- phpcs

# Install PHPUnit
- PHPUNIT_VERSION=5.7.27
- curl -o /usr/local/bin/phpunit "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" && chmod +x /usr/local/bin/phpunit
- phpunit --version

## Run PHPUnit
- bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true
- phpunit
services:
- database

- step:
image: php:7.0
name: "PHP 7.0"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends

# Install PHPCS
- curl -o /usr/local/bin/phpcs -fSL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar && chmod +x /usr/local/bin/phpcs
- phpcs --version

# Install WordPress Coding Standards
- WPCS_VERSION=0.14.1
- curl -o wpcs.tar.gz -fSL "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/archive/${WPCS_VERSION}.tar.gz"
- mkdir -p /var/wpcs && tar -xzf wpcs.tar.gz --directory /var/wpcs --strip-components 1 && rm wpcs.tar.gz
- phpcs --config-set show_progress 1 && phpcs --config-set colors 1 && phpcs --config-set installed_paths /var/wpcs

## Run PHPCS
- phpcs

# Install PHPUnit
- PHPUNIT_VERSION=6.5.6
- curl -o /usr/local/bin/phpunit "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" && chmod +x /usr/local/bin/phpunit
- phpunit --version

## Run PHPUnit
- bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true
- phpunit
services:
- database

- step:
image: php:7.1
name: "PHP 7.1"
script:
# Install Dependencies
- docker-php-ext-install mysqli
- apt-get update && apt-get install -y subversion --no-install-recommends

# Install PHPCS
- curl -o /usr/local/bin/phpcs -fSL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar && chmod +x /usr/local/bin/phpcs
- phpcs --version

# Install WordPress Coding Standards
- WPCS_VERSION=0.14.1
- curl -o wpcs.tar.gz -fSL "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/archive/${WPCS_VERSION}.tar.gz"
- mkdir -p /var/wpcs && tar -xzf wpcs.tar.gz --directory /var/wpcs --strip-components 1 && rm wpcs.tar.gz
- phpcs --config-set show_progress 1 && phpcs --config-set colors 1 && phpcs --config-set installed_paths /var/wpcs

## Run PHPCS
- phpcs

# Install PHPUnit
- PHPUNIT_VERSION=6.5.6
- curl -o /usr/local/bin/phpunit "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" && chmod +x /usr/local/bin/phpunit
- phpunit --version

## Run PHPUnit
- bash bin/install-wp-tests.sh wordpress_tests root root 127.0.0.1 latest true
- phpunit
services:
- database

definitions:
services:
database:
image: mysql:latest
environment:
MYSQL_DATABASE: 'wordpress_tests'
MYSQL_ROOT_PASSWORD: 'root'
1 change: 1 addition & 0 deletions templates/plugin-distignore.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.DS_Store
Thumbs.db
behat.yml
bitbucket-pipelines.yml
bin
.circleci/config.yml
composer.json
Expand Down
2 changes: 1 addition & 1 deletion templates/plugin-test-sample.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SampleTest extends WP_UnitTestCase {
/**
* A single example test.
*/
function test_sample() {
public function test_sample() {
// Replace this with some actual testing code.
$this->assertTrue( true );
}
Expand Down

0 comments on commit 0e6c729

Please sign in to comment.