Skip to content
Snippets Groups Projects
Commit 02f9d4c2 authored by Krzysztof Dyszczyk's avatar Krzysztof Dyszczyk
Browse files

Seria usprawnien w testach i dokumentacji oraz wsparcie dla deployowania

wtyczek do sklepu i repo
parent b1908822
No related branches found
No related tags found
No related merge requests found
before_script:
- cd ${CI_PROJECT_DIR}
variables:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_DATABASE: wptest
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
MYSQL_INNODB_LOG_BUFFER_SIZE: 32M
PHP_ERROR_REPORTING: E_ALL
COMPOSER_ALLOW_SUPERUSER: 1
GIT_STRATEGY: fetch
cache:
untracked: true
paths:
- vendor
stages:
- build
- tests
- pre-deploy
- deploy
build php:
image: wpdesknet/phpunit-woocommerce:0-0
stage: build
artifacts:
expire_in: 1 day
name: "dev vendor"
paths:
- vendor/
script:
- ls /usr/local/bin
- composer install --no-progress
#build js:
# image: node:slim
# stage: build
# script:
# - cd app
# - git clone git@gitlab.com:wpdesk/plugins-tests.git
# - cd plugins-tests
# - npm install
# - grunt dev-chrome
code style test:
image: wpdesknet/phpunit-woocommerce:0-0
stage: tests
allow_failure: true
dependencies:
- build php
script:
- ls -l
- php --version
- php composer.phar phpcs
unit test 0:
image: wpdesknet/phpunit-woocommerce:0-0
stage: tests
dependencies:
- build php
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
script:
- ls -l
- php --version
- php composer.phar phpunit-unit
integration test 0-0:
image: wpdesknet/phpunit-woocommerce:0-0
services:
- mysql
stage: tests
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
dependencies:
- build php
script:
- php --version
- php composer.phar phpunit-integration
integration test 1-1:
image: wpdesknet/phpunit-woocommerce:1-1
services:
- mysql
stage: tests
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
dependencies:
- build php
script:
- php --version
- php composer.phar phpunit-integration
integration test 2-2:
image: wpdesknet/phpunit-woocommerce:2-2
services:
- mysql
stage: tests
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
dependencies:
- build php
script:
- php --version
- php composer.phar phpunit-integration
integration test 3-3:
image: wpdesknet/phpunit-woocommerce:3-3
services:
- mysql
stage: tests
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
dependencies:
- build php
script:
- php --version
- phpunit --configuration phpunit-integration.xml
integration test 4-3:
image: wpdesknet/phpunit-woocommerce:4-3
services:
- mysql
stage: tests
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
dependencies:
- build php
script:
- php --version
- phpunit --configuration phpunit-integration.xml
apigen docs:
image:
name: wpdesknet/apigen
stage: build
artifacts:
expire_in: 1 day
name: "docs"
paths:
- docs/
script:
- ls -l
- /app/vendor/bin/apigen generate
- php /app/hooks-docs.php ${CI_PROJECT_DIR}
when: manual
build to deploy:
image: wpdesknet/phpunit-woocommerce:0-0
stage: pre-deploy
dependencies:
- build php
artifacts:
expire_in: 1 month
name: "production release"
paths:
- release
- release.zip
script:
- php --version
- ls -l
- rm -rf ${CI_PROJECT_DIR}/release
- rm -rf ${CI_PROJECT_DIR}/release.zip
- rm -rf /tmp/release
- mkdir /tmp/release
- mkdir ${CI_PROJECT_DIR}/release
- cp -rf ${CI_PROJECT_DIR}/* /tmp/release
- cp -rf /tmp/release/* ${CI_PROJECT_DIR}/release
- cd ${CI_PROJECT_DIR}/release
- php composer.phar install --no-dev --no-progress
- rm -rf build-coverage
- rm -rf release
- rm -rf tests
- rm -rf docs
- rm -rf .git
- rm -f .editorconfig
- rm -f .gitignore
- rm -f .gitlab-ci.yml
- rm -f apigen.neon
- rm -f composer.json
- rm -f composer.lock
- rm -f phpcs.xml.dist
- rm -f phpunit-integration.xml
- rm -f phpunit-unit.xml
- rm -f composer.phar
- rm -f wp-cli.phar
- zip -r -q ../release.zip ./
only:
- tags
deploy to shop:
image: wpdesknet/amazon-svn-deploy
stage: deploy
dependencies:
- build to deploy
retry: 2
script:
- ls -l
- /tmp/deploy_shop.sh ${CI_PROJECT_NAME} release.zip ${CI_PROJECT_NAME}.zip
only:
- tags
when: manual
deploy to repository:
image: wpdesknet/amazon-svn-deploy
stage: deploy
dependencies:
- build to deploy
retry: 2
script:
- ls -l
- rm -rf /tmp/svn-repository
- mkdir /tmp/svn-repository
- /tmp/deploy_repository.sh flexible-pdf release /tmp/svn-repository
only:
- tags
when: manual
\ No newline at end of file
destination: docs
extensions: [php]
source:
- classes
- plugin-template.php
- bootstrap.php
exclude:
- vendor
- tests
- languages
charset: [UTF-8]
main: Wordpress plugin
title: Plugin template more info
baseUrl: "/"
templateTheme: default
php: false
sourceCode: false
tree: true
deprecated: false
todo: false
download: false
accessLevels:
- public
- private
- protected
\ No newline at end of file
*** plugin-template Changelog ***
1.0.0 - 2018-03-16
* TEST
\ No newline at end of file
......@@ -23,6 +23,10 @@
}
},
"scripts": {
"phpcs": "vendor/bin/phpcs"
"test": "echo composer is alive",
"phpcs": "phpcs",
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
"docs": "apigen generate"
}
}
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "be2486cd1b6bdbc457d614783adfc639",
"hash": "ab79cfb4a1a3de35a971fb4fedc9b4a5",
"content-hash": "12219163e8f6b69c0711dc250b74948b",
"packages": [],
"packages-dev": [
......
<phpunit bootstrap="tests/integration/bootstrap.php"
backupGlobals="false"
>
<testsuites>
<testsuite>
<directory prefix="test-" suffix=".php">./tests/integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">classes</directory>
</whitelist>
</filter>
<logging>
<log type="junit" target="build-coverage/report.junit.xml"/>
<log type="coverage-html" target="build-coverage/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build-coverage/coverage.txt"/>
<log type="coverage-clover" target="build-coverage/clover.xml"/>
</logging>
<php>
<env name="WP_DEVELOP_DIR" value="/tmp/wordpress-develop"/>
<env name="WC_DEVELOP_DIR" value="/tmp/woocommerce"/>
</php>
</phpunit>
\ No newline at end of file
<phpunit bootstrap="tests/unit/bootstrap.php">
<testsuites>
<testsuite>
<directory prefix="test-" suffix=".php">./tests/unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">classes</directory>
</whitelist>
</filter>
<logging>
<log type="junit" target="build-coverage/report.junit.xml"/>
<log type="coverage-html" target="build-coverage/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build-coverage/coverage.txt"/>
<log type="coverage-clover" target="build-coverage/clover.xml"/>
</logging>
</phpunit>
\ No newline at end of file
......@@ -28,6 +28,7 @@
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
......
<?php
// disable xdebug backtrace
if ( function_exists( 'xdebug_disable' ) ) {
xdebug_disable();
}
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
} else {
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
}
require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' );
tests_add_filter( 'muplugins_loaded', function () {
require PLUGIN_PATH . '/plugin-template.php';
$plugins_to_active[] = 'plugin-template/plugin-template.php';
update_option( 'active_plugins', $plugins_to_active );
}, 100 );
putenv('WP_TESTS_DIR=' . getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit');
require_once( getenv( 'WC_DEVELOP_DIR' ) . '/tests/bootstrap.php' );
<?php
use PHPUnit\Framework\TestCase;
require_once( PLUGIN_PATH . '/classes/wpdesk/class-plugin.php' );
require_once( PLUGIN_PATH . '/classes/plugin-template-factory.php' );
class Test_WPDesk_Plugin_Template_Factory extends TestCase {
public function testBuildForNotActivatedPlugin() {
$factory = new WPDesk_Plugin_Template_Factory();
$this->assertInstanceOf( WPDesk_Plugin_Template_Plugin::class, $factory::build_plugin() );
}
public function testGetPluginAlwaysSingleInstance() {
$factory = new WPDesk_Plugin_Template_Factory();
$instanceOne = $factory::get_plugin_instance();
$instanceTwo = $factory::get_plugin_instance();
$this->assertInstanceOf( WPDesk_Plugin_Template_Plugin::class, $instanceOne );
$this->assertSame($instanceOne, $instanceTwo);
}
}
\ No newline at end of file
<?php
/**
* PHPUnit bootstrap file
*/
require_once __DIR__ . '/../../vendor/autoload.php';
error_reporting( E_ALL );
if ( getenv( 'PLUGIN_PATH' ) !== false ) {
define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) );
} else {
define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
}
if ( getenv( 'ABSPATH' ) !== false ) {
define( 'ABSPATH', getenv( 'ABSPATH' ) );
} else {
define( 'ABSPATH', PLUGIN_PATH . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR );
}
WP_Mock::setUsePatchwork( true );
WP_Mock::bootstrap();
<?php
use PHPUnit\Framework\TestCase;
require_once( PLUGIN_PATH . '/classes/wpdesk/class-plugin.php' );
require_once( PLUGIN_PATH . '/classes/plugin-template-factory.php' );
class Test_WPDesk_Plugin_Template_Factory extends TestCase {
public function setUp() {
WP_Mock::setUp();
}
public function tearDown() {
WP_Mock::tearDown();
}
public function testBuildForNotActivatedPlugin() {
WP_Mock::userFunction( 'plugin_basename', [
'return' => 'some-plugin-name'
] );
WP_Mock::userFunction( 'admin_url', [
'return' => 'http://whatever.com'
] );
WP_Mock::userFunction( 'get_option', [
'args' => [ 'api_._activated', '0' ],
'return' => 'not Activated'
] );
WP_Mock::userFunction( 'plugin_dir_url', [
'return' => 'whatever'
] );
WP_Mock::userFunction( 'trailingslashit', [
'return_arg' => 0
] );
$factory = new WPDesk_Plugin_Template_Factory();
$this->assertInstanceOf( WPDesk_Plugin_Template_Plugin::class, $factory::build_plugin() );
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment