Run PHPStan for unit tests
[MAILPOET-2429]
This commit is contained in:
committed by
Jack Kitterhing
parent
078223cd64
commit
39932e9846
28
RoboFile.php
28
RoboFile.php
@@ -453,22 +453,32 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function qaPhpstan() {
|
function qaPhpstan() {
|
||||||
|
$dir = __DIR__;
|
||||||
|
$task = implode(' ', [
|
||||||
|
'WP_ROOT="' . getenv('WP_ROOT') . '"',
|
||||||
|
'php -d memory_limit=2G',
|
||||||
|
"$dir/tasks/phpstan/vendor/bin/phpstan analyse ",
|
||||||
|
'--level 5',
|
||||||
|
]);
|
||||||
|
|
||||||
// PHPStan must be run out of main plugin directory to avoid its autoloading
|
// PHPStan must be run out of main plugin directory to avoid its autoloading
|
||||||
// from vendor/autoload.php where some dev dependencies cause conflicts.
|
// from vendor/autoload.php where some dev dependencies cause conflicts.
|
||||||
$dir = __DIR__;
|
|
||||||
return $this->collectionBuilder()
|
return $this->collectionBuilder()
|
||||||
->taskExec('rm -rf ' . __DIR__ . '/vendor/goaop')
|
->taskExec('rm -rf ' . __DIR__ . '/vendor/goaop')
|
||||||
->taskExec('rm -rf ' . __DIR__ . '/vendor/nikic')
|
->taskExec('rm -rf ' . __DIR__ . '/vendor/nikic')
|
||||||
->taskExec('cd ' . __DIR__ . ' && ./tools/vendor/composer.phar dump-autoload')
|
->taskExec('cd ' . __DIR__ . ' && ./tools/vendor/composer.phar dump-autoload')
|
||||||
->taskExec(
|
|
||||||
'WP_ROOT="' . getenv('WP_ROOT') . '" ' .
|
// lib
|
||||||
'php -d memory_limit=2G ' .
|
->taskExec($task)
|
||||||
"$dir/tasks/phpstan/vendor/bin/phpstan analyse " .
|
->arg("$dir/lib")
|
||||||
"--configuration $dir/tasks/phpstan/phpstan.neon " .
|
|
||||||
'--level 5 ' .
|
|
||||||
"$dir/lib"
|
|
||||||
)
|
|
||||||
->dir(__DIR__ . '/tasks/phpstan')
|
->dir(__DIR__ . '/tasks/phpstan')
|
||||||
|
|
||||||
|
// tests
|
||||||
|
->taskExec($task)
|
||||||
|
->rawArg('--configuration=phpstan-tests.neon')
|
||||||
|
->arg("$dir/tests/unit")
|
||||||
|
->dir(__DIR__ . '/tasks/phpstan')
|
||||||
|
|
||||||
->taskExec('cd ' . __DIR__ . ' && ./tools/vendor/composer.phar install')
|
->taskExec('cd ' . __DIR__ . ' && ./tools/vendor/composer.phar install')
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
|
13
tasks/phpstan/phpstan-tests.neon
Normal file
13
tasks/phpstan/phpstan-tests.neon
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
parameters:
|
||||||
|
mailpoetDir: %rootDir%/../../../../..
|
||||||
|
tmpDir: ../../temp/phpstan
|
||||||
|
bootstrap: bootstrap.php
|
||||||
|
autoload_files:
|
||||||
|
- %mailpoetDir%/vendor/autoload.php
|
||||||
|
- %mailpoetDir%/vendor/codeception/codeception/autoload.php
|
||||||
|
- %mailpoetDir%/vendor/codeception/verify/src/Codeception/function.php
|
||||||
|
- %mailpoetDir%/vendor/codeception/verify/src/Codeception/Verify.php
|
||||||
|
autoload_directories:
|
||||||
|
- %mailpoetDir%/tests/unit
|
||||||
|
dynamicConstantNames:
|
||||||
|
- WP_DEBUG
|
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function __($text) {
|
if (!function_exists('__')) {
|
||||||
return $text;
|
function __($text) {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for mocking WPFunctions
|
// Fix for mocking WPFunctions
|
||||||
@@ -10,8 +12,13 @@ if (!defined('OBJECT')) {
|
|||||||
define( 'OBJECT', 'OBJECT' );
|
define( 'OBJECT', 'OBJECT' );
|
||||||
}
|
}
|
||||||
|
|
||||||
define('ABSPATH', '/');
|
if (!defined('ABSPATH')) {
|
||||||
define('WP_DEBUG', false);
|
define('ABSPATH', '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined('WP_DEBUG')) {
|
||||||
|
define('WP_DEBUG', false);
|
||||||
|
}
|
||||||
|
|
||||||
$console = new \Codeception\Lib\Console\Output([]);
|
$console = new \Codeception\Lib\Console\Output([]);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user