diff --git a/composer.json b/composer.json index 255a58d38..ffa204bac 100644 --- a/composer.json +++ b/composer.json @@ -142,7 +142,7 @@ "mockery/mockery": "^1.6.12", "phpunit/phpunit": "^10.5.41", "ramsey/collection": "^1.3", - "rector/rector": "~2.0.9", + "rector/rector": "~2.4.5", "spiral/code-style": "^2.2.2", "spiral/nyholm-bridge": "^1.3", "spiral/testing": "^2.12", diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 3e2a8cd08..8876732be 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + registerInstance($ctx, $instance)]]> @@ -20,10 +52,20 @@ key]]> + + + + + delay * $this->multiplier ** $attempts]]> multiplier ** $attempts]]> + + + + + diff --git a/rector.php b/rector.php index 229fd29ad..07d6490b4 100644 --- a/rector.php +++ b/rector.php @@ -18,12 +18,10 @@ use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; -use Rector\Php81\Rector\Array_\FirstClassCallableRector; -use Rector\Php81\Rector\ClassMethod\NewInInitializerRector; +use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector; use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitSelfCallRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; -use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertCountWithZeroToAssertEmptyRector; use Rector\TypeDeclaration\Rector\Closure\AddClosureNeverReturnTypeRector; use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; @@ -71,6 +69,9 @@ __DIR__ . '/src/Logger/src/ListenerRegistry.php', __DIR__ . '/src/Stempler/src/Transform/Merge/ExtendsParent.php', __DIR__ . '/src/Bridge/Stempler/src/StemplerEngine.php', + // Keep the is_string() guard: getBindings() reads user config, so a + // malformed (non-string) binding must be skipped, not crash class_exists(). + __DIR__ . '/src/Prototype/src/Bootloader/PrototypeBootloader.php', ], RemoveExtraParametersRector::class => [ __DIR__ . '/src/Boot/src/BootloadManager/AbstractBootloadManager.php', @@ -93,7 +94,6 @@ RemoveUnusedPublicMethodParameterRector::class, RemoveEmptyClassMethodRector::class, RemoveUnusedPromotedPropertyRector::class, - NewInInitializerRector::class, // start with short open tag __DIR__ . '/src/Views/tests/fixtures/other/var.php', @@ -117,8 +117,10 @@ __DIR__ . '/src/Scaffolder/src/Command', ], - FirstClassCallableRector::class => [ + ArrayToFirstClassCallableRector::class => [ __DIR__ . '/src/Core/tests/Scope/UseCaseTest.php', + __DIR__ . '/src/Core/tests/InjectableTest.php', + __DIR__ . '/src/Core/tests/InvokerTest.php', ], PreferPHPUnitThisCallRector::class, @@ -127,8 +129,24 @@ __DIR__ . '/src/Models/tests/PublicEntity.php', ], - // Explicit behavior is more preferable - AssertCountWithZeroToAssertEmptyRector::class, + // to be enabled later for easier to review + \Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector::class, + \Rector\PHPUnit\PHPUnit120\Rector\CallLike\CreateStubOverCreateMockArgRector::class, + \Rector\Php55\Rector\ClassConstFetch\StaticToSelfOnFinalClassRector::class, + \Rector\PHPUnit\CodeQuality\Rector\MethodCall\StringCastAssertStringContainsStringRector::class, + \Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitSelfCallRector::class, + \Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector::class, + \Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector::class, + \Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector::class, + \Rector\PHPUnit\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector::class, + \Rector\PHPUnit\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector::class, + \Rector\PHPUnit\CodeQuality\Rector\ClassMethod\BareCreateMockAssignToDirectUseRector::class, + \Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector::class, + \Rector\DeadCode\Rector\FunctionLike\NarrowWideUnionReturnTypeRector::class, + \Rector\PHPUnit\CodeQuality\Rector\MethodCall\WithCallbackIdenticalToStandaloneAssertsRector::class, + \Rector\PHPUnit\CodeQuality\Rector\MethodCall\SimplerWithIsInstanceOfRector::class, + \Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class, + \Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector::class, ]) ->withPhpSets(php81: true) ->withPreparedSets(deadCode: true, phpunitCodeQuality: true) diff --git a/src/Boot/src/AbstractKernel.php b/src/Boot/src/AbstractKernel.php index dafd6c7ac..3f675ca25 100644 --- a/src/Boot/src/AbstractKernel.php +++ b/src/Boot/src/AbstractKernel.php @@ -139,7 +139,6 @@ final public static function create( $container->bind(BootloadManagerInterface::class, $bootloadManager); if (!$container->has(BootloaderRegistryInterface::class)) { - /** @psalm-suppress InvalidArgument */ $container->bindSingleton(BootloaderRegistryInterface::class, [self::class, 'initBootloaderRegistry']); } diff --git a/src/Console/src/Configurator/Signature/Parser.php b/src/Console/src/Configurator/Signature/Parser.php index c72bc1357..ad11a70be 100644 --- a/src/Console/src/Configurator/Signature/Parser.php +++ b/src/Console/src/Configurator/Signature/Parser.php @@ -173,7 +173,7 @@ private function extractDescription(string $token): array { $token = \trim($token); - $parts = \array_map('trim', \explode(':', $token, 2)); + $parts = \array_map(trim(...), \explode(':', $token, 2)); return \count($parts) === 2 ? $parts : [$token, '']; } diff --git a/src/Core/src/Internal/Actor.php b/src/Core/src/Internal/Actor.php index d09d15025..169a3c653 100644 --- a/src/Core/src/Internal/Actor.php +++ b/src/Core/src/Internal/Actor.php @@ -159,7 +159,6 @@ public function resolveBinding( Config\Injectable::class => $this->resolveInjector( $binding, new Ctx(alias: $alias, class: $alias, context: $context), - $arguments, $tracer, ), Config\Scalar::class => $binding->value, @@ -194,11 +193,7 @@ public function autowire(Ctx $ctx, array $arguments, ?Actor $fallbackActor, Trac return $this->createInstance($ctx, $arguments, $fallbackActor, $tracer); } - /** - * @psalm-suppress UnusedParam - * todo wat should we do with $arguments? - */ - private function resolveInjector(Config\Injectable $binding, Ctx $ctx, array $arguments, Tracer $tracer) + private function resolveInjector(Config\Injectable $binding, Ctx $ctx, Tracer $tracer) { $context = $ctx->context; try { @@ -511,7 +506,7 @@ private function createInstance( // We have to construct class using external injector when we know the exact context if ($arguments === [] && $actor->binder->hasInjector($class)) { - return $actor->resolveInjector($actor->state->bindings[$ctx->class], $ctx, $arguments, $tracer); + return $actor->resolveInjector($actor->state->bindings[$ctx->class], $ctx, $tracer); } if (!$reflection->isInstantiable()) { diff --git a/src/Core/tests/InvokerTest.php b/src/Core/tests/InvokerTest.php index fca62210a..5f1717104 100644 --- a/src/Core/tests/InvokerTest.php +++ b/src/Core/tests/InvokerTest.php @@ -85,6 +85,9 @@ public function testCallValidCallableString(): void */ public function testCallStaticMethodWithoutInstantiation(): void { + // Keep the [class, method] array callable: this test verifies the Invoker resolves + // it without instantiating the class. Do not convert it to a first-class callable + // (PrivateConstructor::publicMethod(...)) — that bypasses the resolution path under test. $result = $this->container->invoke([PrivateConstructor::class, 'publicMethod'], [42]); self::assertSame(42, $result); diff --git a/src/Core/tests/Scope/ProxyTest.php b/src/Core/tests/Scope/ProxyTest.php index c65f129ff..e3712bf75 100644 --- a/src/Core/tests/Scope/ProxyTest.php +++ b/src/Core/tests/Scope/ProxyTest.php @@ -283,7 +283,7 @@ public function testImplementationWithWiderTypes(): void $root->runScope( new Scope('http'), - static function () use ($root, $proxy): void { + static function () use ($proxy): void { self::assertSame('Foo', $proxy->getName()); $proxy->setName(new class implements \Stringable { public function __toString(): string diff --git a/src/Core/tests/ScopesTest.php b/src/Core/tests/ScopesTest.php index 84f0cf33f..9733cbbcd 100644 --- a/src/Core/tests/ScopesTest.php +++ b/src/Core/tests/ScopesTest.php @@ -87,7 +87,7 @@ public function testContainerScopeException(): void self::assertTrue($c->runScope([ 'bucket' => new Bucket('b'), 'other' => new SampleClass(), - ], static function () use ($c): void { + ], static function (): void { throw new RuntimeException('exception'); })); } catch (\Throwable) { diff --git a/src/Distribution/tests/ManagerTestCase.php b/src/Distribution/tests/ManagerTest.php similarity index 95% rename from src/Distribution/tests/ManagerTestCase.php rename to src/Distribution/tests/ManagerTest.php index d979920bb..981283cc6 100644 --- a/src/Distribution/tests/ManagerTestCase.php +++ b/src/Distribution/tests/ManagerTest.php @@ -4,11 +4,12 @@ namespace Spiral\Tests\Distribution; +use PHPUnit\Framework\Attributes\Group; use Spiral\Distribution\Manager; use Spiral\Distribution\Resolver\StaticResolver; -#[\PHPUnit\Framework\Attributes\Group('unit')] -class ManagerTestCase extends TestCase +#[Group('unit')] +class ManagerTest extends TestCase { private StaticResolver $resolver; private Manager $manager; diff --git a/src/Files/src/Files.php b/src/Files/src/Files.php index 414e81a8b..3860d7879 100644 --- a/src/Files/src/Files.php +++ b/src/Files/src/Files.php @@ -280,13 +280,13 @@ public function getFiles(string $location, ?string $pattern = null): array { $result = []; foreach ($this->filesIterator($location, $pattern) as $filename) { - if ($this->isDirectory($filename->getPathname())) { - $result = \array_merge($result, $this->getFiles(((string) $filename) . DIRECTORY_SEPARATOR)); + if ($this->isDirectory($filename)) { + $result = \array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR)); continue; } - $result[] = $this->normalizePath((string) $filename); + $result[] = $this->normalizePath($filename); } return $result; @@ -368,11 +368,22 @@ public function __destruct() } } - private function filesIterator(string $location, ?string $pattern = null): \GlobIterator + /** + * CURRENT_AS_PATHNAME makes the iterator yield each match as its non-empty pathname + * string; psalm's GlobIterator stub still types the value as SplFileInfo|string. + * + * @param non-empty-string $location Location for search. + * @param non-empty-string|null $pattern Extension pattern. + * + * @return iterable + * + * @psalm-suppress all + */ + private function filesIterator(string $location, ?string $pattern = null): iterable { $pattern ??= '*'; $regexp = \rtrim($location, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . \ltrim($pattern, DIRECTORY_SEPARATOR); - return new \GlobIterator($regexp); + return new \GlobIterator($regexp, \FilesystemIterator::CURRENT_AS_PATHNAME); } } diff --git a/src/Files/src/FilesInterface.php b/src/Files/src/FilesInterface.php index 0dc6b0ea4..24046846c 100644 --- a/src/Files/src/FilesInterface.php +++ b/src/Files/src/FilesInterface.php @@ -190,7 +190,6 @@ public function setPermissions(string $filename, int $mode): bool; * @param non-empty-string|null $pattern Extension pattern. * * @return list - * / */ public function getFiles(string $location, ?string $pattern = null): array; diff --git a/src/Pagination/src/Paginator.php b/src/Pagination/src/Paginator.php index a46fcda27..ac2519a33 100644 --- a/src/Pagination/src/Paginator.php +++ b/src/Pagination/src/Paginator.php @@ -195,7 +195,6 @@ public function previousPage(): ?int * Non-Immutable version of withCount. * * @param int<0, max> $count - * @return static */ private function setCount(int $count): self { diff --git a/src/Queue/tests/ContainerRegistryT.php b/src/Queue/tests/ContainerRegistryTest.php similarity index 97% rename from src/Queue/tests/ContainerRegistryT.php rename to src/Queue/tests/ContainerRegistryTest.php index 33fde54da..73a95b164 100644 --- a/src/Queue/tests/ContainerRegistryT.php +++ b/src/Queue/tests/ContainerRegistryTest.php @@ -11,7 +11,7 @@ use Spiral\Queue\Exception\JobException; use Spiral\Queue\HandlerInterface; -final class ContainerRegistryT extends TestCase +final class ContainerRegistryTest extends TestCase { private ContainerInterface|m\MockInterface $container; private ContainerRegistry $registry; diff --git a/src/Router/tests/PatternsTests.php b/src/Router/tests/PatternsTest.php similarity index 99% rename from src/Router/tests/PatternsTests.php rename to src/Router/tests/PatternsTest.php index 5e829bda3..1c7d2d671 100644 --- a/src/Router/tests/PatternsTests.php +++ b/src/Router/tests/PatternsTest.php @@ -15,7 +15,7 @@ use Spiral\Tests\Router\Stub\InArrayPattern; use Mockery as m; -class PatternsTests extends TestCase +class PatternsTest extends TestCase { public function testDigitWithZeroValue(): void { diff --git a/src/Security/tests/GuardTest.php b/src/Security/tests/GuardTest.php index 4f445b6b6..db8c00ccc 100644 --- a/src/Security/tests/GuardTest.php +++ b/src/Security/tests/GuardTest.php @@ -18,13 +18,13 @@ class GuardTest extends TestCase public const CONTEXT = []; private MockObject&PermissionsInterface $permission; - private MockObject&ActorInterface $actor; + private \PHPUnit\Framework\MockObject\Stub&ActorInterface $actor; private array $roles = ['user', 'admin']; public function testAllows(): void { $this->permission->method('hasRole') - ->willReturnCallback(static function (...$args) { + ->willReturnCallback(static function (...$args): bool { static $series = [ [['user'], false], [['admin'], true], @@ -85,6 +85,6 @@ public function testWithRoles(): void protected function setUp(): void { $this->permission = $this->createMock(PermissionsInterface::class); - $this->actor = $this->createMock(ActorInterface::class); + $this->actor = $this->createStub(ActorInterface::class); } } diff --git a/src/Security/tests/RuleManagerTest.php b/src/Security/tests/RuleManagerTest.php index 8e627dd60..5104a8aba 100644 --- a/src/Security/tests/RuleManagerTest.php +++ b/src/Security/tests/RuleManagerTest.php @@ -18,7 +18,10 @@ */ class RuleManagerTest extends TestCase { - public const RULE_NAME = 'test'; + // Not a valid/loadable class name on purpose: RuleManager::has() calls + // class_exists() (case-insensitive, with autoload), so a plain word like + // "test" could collide with a global class loaded elsewhere in the suite. + public const RULE_NAME = 'test-rule'; /** @var ContainerInterface */ private $container; diff --git a/src/Security/tests/RuleTest.php b/src/Security/tests/RuleTest.php index f73c45740..6e7d16e02 100644 --- a/src/Security/tests/RuleTest.php +++ b/src/Security/tests/RuleTest.php @@ -22,7 +22,7 @@ class RuleTest extends TestCase public const OPERATION = 'test'; public const CONTEXT = []; - private MockObject&ActorInterface $actor; + private \PHPUnit\Framework\MockObject\Stub&ActorInterface $actor; private MockObject&ResolverInterface $resolver; private MockObject&Rule $rule; @@ -68,7 +68,7 @@ public function testAllowsException(): void protected function setUp(): void { - $this->actor = $this->createMock(ActorInterface::class); + $this->actor = $this->createStub(ActorInterface::class); $this->resolver = $this->createMock(ResolverInterface::class); $this->rule = $this->getMockBuilder(Rule::class) ->setConstructorArgs([$this->resolver]) diff --git a/src/Security/tests/Rules/CompositeRuleTest.php b/src/Security/tests/Rules/CompositeRuleTest.php index 9f07f763f..9ca84bb64 100644 --- a/src/Security/tests/Rules/CompositeRuleTest.php +++ b/src/Security/tests/Rules/CompositeRuleTest.php @@ -19,7 +19,7 @@ class CompositeRuleTest extends TestCase public const OPERATION = 'test'; public const CONTEXT = []; - private MockObject&ActorInterface $actor; + private \PHPUnit\Framework\MockObject\Stub&ActorInterface $actor; public static function allowsProvider(): \Traversable { @@ -45,7 +45,7 @@ public function testAllow(bool $expected, string $compositeRuleClass, array $rul protected function setUp(): void { - $this->actor = $this->createMock(ActorInterface::class); + $this->actor = $this->createStub(ActorInterface::class); } private static function allowRule(): RuleInterface diff --git a/src/Serializer/src/Bootloader/SerializerBootloader.php b/src/Serializer/src/Bootloader/SerializerBootloader.php index 6093ff353..fca1474ab 100644 --- a/src/Serializer/src/Bootloader/SerializerBootloader.php +++ b/src/Serializer/src/Bootloader/SerializerBootloader.php @@ -48,7 +48,7 @@ private function initSerializerManager( private function initSerializerRegistry(SerializerConfig $config): SerializerRegistryInterface { - return new SerializerRegistry(\array_map([$this, 'wire'], $config->getSerializers())); + return new SerializerRegistry(\array_map($this->wire(...), $config->getSerializers())); } private function initConfig(EnvironmentInterface $env): void diff --git a/src/Stempler/src/Builder.php b/src/Stempler/src/Builder.php index 62feb9fc7..f00de95dd 100644 --- a/src/Stempler/src/Builder.php +++ b/src/Stempler/src/Builder.php @@ -113,8 +113,6 @@ public function load(string $path): Template return $this->process($tpl); } catch (ContextExceptionInterface $e) { throw $this->mapException($e); - } catch (\Throwable $e) { - throw $e; } } diff --git a/src/Stempler/src/Exception/SyntaxException.php b/src/Stempler/src/Exception/SyntaxException.php index bcf28ce66..a907cb20f 100644 --- a/src/Stempler/src/Exception/SyntaxException.php +++ b/src/Stempler/src/Exception/SyntaxException.php @@ -17,7 +17,7 @@ public function __construct( private readonly Token $token, ) { $message = \sprintf('%s at offset %s', $message, $token->offset); - parent::__construct($message, 0, null); + parent::__construct($message); } public function getToken(): Token diff --git a/src/Stempler/src/Lexer/Buffer.php b/src/Stempler/src/Lexer/Buffer.php index 3e68a4618..6d325c6ba 100644 --- a/src/Stempler/src/Lexer/Buffer.php +++ b/src/Stempler/src/Lexer/Buffer.php @@ -54,7 +54,7 @@ public function next(): Byte|Token|null $this->buffer[] = $n; } - if ($n !== null && $n->offset !== null) { + if ($n->offset !== null) { $this->offset = $n->offset; } diff --git a/src/Stempler/src/Parser/Syntax/DynamicSyntax.php b/src/Stempler/src/Parser/Syntax/DynamicSyntax.php index 5ecb17e47..6c90a60e5 100644 --- a/src/Stempler/src/Parser/Syntax/DynamicSyntax.php +++ b/src/Stempler/src/Parser/Syntax/DynamicSyntax.php @@ -108,6 +108,6 @@ private function fetchValues(string $body): array } } - return \array_map('trim', $values); + return \array_map(trim(...), $values); } } diff --git a/src/Stempler/tests/Transform/AttributesTest.php b/src/Stempler/tests/Transform/AttributesTest.php index a4b05cb4c..270e6ecdb 100644 --- a/src/Stempler/tests/Transform/AttributesTest.php +++ b/src/Stempler/tests/Transform/AttributesTest.php @@ -28,7 +28,6 @@ public function testAggregatedAttribute(): void self::assertInstanceOf(Aggregate::class, $doc->nodes[0]->attrs[1]); - /** @var Aggregate $aggr */ $aggr = $doc->nodes[0]->attrs[1]; self::assertSame('style', $aggr->accepts('style')); @@ -48,7 +47,6 @@ public function testAggregatedAttributePattern(): void self::assertInstanceOf(Aggregate::class, $doc->nodes[0]->attrs[1]); - /** @var Aggregate $aggr */ $aggr = $doc->nodes[0]->attrs[1]; self::assertNull($aggr->accepts('style')); @@ -69,7 +67,6 @@ public function testAggregateInclude(): void self::assertInstanceOf(Aggregate::class, $doc->nodes[0]->attrs[1]); - /** @var Aggregate $aggr */ $aggr = $doc->nodes[0]->attrs[1]; self::assertSame('style', $aggr->accepts('style')); @@ -90,7 +87,6 @@ public function testAggregateExclude(): void self::assertInstanceOf(Aggregate::class, $doc->nodes[0]->attrs[1]); - /** @var Aggregate $aggr */ $aggr = $doc->nodes[0]->attrs[1]; self::assertNull($aggr->accepts('style')); diff --git a/src/Storage/tests/Config/StorageConfigTest.php b/src/Storage/tests/Config/StorageConfigTest.php index f1ce29b73..ebd2b7d13 100644 --- a/src/Storage/tests/Config/StorageConfigTest.php +++ b/src/Storage/tests/Config/StorageConfigTest.php @@ -53,7 +53,7 @@ public function testS3AsyncAdapter(): void { $config = new StorageConfig($this->getConfig()); - self::assertEquals(new AsyncAwsS3Adapter( + $this->assertAsyncAdapterEquals(new AsyncAwsS3Adapter( new S3AsyncClient([ 'region' => 'test-region', 'endpoint' => 'test-endpoint', @@ -67,6 +67,29 @@ public function testS3AsyncAdapter(): void ), $config->getAdapters()['uploads-async']); } + /** + * S3AsyncClient eagerly builds a Symfony HTTP client whose internal curl state + * (handle id) is non-deterministic across platforms, so a deep object comparison + * is flaky on Windows. Drop the HTTP client / credential provider first so the + * assertion focuses on the configured bucket/prefix/region/credentials. + */ + private function assertAsyncAdapterEquals(AsyncAwsS3Adapter $expected, mixed $actual): void + { + self::assertInstanceOf(AsyncAwsS3Adapter::class, $actual); + self::assertEquals($this->withoutHttpClient($expected), $this->withoutHttpClient($actual)); + } + + private function withoutHttpClient(AsyncAwsS3Adapter $adapter): AsyncAwsS3Adapter + { + $client = (new \ReflectionProperty(AsyncAwsS3Adapter::class, 'client'))->getValue($adapter); + + foreach (['httpClient', 'credentialProvider'] as $property) { + (new \ReflectionProperty(\AsyncAws\Core\AbstractApi::class, $property))->setValue($client, null); + } + + return $adapter; + } + public function testS3AdapterWithOverriddenBucket(): void { $config = new StorageConfig($this->getConfig(['buckets' => [ @@ -98,7 +121,7 @@ public function testS3AsyncAdapterWithOverriddenBucket(): void 'uploads-async' => ['server' => 's3-async', 'bucket' => 'overridden'], ]])); - self::assertEquals(new AsyncAwsS3Adapter( + $this->assertAsyncAdapterEquals(new AsyncAwsS3Adapter( new S3AsyncClient([ 'region' => 'test-region', 'endpoint' => 'test-endpoint', @@ -143,7 +166,7 @@ public function testS3AsyncAdapterWithOverriddenRegion(): void 'uploads-async' => ['server' => 's3-async', 'region' => 'overridden'], ]])); - self::assertEquals(new AsyncAwsS3Adapter( + $this->assertAsyncAdapterEquals(new AsyncAwsS3Adapter( new S3AsyncClient([ 'region' => 'overridden', 'endpoint' => 'test-endpoint', @@ -188,7 +211,7 @@ public function testS3AsyncAdapterWithOverriddenVisibility(): void 'uploads-async' => ['server' => 's3-async', 'visibility' => Visibility::VISIBILITY_PRIVATE], ]])); - self::assertEquals(new AsyncAwsS3Adapter( + $this->assertAsyncAdapterEquals(new AsyncAwsS3Adapter( new S3AsyncClient([ 'region' => 'test-region', 'endpoint' => 'test-endpoint', @@ -233,7 +256,7 @@ public function testS3AsyncAdapterWithOverriddenPrefix(): void 'uploads-async' => ['server' => 's3-async', 'prefix' => 'overridden'], ]])); - self::assertEquals(new AsyncAwsS3Adapter( + $this->assertAsyncAdapterEquals(new AsyncAwsS3Adapter( new S3AsyncClient([ 'region' => 'test-region', 'endpoint' => 'test-endpoint', diff --git a/src/Storage/tests/FileTestCase.php b/src/Storage/tests/FileTest.php similarity index 98% rename from src/Storage/tests/FileTestCase.php rename to src/Storage/tests/FileTest.php index 5a8526c0c..05cbeb93e 100644 --- a/src/Storage/tests/FileTestCase.php +++ b/src/Storage/tests/FileTest.php @@ -4,10 +4,11 @@ namespace Spiral\Tests\Storage; +use PHPUnit\Framework\Attributes\Group; use Spiral\Storage\Visibility; -#[\PHPUnit\Framework\Attributes\Group('unit')] -class FileTestCase extends TestCase +#[Group('unit')] +final class FileTest extends TestCase { public function testPathname(): void { diff --git a/src/Storage/tests/ManagerTestCase.php b/src/Storage/tests/ManagerTest.php similarity index 98% rename from src/Storage/tests/ManagerTestCase.php rename to src/Storage/tests/ManagerTest.php index d64361f91..c47d63d04 100644 --- a/src/Storage/tests/ManagerTestCase.php +++ b/src/Storage/tests/ManagerTest.php @@ -4,12 +4,13 @@ namespace Spiral\Tests\Storage; +use PHPUnit\Framework\Attributes\Group; use Spiral\Storage\Exception\InvalidArgumentException; use Spiral\Storage\Storage; use Spiral\Storage\Visibility; -#[\PHPUnit\Framework\Attributes\Group('unit')] -class ManagerTestCase extends TestCase +#[Group('unit')] +final class ManagerTest extends TestCase { private Storage $manager; diff --git a/src/Storage/tests/StorageTestCase.php b/src/Storage/tests/StorageTest.php similarity index 98% rename from src/Storage/tests/StorageTestCase.php rename to src/Storage/tests/StorageTest.php index 1f24fb65e..2cb06662f 100644 --- a/src/Storage/tests/StorageTestCase.php +++ b/src/Storage/tests/StorageTest.php @@ -4,10 +4,11 @@ namespace Spiral\Tests\Storage; +use PHPUnit\Framework\Attributes\Group; use Spiral\Storage\Visibility; -#[\PHPUnit\Framework\Attributes\Group('unit')] -class StorageTestCase extends TestCase +#[Group('unit')] +final class StorageTest extends TestCase { public function testCreate(): void { diff --git a/src/Views/tests/ManagerTest.php b/src/Views/tests/ManagerTest.php index 19720e50f..e91cf2ce1 100644 --- a/src/Views/tests/ManagerTest.php +++ b/src/Views/tests/ManagerTest.php @@ -60,7 +60,6 @@ public function testCompile(): void $r = new \ReflectionObject($manager); $p = $r->getProperty('cache'); - $p->setAccessible(true); /** @var ViewCache $cache */ $cache = $p->getValue($manager); @@ -78,7 +77,6 @@ public function testReset(): void $r = new \ReflectionObject($manager); $p = $r->getProperty('cache'); - $p->setAccessible(true); /** @var ViewCache $cache */ $cache = $p->getValue($manager); diff --git a/tests/Framework/Framework/ExtensionsCommand.php b/tests/Framework/Framework/ExtensionsCommand.php deleted file mode 100644 index b3947f61c..000000000 --- a/tests/Framework/Framework/ExtensionsCommand.php +++ /dev/null @@ -1,22 +0,0 @@ -runCommand('php:extensions'); - - foreach (\get_loaded_extensions() as $extension) { - self::assertStringContainsString($extension, $output); - } - } -}