mirror of
https://github.com/flarum/core.git
synced 2025-08-06 16:36:47 +02:00
chore(phpstan): upgrade to be compatible with latest dependency updates (#3835)
This commit is contained in:
22
php-packages/phpstan/bootstrap.php
Normal file
22
php-packages/phpstan/bootstrap.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (! defined('LARAVEL_VERSION')) {
|
||||
define('LARAVEL_VERSION', '10.0');
|
||||
}
|
||||
|
||||
if (! function_exists('database_path')) {
|
||||
function database_path($path = ''): string
|
||||
{
|
||||
return __DIR__."/../../$path";
|
||||
}
|
||||
}
|
||||
|
||||
$site = (new \Flarum\Testing\integration\Setup\Bootstrapper())->run();
|
||||
$site->bootApp();
|
@@ -4,8 +4,9 @@
|
||||
"minimum-stability": "dev",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"phpstan/phpstan": ">=1.8.11 < 1.9.0",
|
||||
"nunomaduro/larastan": "^1.0"
|
||||
"flarum/testing": "^2.0",
|
||||
"phpstan/phpstan": "^1.10.0",
|
||||
"nunomaduro/larastan": "^2.6"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@@ -1,38 +1,7 @@
|
||||
parameters:
|
||||
stubFiles:
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Enumerable.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/EloquentBuilder.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Collection.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/EloquentCollection.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Factory.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Model.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Gate.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Relation.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/BelongsTo.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/BelongsToMany.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/HasOneOrMany.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/HasMany.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/HasOne.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/HasOneThrough.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/HasManyThrough.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Mailable.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/MorphOne.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/MorphOneOrMany.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/MorphTo.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/MorphToMany.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/MorphMany.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Helpers.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/HigherOrderProxies.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/QueryBuilder.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Facades.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Pagination.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Contracts/Pagination.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Contracts/Support.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Redis/Connection.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/Logger.stub
|
||||
- %rootDir%/../../nunomaduro/larastan/stubs/EnumeratesValues.stub
|
||||
universalObjectCratesClasses:
|
||||
- Illuminate\Http\Request
|
||||
- Illuminate\Support\Optional
|
||||
earlyTerminatingFunctionCalls:
|
||||
- abort
|
||||
- dd
|
||||
@@ -40,17 +9,21 @@ parameters:
|
||||
- *.blade.php
|
||||
mixinExcludeClasses:
|
||||
- Eloquent
|
||||
# bootstrapFiles:
|
||||
# - bootstrap.php
|
||||
checkGenericClassInNonGenericObjectType: false
|
||||
bootstrapFiles:
|
||||
- bootstrap.php
|
||||
checkOctaneCompatibility: false
|
||||
noModelMake: true
|
||||
noUnnecessaryCollectionCall: true
|
||||
noUnnecessaryCollectionCallOnly: []
|
||||
noUnnecessaryCollectionCallExcept: []
|
||||
squashedMigrationsPath: []
|
||||
databaseMigrationsPath: []
|
||||
disableMigrationScan: false
|
||||
disableSchemaScan: false
|
||||
viewDirectories: []
|
||||
checkModelProperties: false
|
||||
checkPhpDocMissingReturn: false
|
||||
checkUnusedViews: false
|
||||
|
||||
parametersSchema:
|
||||
checkOctaneCompatibility: bool()
|
||||
@@ -59,7 +32,12 @@ parametersSchema:
|
||||
noUnnecessaryCollectionCallOnly: listOf(string())
|
||||
noUnnecessaryCollectionCallExcept: listOf(string())
|
||||
databaseMigrationsPath: listOf(string())
|
||||
disableMigrationScan: bool()
|
||||
viewDirectories: listOf(string())
|
||||
squashedMigrationsPath: listOf(string())
|
||||
disableSchemaScan: bool()
|
||||
checkModelProperties: bool()
|
||||
checkUnusedViews: bool()
|
||||
|
||||
conditionalTags:
|
||||
NunoMaduro\Larastan\Rules\NoModelMakeRule:
|
||||
@@ -72,6 +50,8 @@ conditionalTags:
|
||||
phpstan.rules.rule: %checkModelProperties%
|
||||
NunoMaduro\Larastan\Rules\ModelProperties\ModelPropertyStaticCallRule:
|
||||
phpstan.rules.rule: %checkModelProperties%
|
||||
NunoMaduro\Larastan\Rules\UnusedViewsRule:
|
||||
phpstan.rules.rule: %checkUnusedViews%
|
||||
|
||||
services:
|
||||
-
|
||||
@@ -116,6 +96,14 @@ services:
|
||||
class: NunoMaduro\Larastan\Methods\RedirectResponseMethodsClassReflectionExtension
|
||||
tags:
|
||||
- phpstan.broker.methodsClassReflectionExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\Methods\MacroMethodsClassReflectionExtension
|
||||
tags:
|
||||
- phpstan.broker.methodsClassReflectionExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\Methods\ViewWithMethodsClassReflectionExtension
|
||||
tags:
|
||||
- phpstan.broker.methodsClassReflectionExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Properties\ModelAccessorExtension
|
||||
@@ -182,7 +170,12 @@ services:
|
||||
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\ModelExtension
|
||||
class: NunoMaduro\Larastan\ReturnTypes\ModelDynamicStaticMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\AppMakeDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
|
||||
|
||||
@@ -201,13 +194,28 @@ services:
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\DateExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\GuardExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\RequestExtension
|
||||
class: NunoMaduro\Larastan\ReturnTypes\RequestFileExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\RequestRouteExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\RequestUserExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
@@ -241,11 +249,6 @@ services:
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\CollectionMakeDynamicStaticMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Support\CollectionHelper
|
||||
|
||||
@@ -260,7 +263,7 @@ services:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\CookieExtension
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\NowAndTodayExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
@@ -269,31 +272,6 @@ services:
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\RequestExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\RedirectExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\UrlExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\ViewExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\TransExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\Helpers\ValidatorExtension
|
||||
tags:
|
||||
@@ -303,6 +281,30 @@ services:
|
||||
class: NunoMaduro\Larastan\ReturnTypes\CollectionFilterDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\CollectionWhereNotNullDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\CollectionGenericStaticMethodDynamicMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\NewModelQueryDynamicMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\FactoryDynamicMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\CollectionGenericStaticMethodDynamicStaticMethodReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Types\AbortIfFunctionTypeSpecifyingExtension
|
||||
@@ -388,6 +390,10 @@ services:
|
||||
class: NunoMaduro\Larastan\Types\GenericEloquentBuilderTypeNodeResolverExtension
|
||||
tags:
|
||||
- phpstan.phpDoc.typeNodeResolverExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\AppEnvironmentReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Types\ModelProperty\ModelPropertyTypeNodeResolverExtension
|
||||
@@ -405,8 +411,18 @@ services:
|
||||
class: NunoMaduro\Larastan\Properties\MigrationHelper
|
||||
arguments:
|
||||
databaseMigrationPath: %databaseMigrationsPath%
|
||||
disableMigrationScan: %disableMigrationScan%
|
||||
parser: @currentPhpVersionSimpleDirectParser
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Properties\SquashedMigrationHelper
|
||||
arguments:
|
||||
schemaPaths: %squashedMigrationsPath%
|
||||
disableSchemaScan: %disableSchemaScan%
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Properties\ModelCastHelper
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Rules\ModelProperties\ModelPropertiesRuleHelper
|
||||
|
||||
@@ -421,7 +437,7 @@ services:
|
||||
-
|
||||
class: NunoMaduro\Larastan\Rules\RelationExistenceRule
|
||||
tags:
|
||||
- phpstan.rule
|
||||
- phpstan.rules.rule
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Rules\CheckDispatchArgumentTypesCompatibleWithClassConstructorRule
|
||||
@@ -435,5 +451,94 @@ services:
|
||||
dispatchableClass: Illuminate\Foundation\Events\Dispatchable
|
||||
tags:
|
||||
- phpstan.rules.rule
|
||||
- NunoMaduro\Larastan\Properties\Schema\PhpMyAdminDataTypeToPhpTypeConverter
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\LarastanStubFilesExtension
|
||||
tags: [phpstan.stubFilesExtension]
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Rules\UnusedViewsRule
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Collectors\UsedViewFunctionCollector
|
||||
tags:
|
||||
- phpstan.collector
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Collectors\UsedEmailViewCollector
|
||||
tags:
|
||||
- phpstan.collector
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Collectors\UsedViewMakeCollector
|
||||
tags:
|
||||
- phpstan.collector
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Collectors\UsedViewFacadeMakeCollector
|
||||
tags:
|
||||
- phpstan.collector
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\Collectors\UsedRouteFacadeViewCollector
|
||||
tags:
|
||||
- phpstan.collector
|
||||
-
|
||||
class: NunoMaduro\Larastan\Collectors\UsedViewInAnotherViewCollector
|
||||
arguments:
|
||||
parser: @currentPhpVersionSimpleDirectParser
|
||||
-
|
||||
class: NunoMaduro\Larastan\Support\ViewFileHelper
|
||||
arguments:
|
||||
viewDirectories: %viewDirectories%
|
||||
|
||||
# -
|
||||
# class: NunoMaduro\Larastan\ReturnTypes\ApplicationMakeDynamicReturnTypeExtension
|
||||
# tags:
|
||||
# - phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
#
|
||||
# -
|
||||
# class: NunoMaduro\Larastan\ReturnTypes\ContainerMakeDynamicReturnTypeExtension
|
||||
# tags:
|
||||
# - phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\ConsoleCommand\ArgumentDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\ConsoleCommand\HasArgumentDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\ConsoleCommand\OptionDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\ConsoleCommand\HasOptionDynamicReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\TranslatorGetReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\TransHelperReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
-
|
||||
class: NunoMaduro\Larastan\ReturnTypes\DoubleUnderscoreHelperReturnTypeExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicFunctionReturnTypeExtension
|
||||
|
||||
- NunoMaduro\Larastan\ReturnTypes\AppMakeHelper
|
||||
- NunoMaduro\Larastan\Internal\ConsoleApplicationResolver
|
||||
- NunoMaduro\Larastan\Internal\ConsoleApplicationHelper
|
||||
- NunoMaduro\Larastan\Support\HigherOrderCollectionProxyHelper
|
||||
|
||||
rules:
|
||||
- NunoMaduro\Larastan\Rules\RelationExistenceRule
|
||||
- NunoMaduro\Larastan\Rules\UselessConstructs\NoUselessWithFunctionCallsRule
|
||||
- NunoMaduro\Larastan\Rules\UselessConstructs\NoUselessValueFunctionCallsRule
|
||||
- NunoMaduro\Larastan\Rules\DeferrableServiceProviderMissingProvidesRule
|
||||
- NunoMaduro\Larastan\Rules\ConsoleCommand\UndefinedArgumentOrOptionRule
|
||||
|
@@ -16,6 +16,8 @@ parameters:
|
||||
# @TODO: needs discussion.
|
||||
- message: "#^Unsafe usage of new static[()]{2}.$#"
|
||||
reportUnmatched: false
|
||||
- message: "#^Static access to instance property .*#"
|
||||
reportUnmatched: false
|
||||
|
||||
# ConnectionInterface lacks methods that exist in the implementation,
|
||||
# yet we don't want to inject the implementation.
|
||||
|
@@ -16,6 +16,7 @@ use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\PropertyReflection;
|
||||
use PHPStan\TrinaryLogic;
|
||||
use PHPStan\Type\Generic\GenericObjectType;
|
||||
use PHPStan\Type\IntegerType;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
|
||||
@@ -59,18 +60,14 @@ class RelationProperty implements PropertyReflection
|
||||
|
||||
public function getReadableType(): Type
|
||||
{
|
||||
switch ($this->methodCall->methodName) {
|
||||
case 'hasMany':
|
||||
case 'belongsToMany':
|
||||
return new GenericObjectType(Collection::class, [new ObjectType($this->methodCall->arguments[1]->class->toString())]);
|
||||
|
||||
case 'hasOne':
|
||||
case 'belongsTo':
|
||||
return new ObjectType($this->methodCall->arguments[1]->class->toString());
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown relationship type for relation: '.$this->methodCall->methodName);
|
||||
}
|
||||
return match ($this->methodCall->methodName) {
|
||||
'hasMany', 'belongsToMany' => new GenericObjectType(Collection::class, [
|
||||
new IntegerType(),
|
||||
new ObjectType($this->methodCall->arguments[1]->class->toString())
|
||||
]),
|
||||
'hasOne', 'belongsTo' => new ObjectType($this->methodCall->arguments[1]->class->toString()),
|
||||
default => throw new Exception('Unknown relationship type for relation: '.$this->methodCall->methodName),
|
||||
};
|
||||
}
|
||||
|
||||
public function getWritableType(): Type
|
||||
|
80
php-packages/testing/src/integration/Setup/Bootstrapper.php
Normal file
80
php-packages/testing/src/integration/Setup/Bootstrapper.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Testing\integration\Setup;
|
||||
|
||||
use Flarum\Foundation\Config;
|
||||
use Flarum\Foundation\InstalledSite;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\Testing\integration\Extend\BeginTransactionAndSetDatabase;
|
||||
use Flarum\Testing\integration\Extend\OverrideExtensionManagerForTests;
|
||||
use Flarum\Testing\integration\Extend\SetSettingsBeforeBoot;
|
||||
use Flarum\Testing\integration\UsesTmpDir;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Bootstrapper
|
||||
{
|
||||
use UsesTmpDir;
|
||||
|
||||
public ?ConnectionInterface $database = null;
|
||||
|
||||
public function __construct(
|
||||
protected array $config = [],
|
||||
protected array $extensions = [],
|
||||
protected array $settings = [],
|
||||
protected array $extenders = []
|
||||
) {
|
||||
}
|
||||
|
||||
public function setupOnce(): void
|
||||
{
|
||||
$tmp = $this->tmpDir();
|
||||
|
||||
if (! file_exists("$tmp/config.php")) {
|
||||
$setup = new SetupScript();
|
||||
$setup->run();
|
||||
}
|
||||
}
|
||||
|
||||
public function run(): InstalledSite
|
||||
{
|
||||
$this->setupOnce();
|
||||
|
||||
$tmp = $this->tmpDir();
|
||||
|
||||
$config = include "$tmp/config.php";
|
||||
|
||||
foreach ($this->config as $key => $value) {
|
||||
Arr::set($config, $key, $value);
|
||||
}
|
||||
|
||||
$site = new InstalledSite(
|
||||
new Paths([
|
||||
'base' => $tmp,
|
||||
'public' => "$tmp/public",
|
||||
'storage' => "$tmp/storage",
|
||||
'vendor' => getenv('FLARUM_TEST_VENDOR_PATH') ?: getcwd().'/vendor',
|
||||
]),
|
||||
new Config($config)
|
||||
);
|
||||
|
||||
$extenders = array_merge([
|
||||
new OverrideExtensionManagerForTests($this->extensions),
|
||||
new BeginTransactionAndSetDatabase(function (ConnectionInterface $db) {
|
||||
$this->database = $db;
|
||||
}),
|
||||
new SetSettingsBeforeBoot($this->settings),
|
||||
], $this->extenders);
|
||||
|
||||
$site->extendWith($extenders);
|
||||
|
||||
return $site;
|
||||
}
|
||||
}
|
@@ -10,12 +10,7 @@
|
||||
namespace Flarum\Testing\integration;
|
||||
|
||||
use Flarum\Extend\ExtenderInterface;
|
||||
use Flarum\Foundation\Config;
|
||||
use Flarum\Foundation\InstalledSite;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\Testing\integration\Extend\BeginTransactionAndSetDatabase;
|
||||
use Flarum\Testing\integration\Extend\OverrideExtensionManagerForTests;
|
||||
use Flarum\Testing\integration\Extend\SetSettingsBeforeBoot;
|
||||
use Flarum\Testing\integration\Setup\Bootstrapper;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Support\Arr;
|
||||
@@ -51,35 +46,16 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||
protected function app()
|
||||
{
|
||||
if (is_null($this->app)) {
|
||||
$tmp = $this->tmpDir();
|
||||
|
||||
$config = include "$tmp/config.php";
|
||||
|
||||
foreach ($this->config as $key => $value) {
|
||||
Arr::set($config, $key, $value);
|
||||
}
|
||||
|
||||
$site = new InstalledSite(
|
||||
new Paths([
|
||||
'base' => $tmp,
|
||||
'public' => "$tmp/public",
|
||||
'storage' => "$tmp/storage",
|
||||
'vendor' => getenv('FLARUM_TEST_VENDOR_PATH') ?: getcwd().'/vendor',
|
||||
]),
|
||||
new Config($config)
|
||||
$bootstrapper = new Bootstrapper(
|
||||
$this->config,
|
||||
$this->extensions,
|
||||
$this->settings,
|
||||
$this->extenders
|
||||
);
|
||||
|
||||
$extenders = array_merge([
|
||||
new OverrideExtensionManagerForTests($this->extensions),
|
||||
new BeginTransactionAndSetDatabase(function (ConnectionInterface $db) {
|
||||
$this->database = $db;
|
||||
}),
|
||||
new SetSettingsBeforeBoot($this->settings),
|
||||
], $this->extenders);
|
||||
$this->app = $bootstrapper->run()->bootApp();
|
||||
|
||||
$site->extendWith($extenders);
|
||||
|
||||
$this->app = $site->bootApp();
|
||||
$this->database = $bootstrapper->database;
|
||||
|
||||
$this->populateDatabase();
|
||||
}
|
||||
|
Reference in New Issue
Block a user