Added composer test-plugins to test plugin issues with the current version of Grav

This commit is contained in:
Matias Griese 2019-03-18 10:58:21 +02:00
parent 81efef7c60
commit 33282e043b
4 changed files with 62 additions and 0 deletions

View File

@ -3,6 +3,7 @@
1. [](#new)
* Added phpstan: PHP Static Analysis Tool [#2393](https://github.com/getgrav/grav/pull/2393)
* Added `composer test-plugins` to test plugin issues with the current version of Grav
* Grav 1.6: Renamed `$grav['users']` service to `$grav['accounts']`
* Added `Flex::getObjects()` and `Flex::getMixedCollection()` methods for co-mingled collections
* Added support to use single Flex key parameter in `Flex::getObject()` method

View File

@ -91,6 +91,7 @@
"post-create-project-cmd": "bin/grav install",
"phpstan": "vendor/bin/phpstan analyse -l 2 -c ./tests/phpstan/phpstan.neon system/src --memory-limit=256M",
"phpstan-framework": "vendor/bin/phpstan analyse -l 5 -c ./tests/phpstan/phpstan.neon system/src/Grav/Framework --memory-limit=256M",
"test-plugins": "vendor/bin/phpstan analyse -l 0 -c ./tests/phpstan/plugins.neon user/plugins --memory-limit=256M",
"test": "vendor/bin/codecept run unit",
"test-windows": "vendor\\bin\\codecept run unit"
},

View File

@ -0,0 +1,41 @@
<?php
use Grav\Common\Grav;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
\define('GRAV_CLI', true);
\define('GRAV_REQUEST_TIME', microtime(true));
\define('GRAV_USER_INSTANCE', 'FLEX');
$autoload = require __DIR__ . '/../../vendor/autoload.php';
if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
}
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
if (!file_exists(GRAV_ROOT . '/index.php')) {
exit('FATAL: Must be run from ROOT directory of Grav!');
}
$grav = Grav::instance(array('loader' => $autoload));
$grav->setup('tests');
$grav['config']->init();
// Find all plugins in Grav installation and autoload their classes.
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
$iterator = $locator->getIterator('plugins://');
foreach($iterator as $directory) {
if (!$directory->isDir()) {
continue;
}
$autoloader = $directory->getPathname() . '/vendor/autoload.php';
if (file_exists($autoloader)) {
require $autoloader;
}
}

View File

@ -0,0 +1,19 @@
includes:
#- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
fileExtensions:
- php
excludes_analyse:
- %currentWorkingDirectory%/user/plugins/*/vendor/*
- %currentWorkingDirectory%/user/plugins/*/tests/*
bootstrap: tests/phpstan/plugins-bootstrap.php
reportUnmatchedIgnoredErrors: true
universalObjectCratesClasses:
- Grav\Common\Config\Config
- Grav\Common\Config\Languages
- Grav\Common\Config\Setup
- Grav\Common\Data\Data
- Grav\Common\GPM\Common\Package
- Grav\Common\GPM\Local\Package
- Grav\Common\GPM\Remote\Package
- Grav\Common\Session