Skip to content
Snippets Groups Projects
Verified Commit 96d8b3da authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

tests: improve tests organization


Move all tests to one directory as no integration tests are
executed. Modernize packages used. Simplify configuration.

Signed-off-by: default avatarBart Jaskulski <bjaskulski@protonmail.com>
parent 4c440080
Branches
Tags
1 merge request!7Draft: tests: improve tests organization
......@@ -8,26 +8,24 @@
}
],
"require": {
"php": ">=7.0"
"php": ">=7.1 | ^8"
},
"require-dev": {
"phpunit/phpunit": "<7",
"wp-coding-standards/wpcs": "^0.14.1",
"squizlabs/php_codesniffer": "^3.0.2",
"mockery/mockery": "*",
"10up/wp_mock": "*",
"wimg/php-compatibility": "^8"
"phpunit/phpunit": "^7 | ^8 | ^9",
"wpdesk/wp-code-sniffer": "^1",
"mockery/mockery": "^1",
"10up/wp_mock": "^1"
},
"autoload": {
"psr-4": {"WPDesk\\View\\": "src/"}
},
"autoload-dev": {
},
"scripts": {
"phpcs": "phpcs",
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
"phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage",
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
"phpunit-integration-fast": "phpunit --configuration phpunit-integration.xml --no-coverage"
"test": "phpunit",
"phpcs": "phpcs"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for WP Desk Plugin">
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->
<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>
<!-- Show progress, show the error codes for each message (source). -->
<arg value="sp"/>
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>
<!-- Cache outcomes for better performance. Remember to add the file to .gitignore. -->
<arg name="cache" value="./.phpcs-cache"/>
<!--
#############################################################################
USE THE WPDeskCS RULESET
#############################################################################
-->
<!-- This value should be aligned with WordPress support version declared in plugin header -->
<config name="minimum_supported_wp_version" value="6.0"/>
<!-- Set value aligned with supported PHP Version for PHPCompatibilityWP check. -->
<config name="testVersion" value="7.1-"/>
<rule ref="WPDeskPlugin"/>
</ruleset>
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Unit Tests">
<directory prefix="Test" suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
......@@ -10,12 +10,12 @@ class TestChainResolver extends \PHPUnit\Framework\TestCase
const RESOLVE_METHOD_NAME = 'resolve';
public function setUp()
public function setUp(): void
{
\WP_Mock::setUp();
}
public function tearDown()
public function tearDown(): void
{
\WP_Mock::tearDown();
}
......
......@@ -9,12 +9,12 @@ class TestDirResolver extends \PHPUnit\Framework\TestCase
const TEMPLATE_FILE = 'some_template.php';
const TEMPLATE_SUBDIR = 'templates';
public function setUp()
public function setUp(): void
{
\WP_Mock::setUp();
}
public function tearDown()
public function tearDown(): void
{
\WP_Mock::tearDown();
}
......
......@@ -9,7 +9,7 @@ class TestThemeResolver extends \PHPUnit\Framework\TestCase
const TEMPLATE_FILE = 'some_template.php';
const TEMPLATE_SUBDIR = 'templates';
public function setUp()
public function setUp(): void
{
\WP_Mock::setUp();
......@@ -43,7 +43,7 @@ class TestThemeResolver extends \PHPUnit\Framework\TestCase
]);
}
public function tearDown()
public function tearDown(): void
{
\WP_Mock::tearDown();
}
......
......@@ -4,7 +4,7 @@
use WPDesk\View\PluginViewBuilder;
class TestPluginViewBuilder extends \PHPUnit\Framework\TestCase {
public function setUp() {
public function setUp(): void {
\WP_Mock::setUp();
\WP_Mock::userFunction('trailingslashit', [
......@@ -14,7 +14,7 @@ class TestPluginViewBuilder extends \PHPUnit\Framework\TestCase {
]);
}
public function tearDown()
public function tearDown(): void
{
\WP_Mock::tearDown();
}
......
<?php
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
require_once __DIR__ . '/../../vendor/autoload.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 );
}
require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' );
tests_add_filter( 'muplugins_loaded', function () {
}, 100 );
putenv('WP_TESTS_DIR=' . getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit');
require_once( getenv( 'WC_DEVELOP_DIR' ) . '/tests/bootstrap.php' );
do_action('plugins_loaded');
\ No newline at end of file
File moved
<?php
/**
* PHPUnit bootstrap file
*/
require_once __DIR__ . '/../../vendor/autoload.php';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment