diff --git a/src/ConfigHelper.php b/src/ConfigHelper.php index 54d2760..d764bfc 100644 --- a/src/ConfigHelper.php +++ b/src/ConfigHelper.php @@ -19,6 +19,17 @@ public static function get($className, $configKey) return Config::inst()->get($className, $configKey); } + /** + * @param string $className + * @param string $configKey + * @param string $configValue + * @return array|scalar + */ + public static function update($className, $configKey, $configValue) + { + return Config::inst()->update($className, $configKey, $configValue); + } + /** * @param string $className * @return ObjectType[] diff --git a/tests/SiteTreeMethodClassReflectionExtensionTest.php b/tests/Reflection/SiteTreeMethodClassReflectionExtensionTest.php similarity index 100% rename from tests/SiteTreeMethodClassReflectionExtensionTest.php rename to tests/Reflection/SiteTreeMethodClassReflectionExtensionTest.php diff --git a/tests/SiteTreePropertyClassReflectionExtensionTest.php b/tests/Reflection/SiteTreePropertyClassReflectionExtensionTest.php similarity index 100% rename from tests/SiteTreePropertyClassReflectionExtensionTest.php rename to tests/Reflection/SiteTreePropertyClassReflectionExtensionTest.php diff --git a/tests/RequestFilterBad.php b/tests/Rule/Data/RequestFilterBad.php similarity index 88% rename from tests/RequestFilterBad.php rename to tests/Rule/Data/RequestFilterBad.php index 01716a4..9f79fba 100644 --- a/tests/RequestFilterBad.php +++ b/tests/Rule/Data/RequestFilterBad.php @@ -1,6 +1,6 @@ analyse([__DIR__ . '/RequestFilterGood.php'], []); + $this->analyse([__DIR__ . '/Data/RequestFilterGood.php'], []); } public function testRequestFilterBad(): void { - $this->analyse([__DIR__ . '/RequestFilterBad.php'], [ + $this->analyse([__DIR__ . '/Data/RequestFilterBad.php'], [ [ 'RequestFilter::preRequest() should not return false as this will cause an uncaught "Invalid Request" exception to be thrown by the SilverStripe framework. (returning "null" will not cause this problem)', 21, diff --git a/tests/DBFieldGetStaticReturnTypeExtensionTest.php b/tests/Type/DBFieldGetStaticReturnTypeExtensionTest.php similarity index 96% rename from tests/DBFieldGetStaticReturnTypeExtensionTest.php rename to tests/Type/DBFieldGetStaticReturnTypeExtensionTest.php index 9752680..e175e87 100644 --- a/tests/DBFieldGetStaticReturnTypeExtensionTest.php +++ b/tests/Type/DBFieldGetStaticReturnTypeExtensionTest.php @@ -4,6 +4,7 @@ use SilbinaryWolf\SilverstripePHPStan\Type\DBFieldStaticReturnTypeExtension; use SilbinaryWolf\SilverstripePHPStan\ClassHelper; +use SilbinaryWolf\SilverstripePHPStan\Tests\ResolverTest; class DBFieldGetStaticReturnTypeExtensionTest extends ResolverTest { diff --git a/tests/DataListReturnTypeExtensionTest.php b/tests/Type/DataListReturnTypeExtensionTest.php similarity index 98% rename from tests/DataListReturnTypeExtensionTest.php rename to tests/Type/DataListReturnTypeExtensionTest.php index 17e9101..2f01fd8 100644 --- a/tests/DataListReturnTypeExtensionTest.php +++ b/tests/Type/DataListReturnTypeExtensionTest.php @@ -5,6 +5,7 @@ use SilbinaryWolf\SilverstripePHPStan\Type\DataListReturnTypeExtension; use SilbinaryWolf\SilverstripePHPStan\Type\DataObjectGetStaticReturnTypeExtension; use SilbinaryWolf\SilverstripePHPStan\ClassHelper; +use SilbinaryWolf\SilverstripePHPStan\Tests\ResolverTest; class DataListReturnTypeExtensionTest extends ResolverTest { diff --git a/tests/DataObjectGetStaticReturnTypeExtensionTest.php b/tests/Type/DataObjectGetStaticReturnTypeExtensionTest.php similarity index 97% rename from tests/DataObjectGetStaticReturnTypeExtensionTest.php rename to tests/Type/DataObjectGetStaticReturnTypeExtensionTest.php index 799ea00..e109ea9 100644 --- a/tests/DataObjectGetStaticReturnTypeExtensionTest.php +++ b/tests/Type/DataObjectGetStaticReturnTypeExtensionTest.php @@ -4,6 +4,7 @@ use SilbinaryWolf\SilverstripePHPStan\Type\DataObjectGetStaticReturnTypeExtension; use SilbinaryWolf\SilverstripePHPStan\ClassHelper; +use SilbinaryWolf\SilverstripePHPStan\Tests\ResolverTest; class DataObjectGetStaticReturnTypeExtensionTest extends ResolverTest { diff --git a/tests/DataObjectReturnTypeExtensionTest.php b/tests/Type/DataObjectReturnTypeExtensionTest.php similarity index 96% rename from tests/DataObjectReturnTypeExtensionTest.php rename to tests/Type/DataObjectReturnTypeExtensionTest.php index 8877350..7cffb43 100644 --- a/tests/DataObjectReturnTypeExtensionTest.php +++ b/tests/Type/DataObjectReturnTypeExtensionTest.php @@ -4,6 +4,7 @@ use SilbinaryWolf\SilverstripePHPStan\Type\DataObjectReturnTypeExtension; use SilbinaryWolf\SilverstripePHPStan\ClassHelper; +use SilbinaryWolf\SilverstripePHPStan\Tests\ResolverTest; class DataObjectReturnTypeExtensionTest extends ResolverTest { diff --git a/tests/ExtensionReturnTypeExtensionTest.php b/tests/Type/ExtensionReturnTypeExtensionTest.php similarity index 94% rename from tests/ExtensionReturnTypeExtensionTest.php rename to tests/Type/ExtensionReturnTypeExtensionTest.php index 7c621d5..44ea3e7 100644 --- a/tests/ExtensionReturnTypeExtensionTest.php +++ b/tests/Type/ExtensionReturnTypeExtensionTest.php @@ -3,9 +3,8 @@ namespace SilbinaryWolf\SilverstripePHPStan\Tests; use SilbinaryWolf\SilverstripePHPStan\Type\ExtensionReturnTypeExtension; - -// SilverStripe -use Config; +use SilbinaryWolf\SilverstripePHPStan\ConfigHelper; +use SilbinaryWolf\SilverstripePHPStan\Tests\ResolverTest; class ExtensionReturnTypeExtensionTest extends ResolverTest { @@ -35,7 +34,7 @@ public function testDynamicMethodReturnTypeExtensions( new ExtensionReturnTypeExtension(), ]; $dynamicStaticMethodReturnTypeExtensions = []; - Config::inst()->update( + ConfigHelper::update( \DataExtensionDynamicMethodReturnTypesNamespace\Foo::class, 'extensions', [ @@ -85,12 +84,12 @@ public function testUnionDynamicMethodReturnTypeExtensions( $extensions = [ \DataExtensionUnionDynamicMethodReturnTypesNamespace\FooDataExtension::class, ]; - Config::inst()->update( + ConfigHelper::update( \DataExtensionUnionDynamicMethodReturnTypesNamespace\Foo::class, 'extensions', $extensions ); - Config::inst()->update( + ConfigHelper::update( \DataExtensionUnionDynamicMethodReturnTypesNamespace\FooTwo::class, 'extensions', $extensions diff --git a/tests/InjectorReturnTypeExtensionTest.php b/tests/Type/InjectorReturnTypeExtensionTest.php similarity index 96% rename from tests/InjectorReturnTypeExtensionTest.php rename to tests/Type/InjectorReturnTypeExtensionTest.php index 68ef77d..85c1438 100644 --- a/tests/InjectorReturnTypeExtensionTest.php +++ b/tests/Type/InjectorReturnTypeExtensionTest.php @@ -3,8 +3,9 @@ namespace SilbinaryWolf\SilverstripePHPStan\Tests; use SilbinaryWolf\SilverstripePHPStan\Type\InjectorReturnTypeExtension; -use \SilbinaryWolf\SilverstripePHPStan\Type\SingletonReturnTypeExtension; +use SilbinaryWolf\SilverstripePHPStan\Type\SingletonReturnTypeExtension; use SilbinaryWolf\SilverstripePHPStan\ClassHelper; +use SilbinaryWolf\SilverstripePHPStan\Tests\ResolverTest; class InjectorReturnTypeExtensionTest extends ResolverTest { diff --git a/tests/data/data-extension-dynamic-method-return-types.php b/tests/Type/data/data-extension-dynamic-method-return-types.php similarity index 100% rename from tests/data/data-extension-dynamic-method-return-types.php rename to tests/Type/data/data-extension-dynamic-method-return-types.php diff --git a/tests/data/data-extension-union-dynamic-method-return-types.php b/tests/Type/data/data-extension-union-dynamic-method-return-types.php similarity index 100% rename from tests/data/data-extension-union-dynamic-method-return-types.php rename to tests/Type/data/data-extension-union-dynamic-method-return-types.php diff --git a/tests/data/data-list-return-types.php b/tests/Type/data/data-list-return-types.php similarity index 100% rename from tests/data/data-list-return-types.php rename to tests/Type/data/data-list-return-types.php diff --git a/tests/data/data-object-dynamic-method-return-types.php b/tests/Type/data/data-object-dynamic-method-return-types.php similarity index 100% rename from tests/data/data-object-dynamic-method-return-types.php rename to tests/Type/data/data-object-dynamic-method-return-types.php diff --git a/tests/bootstrap-phpunit.php b/tests/bootstrap-phpunit.php index 2ed938a..dd181f6 100644 --- a/tests/bootstrap-phpunit.php +++ b/tests/bootstrap-phpunit.php @@ -14,5 +14,5 @@ require_once(__DIR__.'/../bootstrap.php'); // Used by: RequestFilterPreRequestRuleTest -require_once(__DIR__.'/RequestFilterBad.php'); -require_once(__DIR__.'/RequestFilterGood.php'); +require_once(__DIR__.'/Rule/data/RequestFilterBad.php'); +require_once(__DIR__.'/Rule/data/RequestFilterGood.php');