Test html contentspan>
@@ -53,7 +53,7 @@ public function tearDown(): void
$this->viewCache->enableCaching(false);
}
- public function testServeCachedView()
+ public function testServeCachedView(): void
{
$this->viewCache->enableCaching(true);
@@ -68,7 +68,7 @@ public function testServeCachedView()
$this->assertEquals($this->content, $response->getContent());
}
- public function testSetAndGetViewCache()
+ public function testSetAndGetViewCache(): void
{
$this->viewCache->set($this->route, $this->content);
@@ -77,7 +77,7 @@ public function testSetAndGetViewCache()
$this->assertEquals($this->content, $viewCache);
}
- public function testViewCacheContentMinification()
+ public function testViewCacheContentMinification(): void
{
$this->viewCache->enableMinification(true);
@@ -90,7 +90,7 @@ public function testViewCacheContentMinification()
$this->assertEquals($minifiedContent, $content);
}
- public function testViewCacheMinificationMissingDependency()
+ public function testViewCacheMinificationMissingDependency(): void
{
$viewCache = new ViewCacheDouble();
$viewCache->enableMinification(true);
@@ -101,14 +101,14 @@ public function testViewCacheMinificationMissingDependency()
$viewCache->set($this->route, 'test
');
}
- public function testExistsViewCache()
+ public function testExistsViewCache(): void
{
$this->viewCache->set($this->route, $this->content);
$this->assertTrue($this->viewCache->exists($this->route));
}
- public function testDeleteViewCache()
+ public function testDeleteViewCache(): void
{
$this->viewCache->set($this->route, $this->content);
@@ -119,14 +119,14 @@ public function testDeleteViewCache()
$this->assertFalse($this->viewCache->exists($this->route));
}
- public function testGetNonExistentViewCache()
+ public function testGetNonExistentViewCache(): void
{
$viewCache = $this->viewCache->get('/non-existent-route');
$this->assertNull($viewCache);
}
- public function testViewCacheIsExpired()
+ public function testViewCacheIsExpired(): void
{
$this->viewCache->setTtl(1);
@@ -139,7 +139,7 @@ public function testViewCacheIsExpired()
$this->assertNull($viewCache);
}
- public function testEnableDisableViewCache()
+ public function testEnableDisableViewCache(): void
{
$this->assertFalse($this->viewCache->isEnabled());
diff --git a/tests/Unit/Router/Helpers/RouteHelpersTest.php b/tests/Unit/Router/Helpers/RouteHelpersTest.php
index 6c3f8e1fe..47ca61264 100644
--- a/tests/Unit/Router/Helpers/RouteHelpersTest.php
+++ b/tests/Unit/Router/Helpers/RouteHelpersTest.php
@@ -25,7 +25,7 @@ public function tearDown(): void
parent::tearDown();
}
- public function testHelpersReturnDefaultsWhenNoRouteMatched()
+ public function testHelpersReturnDefaultsWhenNoRouteMatched(): void
{
$this->assertNull(current_middlewares());
$this->assertNull(current_module());
@@ -41,14 +41,13 @@ public function testHelpersReturnDefaultsWhenNoRouteMatched()
$this->assertNull(route_prefix());
}
- public function testHelpersReturnValuesForMatchedControllerRoute()
+ public function testHelpersReturnValuesForMatchedControllerRoute(): void
{
$route = new Route(
['GET'],
'[:alpha:2]?/post/[uuid=:any]',
'PostController',
- 'show',
- null
+ 'show'
);
$route
@@ -80,9 +79,9 @@ public function testHelpersReturnValuesForMatchedControllerRoute()
$this->assertSame('api', route_prefix());
}
- public function testRouteCallbackReturnsClosureForClosureRoute()
+ public function testRouteCallbackReturnsClosureForClosureRoute(): void
{
- $closure = function () {
+ $closure = function (): void {
};
$route = new Route(
@@ -102,14 +101,13 @@ public function testRouteCallbackReturnsClosureForClosureRoute()
$this->assertNull(current_action());
}
- public function testFindRouteByNameReturnsRouteFromCollection()
+ public function testFindRouteByNameReturnsRouteFromCollection(): void
{
$route = new Route(
['GET'],
'dashboard',
'DashboardController',
- 'index',
- null
+ 'index'
);
$route->name('Dashboard')->module('Admin');
@@ -125,14 +123,13 @@ public function testFindRouteByNameReturnsRouteFromCollection()
$this->assertSame('DashboardController', $found->getController());
}
- public function testRouteGroupExistsDetectsGroupInModule()
+ public function testRouteGroupExistsDetectsGroupInModule(): void
{
$route = new Route(
['GET'],
'profile',
'ProfileController',
- 'show',
- null
+ 'show'
);
$route->group('auth')->module('Web');
@@ -147,7 +144,7 @@ public function testRouteGroupExistsDetectsGroupInModule()
$this->assertFalse(route_group_exists('auth', 'api'));
}
- public function testRouteMethodAndUri()
+ public function testRouteMethodAndUri(): void
{
$request = new Request();
$request->create('POST', 'http://example.com/api/test');
@@ -157,7 +154,7 @@ public function testRouteMethodAndUri()
$this->assertSame('api/test', route_uri());
}
- public function testFindRouteByNameDependsOnCollectionRegistration()
+ public function testFindRouteByNameDependsOnCollectionRegistration(): void
{
$this->assertNull(
find_route_by_name('dashboard', 'admin'),
@@ -176,8 +173,7 @@ public function testFindRouteByNameDependsOnCollectionRegistration()
['GET'],
'dashboard',
'DashboardController',
- 'index',
- null
+ 'index'
);
$route->name('dashboard')->module('admin');
@@ -190,7 +186,7 @@ public function testFindRouteByNameDependsOnCollectionRegistration()
$this->assertSame('DashboardController', $found->getController());
}
- public function testRouteGroupExistsDependsOnCollectionRegistration()
+ public function testRouteGroupExistsDependsOnCollectionRegistration(): void
{
$this->assertFalse(
route_group_exists('auth', 'web'),
@@ -209,8 +205,7 @@ public function testRouteGroupExistsDependsOnCollectionRegistration()
['GET'],
'profile',
'ProfileController',
- 'show',
- null
+ 'show'
);
$route->group('auth')->module('web');
diff --git a/tests/Unit/Router/MatchedRouteTest.php b/tests/Unit/Router/MatchedRouteTest.php
index 5b687aa75..983e5b1b6 100644
--- a/tests/Unit/Router/MatchedRouteTest.php
+++ b/tests/Unit/Router/MatchedRouteTest.php
@@ -8,7 +8,7 @@
class MatchedRouteTest extends AppTestCase
{
- public function testMatchedRouteStoresRouteAndParams()
+ public function testMatchedRouteStoresRouteAndParams(): void
{
$route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act');
$params = ['id' => '42'];
@@ -19,7 +19,7 @@ public function testMatchedRouteStoresRouteAndParams()
$this->assertSame($params, $matched->getParams());
}
- public function testMatchedRouteSupportsEmptyParams()
+ public function testMatchedRouteSupportsEmptyParams(): void
{
$route = new Route(['GET'], 'users', 'Ctrl', 'act');
@@ -28,7 +28,7 @@ public function testMatchedRouteSupportsEmptyParams()
$this->assertSame([], $matched->getParams());
}
- public function testMatchedRouteParamsAreReturnedAsGiven()
+ public function testMatchedRouteParamsAreReturnedAsGiven(): void
{
$route = new Route(['GET'], 'x', 'Ctrl', 'act');
@@ -48,7 +48,7 @@ public function testMatchedRouteParamsAreReturnedAsGiven()
$this->assertSame('hello', $matched->getParams()['slug']);
}
- public function testMatchedRouteRouteInstanceIsExactSameObject()
+ public function testMatchedRouteRouteInstanceIsExactSameObject(): void
{
$route = new Route(['POST'], 'submit', 'Ctrl', 'act');
diff --git a/tests/Unit/Router/PatternCompilerTest.php b/tests/Unit/Router/PatternCompilerTest.php
index 775fedab2..30e0ce40d 100644
--- a/tests/Unit/Router/PatternCompilerTest.php
+++ b/tests/Unit/Router/PatternCompilerTest.php
@@ -18,7 +18,7 @@ public function setUp(): void
$this->compiler = new PatternCompiler();
}
- public function testPatternCompilerStaticRouteMatch()
+ public function testPatternCompilerStaticRouteMatch(): void
{
$this->route = new Route(['GET'], 'users', 'Ctrl', 'act');
@@ -31,7 +31,7 @@ public function testPatternCompilerStaticRouteMatch()
$this->assertFalse($this->compiler->match($this->route, '/users/1'));
}
- public function testPatternCompilerNumericParamMatch()
+ public function testPatternCompilerNumericParamMatch(): void
{
$this->route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act');
@@ -44,7 +44,7 @@ public function testPatternCompilerNumericParamMatch()
$this->assertSame([], $this->compiler->getParams());
}
- public function testPatternCompilerAlphaParamMatch()
+ public function testPatternCompilerAlphaParamMatch(): void
{
$this->route = new Route(['GET'], 'tag/[name=:alpha]', 'Ctrl', 'act');
@@ -55,7 +55,7 @@ public function testPatternCompilerAlphaParamMatch()
$this->assertFalse($this->compiler->match($this->route, '/tag/test1'));
}
- public function testPatternCompilerAnyParamMatch()
+ public function testPatternCompilerAnyParamMatch(): void
{
$this->route = new Route(['GET'], 'file/[path=:any]', 'Ctrl', 'act');
@@ -64,7 +64,7 @@ public function testPatternCompilerAnyParamMatch()
$this->assertSame(['path' => 'a-b_c'], $this->compiler->getParams());
}
- public function testPatternCompilerOptionalParamAtEnd()
+ public function testPatternCompilerOptionalParamAtEnd(): void
{
$this->route = new Route(['GET'], 'post/[id=:num]?', 'Ctrl', 'act');
@@ -77,7 +77,7 @@ public function testPatternCompilerOptionalParamAtEnd()
$this->assertSame(['id' => '7'], $this->compiler->getParams());
}
- public function testPatternCompilerLengthConstraint()
+ public function testPatternCompilerLengthConstraint(): void
{
$this->route = new Route(['GET'], 'code/[id=:num:4]', 'Ctrl', 'act');
@@ -88,7 +88,7 @@ public function testPatternCompilerLengthConstraint()
$this->assertFalse($this->compiler->match($this->route, '/code/123'));
}
- public function testPatternCompilerMultipleParams()
+ public function testPatternCompilerMultipleParams(): void
{
$this->route = new Route(
['GET'],
@@ -102,7 +102,7 @@ public function testPatternCompilerMultipleParams()
$this->assertSame(['id' => '5', 'slug' => 'hello'], $this->compiler->getParams());
}
- public function testPatternCompilerOptionalLeadingParam()
+ public function testPatternCompilerOptionalLeadingParam(): void
{
$this->route = new Route(
['GET'],
@@ -116,7 +116,7 @@ public function testPatternCompilerOptionalLeadingParam()
$this->assertTrue($this->compiler->match($this->route, '/en/about'));
}
- public function testPatternCompilerInvalidParamNameThrowsException()
+ public function testPatternCompilerInvalidParamNameThrowsException(): void
{
$this->route = new Route(['GET'], '[id1=:num]', 'Ctrl', 'act');
@@ -125,7 +125,7 @@ public function testPatternCompilerInvalidParamNameThrowsException()
$this->compiler->compile($this->route);
}
- public function testPatternCompilerDuplicateParamNameThrowsException()
+ public function testPatternCompilerDuplicateParamNameThrowsException(): void
{
$this->route = new Route(
['GET'],
@@ -139,7 +139,7 @@ public function testPatternCompilerDuplicateParamNameThrowsException()
$this->compiler->compile($this->route);
}
- public function tesPatternCompilertUrlDecodedInput()
+ public function tesPatternCompilertUrlDecodedInput(): void
{
$this->route = new Route(['GET'], 'user/[id=:num]', 'Ctrl', 'act');
@@ -153,14 +153,14 @@ public function tesPatternCompilertUrlDecodedInput()
$this->assertSame(['id' => '42'], $this->compiler->getParams());
}
- public function testPatternCompilerRootPatternMatches()
+ public function testPatternCompilerRootPatternMatches(): void
{
$this->route = new Route(['GET'], '/', 'Ctrl', 'act');
$this->assertTrue($this->compiler->match($this->route, '/'));
}
- public function testPatternCompilerParamsResetAfterFailedMatch()
+ public function testPatternCompilerParamsResetAfterFailedMatch(): void
{
$this->route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act');
diff --git a/tests/Unit/Router/RouteBuilderTest.php b/tests/Unit/Router/RouteBuilderTest.php
index f9ae15964..e272e05e0 100644
--- a/tests/Unit/Router/RouteBuilderTest.php
+++ b/tests/Unit/Router/RouteBuilderTest.php
@@ -10,12 +10,12 @@
class RouteBuilderTest extends AppTestCase
{
- public function testRouteBuilderBuildReturnsRouteCollection()
+ public function testRouteBuilderBuildReturnsRouteCollection(): void
{
$builder = new RouteBuilder();
$routes = $builder->build([
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('users', 'UserController', 'index');
},
], []);
@@ -25,16 +25,16 @@ public function testRouteBuilderBuildReturnsRouteCollection()
$this->assertSame(1, $routes->count());
}
- public function testRouteBuilderBuildCollectsRoutesFromMultipleModules()
+ public function testRouteBuilderBuildCollectsRoutesFromMultipleModules(): void
{
$builder = new RouteBuilder();
$closures = [
- 'Api' => function (RouteBuilder $route) {
+ 'Api' => function (RouteBuilder $route): void {
$route->get('users', 'UsersController', 'index');
$route->post('login', 'AuthController', 'login');
},
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('', 'HomeController', 'index');
},
];
@@ -69,13 +69,13 @@ public function testRouteBuilderBuildCollectsRoutesFromMultipleModules()
$this->assertTrue($all[2]->allowsMethod('GET'));
}
- public function testRouteBuilderMissingModuleConfigFallsBackSafely()
+ public function testRouteBuilderMissingModuleConfigFallsBackSafely(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Test' => function (RouteBuilder $route) {
+ 'Test' => function (RouteBuilder $route): void {
$route->get('ping', 'PingController', 'index');
},
],
@@ -91,13 +91,13 @@ public function testRouteBuilderMissingModuleConfigFallsBackSafely()
$this->assertSame('/ping', $route->getPattern());
}
- public function testRouteBuilderPrefixIsAppliedToRoutes()
+ public function testRouteBuilderPrefixIsAppliedToRoutes(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Api' => function (RouteBuilder $route) {
+ 'Api' => function (RouteBuilder $route): void {
$route->get('status', 'StatusController', 'index');
},
],
@@ -113,14 +113,14 @@ public function testRouteBuilderPrefixIsAppliedToRoutes()
$this->assertSame('Api', $route->getModule());
}
- public function testRouteBuilderGroupAssignsGroupNameToRoutes()
+ public function testRouteBuilderGroupAssignsGroupNameToRoutes(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Web' => function (RouteBuilder $route) {
- $route->group('auth', function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
+ $route->group('auth', function (RouteBuilder $route): void {
$route->get('dashboard', 'DashboardController', 'index');
});
},
@@ -133,7 +133,7 @@ public function testRouteBuilderGroupAssignsGroupNameToRoutes()
$this->assertSame('auth', $route->getGroup());
}
- public function testRouteBuilderNestedGroupsAreNotAllowed()
+ public function testRouteBuilderNestedGroupsAreNotAllowed(): void
{
$this->expectException(RouteException::class);
@@ -141,9 +141,9 @@ public function testRouteBuilderNestedGroupsAreNotAllowed()
$builder->build(
[
- 'Web' => function (RouteBuilder $route) {
- $route->group('one', function (RouteBuilder $route) {
- $route->group('two', function () {
+ 'Web' => function (RouteBuilder $route): void {
+ $route->group('one', function (RouteBuilder $route): void {
+ $route->group('two', function (): void {
});
});
},
@@ -152,14 +152,14 @@ public function testRouteBuilderNestedGroupsAreNotAllowed()
);
}
- public function testRouteBuilderGroupMiddlewaresAreAppliedToRoutes()
+ public function testRouteBuilderGroupMiddlewaresAreAppliedToRoutes(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Web' => function (RouteBuilder $route) {
- $route->group('auth', function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
+ $route->group('auth', function (RouteBuilder $route): void {
$route->get('profile', 'ProfileController', 'show');
})->middlewares(['Auth']);
},
@@ -172,14 +172,14 @@ public function testRouteBuilderGroupMiddlewaresAreAppliedToRoutes()
$this->assertSame(['Auth'], $route->getMiddlewares());
}
- public function testRouteBuilderRouteMiddlewaresPrependToGroupMiddlewares()
+ public function testRouteBuilderRouteMiddlewaresPrependToGroupMiddlewares(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Web' => function (RouteBuilder $route) {
- $route->group('auth', function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
+ $route->group('auth', function (RouteBuilder $route): void {
$route
->get('profile', 'ProfileController', 'show')
->middlewares(['Editor']);
@@ -197,7 +197,7 @@ public function testRouteBuilderRouteMiddlewaresPrependToGroupMiddlewares()
);
}
- public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup()
+ public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup(): void
{
$this->expectException(RouteException::class);
@@ -205,7 +205,7 @@ public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup()
$builder->build(
[
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->middlewares(['Invalid']);
},
],
@@ -213,14 +213,14 @@ public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup()
);
}
- public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneRoutes()
+ public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneRoutes(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Web' => function (RouteBuilder $route) {
- $route->group('auth', function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
+ $route->group('auth', function (RouteBuilder $route): void {
$route->get('profile', 'ProfileController', 'show')->middlewares(['ProfileMw']);
$route->get('settings', 'SettingsController', 'show')->middlewares(['SettingsMw']);
})->middlewares(['AuthMw']);
@@ -228,8 +228,8 @@ public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneR
$route->get('home', 'HomeController', 'index')->middlewares(['HomeMw']);
},
- 'Api' => function (RouteBuilder $route) {
- $route->group('api-auth', function (RouteBuilder $route) {
+ 'Api' => function (RouteBuilder $route): void {
+ $route->group('api-auth', function (RouteBuilder $route): void {
$route->get('users', 'UsersController', 'index')->middlewares(['UsersMw1', 'UsersMw2']);
$route->post('login', 'AuthController', 'login')->middlewares(['LoginMw']);
})->middlewares(['ApiAuthMw']);
@@ -255,13 +255,13 @@ public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneR
$this->assertSame(['StatusMw'], $all[5]->getMiddlewares());
}
- public function testRouteBuilderRouteNameIsAssigned()
+ public function testRouteBuilderRouteNameIsAssigned(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('home', 'HomeController', 'index')
->name('home');
},
@@ -272,7 +272,7 @@ public function testRouteBuilderRouteNameIsAssigned()
$this->assertSame('home', $routes->all()[0]->getName());
}
- public function testRouteBuilderRouteNamesMustBeUnique()
+ public function testRouteBuilderRouteNamesMustBeUnique(): void
{
$this->expectException(RouteException::class);
@@ -280,7 +280,7 @@ public function testRouteBuilderRouteNamesMustBeUnique()
$builder->build(
[
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('a', 'AController', 'a')->name('dup');
$route->get('b', 'BController', 'b')->name('dup');
},
@@ -289,16 +289,16 @@ public function testRouteBuilderRouteNamesMustBeUnique()
);
}
- public function testRouteBuilderRouteNamesCanRepeatAcrossModules()
+ public function testRouteBuilderRouteNamesCanRepeatAcrossModules(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Api' => function (RouteBuilder $route) {
+ 'Api' => function (RouteBuilder $route): void {
$route->get('posts', 'ApiPostController', 'index')->name('posts');
},
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('posts', 'WebPostController', 'index')->name('posts');
},
],
@@ -317,7 +317,7 @@ public function testRouteBuilderRouteNamesCanRepeatAcrossModules()
$this->assertSame('Web', $all[1]->getModule());
}
- public function testRouteBuilderNameMustBeCalledAfterRouteDefinition()
+ public function testRouteBuilderNameMustBeCalledAfterRouteDefinition(): void
{
$this->expectException(RouteException::class);
@@ -325,7 +325,7 @@ public function testRouteBuilderNameMustBeCalledAfterRouteDefinition()
$builder->build(
[
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->name('invalid');
},
],
@@ -333,13 +333,13 @@ public function testRouteBuilderNameMustBeCalledAfterRouteDefinition()
);
}
- public function testRouteBuilderCacheableAppliesToSingleRoute()
+ public function testRouteBuilderCacheableAppliesToSingleRoute(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('page', 'PageController', 'show')
->cacheable(true, 60);
},
@@ -353,14 +353,14 @@ public function testRouteBuilderCacheableAppliesToSingleRoute()
$this->assertSame(60, $cache['ttl']);
}
- public function testRouteBuilderCacheableAppliesToGroupRoutes()
+ public function testRouteBuilderCacheableAppliesToGroupRoutes(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Web' => function (RouteBuilder $route) {
- $route->group('cached', function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
+ $route->group('cached', function (RouteBuilder $route): void {
$route->get('a', 'AController', 'a');
$route->get('b', 'BController', 'b');
})->cacheable(true, 120);
@@ -376,7 +376,7 @@ public function testRouteBuilderCacheableAppliesToGroupRoutes()
}
}
- public function testRouteBuilderAddRouteRequiresControllerAndAction()
+ public function testRouteBuilderAddRouteRequiresControllerAndAction(): void
{
$this->expectException(RouteException::class);
@@ -384,7 +384,7 @@ public function testRouteBuilderAddRouteRequiresControllerAndAction()
$builder->build(
[
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('broken', 'OnlyController');
},
],
@@ -392,13 +392,13 @@ public function testRouteBuilderAddRouteRequiresControllerAndAction()
);
}
- public function testRouteBuilderResolvesShortControllerNameToFqcn()
+ public function testRouteBuilderResolvesShortControllerNameToFqcn(): void
{
$builder = new RouteBuilder();
$routes = $builder->build(
[
- 'Test' => function (RouteBuilder $route) {
+ 'Test' => function (RouteBuilder $route): void {
$route->get('tests', 'TestController', 'tests');
},
],
@@ -407,22 +407,22 @@ public function testRouteBuilderResolvesShortControllerNameToFqcn()
$route = $routes->all()[0];
- $expected = 'Quantum\\Tests\\_root\\modules\\Test\\Controllers\\TestController';
+ $expected = \Quantum\Tests\_root\modules\Test\Controllers\TestController::class;
$this->assertTrue(class_exists($expected), 'Expected test controller class to exist');
$this->assertSame($expected, $route->getController());
}
- public function testRouteBuilderDoesNotModifyExplicitFqcnController()
+ public function testRouteBuilderDoesNotModifyExplicitFqcnController(): void
{
$builder = new RouteBuilder();
- $fqcn = 'Quantum\\Tests\\_root\\modules\\Test\\Controllers\\TestController';
+ $fqcn = \Quantum\Tests\_root\modules\Test\Controllers\TestController::class;
$routes = $builder->build(
[
- 'Test' => function (RouteBuilder $route) use ($fqcn) {
+ 'Test' => function (RouteBuilder $route) use ($fqcn): void {
$route->get('tests', $fqcn, 'tests');
},
],
@@ -436,19 +436,19 @@ public function testRouteBuilderDoesNotModifyExplicitFqcnController()
$this->assertSame($fqcn, $route->getController());
}
- public function testRouteBuilderAddRouteRejectsEmptyMethods()
+ public function testRouteBuilderAddRouteRejectsEmptyMethods(): void
{
$this->expectException(RouteException::class);
$builder = new RouteBuilder();
$builder->build([
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->add('test', '', 'TestController', 'index');
},
], []);
}
- public function testRouteBuilderShortControllerWithoutModuleThrows()
+ public function testRouteBuilderShortControllerWithoutModuleThrows(): void
{
$this->expectException(RouteException::class);
@@ -467,10 +467,10 @@ public function testRouteBuilderShortControllerWithoutModuleThrows()
);
}
- public function testRouteBuilderMiddlewaresAppliedDirectlyToRoute()
+ public function testRouteBuilderMiddlewaresAppliedDirectlyToRoute(): void
{
$routes = (new RouteBuilder())->build([
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->get('a', 'AController', 'a');
$route->middlewares(['Direct']);
},
@@ -479,22 +479,22 @@ public function testRouteBuilderMiddlewaresAppliedDirectlyToRoute()
$this->assertSame(['Direct'], $routes->all()[0]->getMiddlewares());
}
- public function testRouteBuilderCacheableMustFollowRouteOrGroup()
+ public function testRouteBuilderCacheableMustFollowRouteOrGroup(): void
{
$this->expectException(RouteException::class);
(new RouteBuilder())->build([
- 'Web' => function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
$route->cacheable(true);
},
], []);
}
- public function testRouteBuilderResolvePathTrimsSlashesCorrectly()
+ public function testRouteBuilderResolvePathTrimsSlashesCorrectly(): void
{
$routes = (new RouteBuilder())->build(
[
- 'Api' => function (RouteBuilder $route) {
+ 'Api' => function (RouteBuilder $route): void {
$route->get('/users/', 'UserController', 'index');
},
],
@@ -506,13 +506,11 @@ public function testRouteBuilderResolvePathTrimsSlashesCorrectly()
$this->assertSame('/v1/users', $routes->all()[0]->getPattern());
}
- public function testRouteBuilderClosureBasedRouteIsSupported()
+ public function testRouteBuilderClosureBasedRouteIsSupported(): void
{
$routes = (new RouteBuilder())->build([
- 'Web' => function (RouteBuilder $route) {
- $route->get('ping', function () {
- return 'pong';
- });
+ 'Web' => function (RouteBuilder $route): void {
+ $route->get('ping', fn (): string => 'pong');
},
], []);
@@ -520,11 +518,11 @@ public function testRouteBuilderClosureBasedRouteIsSupported()
$this->assertNull($routes->all()[0]->getController());
}
- public function testRouteBuilderGroupedRoutesAreRegisteredIndividually()
+ public function testRouteBuilderGroupedRoutesAreRegisteredIndividually(): void
{
$routes = (new RouteBuilder())->build([
- 'Web' => function (RouteBuilder $route) {
- $route->group('g', function (RouteBuilder $route) {
+ 'Web' => function (RouteBuilder $route): void {
+ $route->group('g', function (RouteBuilder $route): void {
$route->get('a', 'AController', 'a');
$route->get('b', 'BController', 'b');
});
diff --git a/tests/Unit/Router/RouteCollectionTest.php b/tests/Unit/Router/RouteCollectionTest.php
index 8d40f8623..8860a5a0f 100644
--- a/tests/Unit/Router/RouteCollectionTest.php
+++ b/tests/Unit/Router/RouteCollectionTest.php
@@ -8,7 +8,7 @@
class RouteCollectionTest extends AppTestCase
{
- public function testRouteCollectionStartsEmpty()
+ public function testRouteCollectionStartsEmpty(): void
{
$collection = new RouteCollection();
@@ -17,7 +17,7 @@ public function testRouteCollectionStartsEmpty()
$this->assertSame(0, $collection->count());
}
- public function testRouteCollectionAddIncreasesCount()
+ public function testRouteCollectionAddIncreasesCount(): void
{
$collection = new RouteCollection();
@@ -28,7 +28,7 @@ public function testRouteCollectionAddIncreasesCount()
$this->assertSame(2, $collection->count());
}
- public function testRouteCollectionAllReturnsAddedRoutes()
+ public function testRouteCollectionAllReturnsAddedRoutes(): void
{
$collection = new RouteCollection();
@@ -44,7 +44,7 @@ public function testRouteCollectionAllReturnsAddedRoutes()
$this->assertSame([$r1, $r2], $all);
}
- public function testRouteCollectionInsertionOrderIsPreserved()
+ public function testRouteCollectionInsertionOrderIsPreserved(): void
{
$collection = new RouteCollection();
@@ -61,7 +61,7 @@ public function testRouteCollectionInsertionOrderIsPreserved()
$this->assertSame($r2, $all[1]);
}
- public function testRouteCollectionAllReturnsSameInstances()
+ public function testRouteCollectionAllReturnsSameInstances(): void
{
$collection = new RouteCollection();
diff --git a/tests/Unit/Router/RouteDispatcherTest.php b/tests/Unit/Router/RouteDispatcherTest.php
index 1352c1852..46a5a4a3f 100644
--- a/tests/Unit/Router/RouteDispatcherTest.php
+++ b/tests/Unit/Router/RouteDispatcherTest.php
@@ -21,12 +21,12 @@ public function tearDown(): void
parent::tearDown();
}
- public function testDispatchExecutesClosureRoute()
+ public function testDispatchExecutesClosureRoute(): void
{
$called = false;
$receivedParam = null;
- $closure = function (string $id) use (&$called, &$receivedParam) {
+ $closure = function (string $id) use (&$called, &$receivedParam): void {
$called = true;
$receivedParam = $id;
};
@@ -41,31 +41,31 @@ public function testDispatchExecutesClosureRoute()
$dispatcher = new RouteDispatcher();
$request = Mockery::mock(Request::class);
- $response = Mockery::mock(Response::class);
+ Mockery::mock(Response::class);
- $dispatcher->dispatch($matched, $request, $response);
+ $dispatcher->dispatch($matched, $request);
$this->assertTrue($called);
$this->assertSame('123', $receivedParam);
}
- public function testDispatchThrowsWhenClosureRouteHasNoClosure()
+ public function testDispatchThrowsWhenClosureRouteHasNoClosure(): void
{
$this->expectException(RouteException::class);
- $route = new Route(['GET'], '/broken', null, null, null);
+ $route = new Route(['GET'], '/broken', null, null);
$matched = new MatchedRoute($route, []);
$dispatcher = new RouteDispatcher();
$request = Mockery::mock(Request::class);
- $response = Mockery::mock(Response::class);
+ Mockery::mock(Response::class);
- $dispatcher->dispatch($matched, $request, $response);
+ $dispatcher->dispatch($matched, $request);
}
- public function testDispatchExecutesControllerActionWithParams()
+ public function testDispatchExecutesControllerActionWithParams(): void
{
$controllerClass = new class () {
public static ?string $received = null;
@@ -76,16 +76,16 @@ public function post(string $uuid): void
}
};
- $route = new Route(['GET'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post', null);
+ $route = new Route(['GET'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post');
$matched = new MatchedRoute($route, ['uuid' => 'abc-123']);
$dispatcher = new RouteDispatcher();
$request = Mockery::mock(Request::class);
- $response = Mockery::mock(Response::class);
+ Mockery::mock(Response::class);
- $dispatcher->dispatch($matched, $request, $response);
+ $dispatcher->dispatch($matched, $request);
$this->assertSame(
'abc-123',
@@ -94,7 +94,7 @@ public function post(string $uuid): void
);
}
- public function testDispatchCallsControllerHooksInCorrectOrder()
+ public function testDispatchCallsControllerHooksInCorrectOrder(): void
{
$controllerClass = new class () {
public static array $calls = [];
@@ -115,7 +115,7 @@ public function __after(string $uuid): void
}
};
- $route = new Route(['GET', 'POST'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post', null);
+ $route = new Route(['GET', 'POST'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post');
$matched = new MatchedRoute($route, ['uuid' => 'abc']);
@@ -124,9 +124,9 @@ public function __after(string $uuid): void
$request = Mockery::mock(Request::class);
$request->shouldReceive('getMethod')->andReturn('POST');
- $response = Mockery::mock(Response::class);
+ Mockery::mock(Response::class);
- $dispatcher->dispatch($matched, $request, $response);
+ $dispatcher->dispatch($matched, $request);
$this->assertSame(
[
@@ -139,7 +139,7 @@ public function __after(string $uuid): void
);
}
- public function testDispatchThrowsWhenControllerActionDoesNotExist()
+ public function testDispatchThrowsWhenControllerActionDoesNotExist(): void
{
$this->expectException(RouteException::class);
@@ -147,19 +147,19 @@ public function testDispatchThrowsWhenControllerActionDoesNotExist()
// Intentionally no action method
};
- $route = new Route(['GET'], '[:alpha:2]?/broken', get_class($controllerClass), 'missingAction', null);
+ $route = new Route(['GET'], '[:alpha:2]?/broken', get_class($controllerClass), 'missingAction');
$matched = new MatchedRoute($route, []);
$dispatcher = new RouteDispatcher();
$request = Mockery::mock(Request::class);
- $response = Mockery::mock(Response::class);
+ Mockery::mock(Response::class);
- $dispatcher->dispatch($matched, $request, $response);
+ $dispatcher->dispatch($matched, $request);
}
- public function testDispatchFailsWhenCsrfIsEnabledAndTokenIsMissing()
+ public function testDispatchFailsWhenCsrfIsEnabledAndTokenIsMissing(): void
{
$this->expectException(CsrfException::class);
@@ -172,7 +172,7 @@ public function submit(): void
}
};
- $route = new Route(['POST'], '[:alpha:2]?/submit', get_class($controllerClass), 'submit', null);
+ $route = new Route(['POST'], '[:alpha:2]?/submit', get_class($controllerClass), 'submit');
$matched = new MatchedRoute($route, []);
@@ -182,10 +182,10 @@ public function submit(): void
->with(Csrf::TOKEN_KEY)
->andReturn(false);
- $response = Mockery::mock(Response::class);
+ Mockery::mock(Response::class);
$dispatcher = new RouteDispatcher();
- $dispatcher->dispatch($matched, $request, $response);
+ $dispatcher->dispatch($matched, $request);
}
}
diff --git a/tests/Unit/Router/RouteFinderTest.php b/tests/Unit/Router/RouteFinderTest.php
index 3a5f37743..f81d474da 100644
--- a/tests/Unit/Router/RouteFinderTest.php
+++ b/tests/Unit/Router/RouteFinderTest.php
@@ -22,7 +22,7 @@ public function setUp(): void
$this->finder = new RouteFinder($this->collection);
}
- public function testRouteFinderFindReturnsMatchedRouteForStaticMatch()
+ public function testRouteFinderFindReturnsMatchedRouteForStaticMatch(): void
{
$route = new Route(['GET'], 'users', 'Ctrl', 'act');
$this->collection->add($route);
@@ -37,7 +37,7 @@ public function testRouteFinderFindReturnsMatchedRouteForStaticMatch()
$this->assertSame([], $result->getParams());
}
- public function testRouteFinderFindReturnsNullWhenNoMatch()
+ public function testRouteFinderFindReturnsNullWhenNoMatch(): void
{
$route = new Route(['GET'], 'users', 'Ctrl', 'act');
$this->collection->add($route);
@@ -48,7 +48,7 @@ public function testRouteFinderFindReturnsNullWhenNoMatch()
$this->assertNull($this->finder->find($req));
}
- public function testRouteFinderFindSkipsWrongHttpMethod()
+ public function testRouteFinderFindSkipsWrongHttpMethod(): void
{
$route = new Route(['POST'], 'users', 'Ctrl', 'act');
$this->collection->add($route);
@@ -59,7 +59,7 @@ public function testRouteFinderFindSkipsWrongHttpMethod()
$this->assertNull($this->finder->find($req));
}
- public function testRouteFinderFindReturnsFirstMatchingRouteOnly()
+ public function testRouteFinderFindReturnsFirstMatchingRouteOnly(): void
{
$r1 = new Route(['GET'], 'users', 'C1', 'a1');
$r2 = new Route(['GET'], 'users', 'C2', 'a2');
@@ -75,7 +75,7 @@ public function testRouteFinderFindReturnsFirstMatchingRouteOnly()
$this->assertSame($r1, $result->getRoute());
}
- public function testRouteFinderFindPassesExtractedParams()
+ public function testRouteFinderFindPassesExtractedParams(): void
{
$route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act');
$this->collection->add($route);
@@ -88,7 +88,7 @@ public function testRouteFinderFindPassesExtractedParams()
$this->assertSame(['id' => '42'], $result->getParams());
}
- public function testRouteFinderFindWithMultipleRoutesOnlyOneMatches()
+ public function testRouteFinderFindWithMultipleRoutesOnlyOneMatches(): void
{
$r1 = new Route(['GET'], 'posts', 'Ctrl', 'act');
$this->collection->add($r1);
diff --git a/tests/Unit/Router/RouteTest.php b/tests/Unit/Router/RouteTest.php
index b78f0b137..811719185 100644
--- a/tests/Unit/Router/RouteTest.php
+++ b/tests/Unit/Router/RouteTest.php
@@ -8,7 +8,7 @@
class RouteTest extends AppTestCase
{
- public function testRouteControllerRouteConstruction()
+ public function testRouteControllerRouteConstruction(): void
{
$route = new Route(
['get', 'post'],
@@ -28,9 +28,9 @@ public function testRouteControllerRouteConstruction()
$this->assertFalse($route->isClosure());
}
- public function testRouteClosureRouteConstruction()
+ public function testRouteClosureRouteConstruction(): void
{
- $handler = function () {
+ $handler = function (): void {
};
$route = new Route(
@@ -50,14 +50,14 @@ public function testRouteClosureRouteConstruction()
$this->assertNull($route->getAction());
}
- public function testRouteConstructorRejectsEmptyMethods()
+ public function testRouteConstructorRejectsEmptyMethods(): void
{
$this->expectException(RouteException::class);
new Route([], 'users', 'UserController', 'listAction');
}
- public function testRouteClosureRouteCannotDefineControllerOrAction()
+ public function testRouteClosureRouteCannotDefineControllerOrAction(): void
{
$this->expectException(RouteException::class);
@@ -66,19 +66,19 @@ public function testRouteClosureRouteCannotDefineControllerOrAction()
'health',
'HealthController',
'checkAction',
- function () {
+ function (): void {
}
);
}
- public function testRouteControllerRouteRequiresControllerAndAction()
+ public function testRouteControllerRouteRequiresControllerAndAction(): void
{
$this->expectException(RouteException::class);
new Route(['GET'], 'users', null, null);
}
- public function testRouteAllowsMethodIsCaseInsensitive()
+ public function testRouteAllowsMethodIsCaseInsensitive(): void
{
$route = new Route(
['GET'],
@@ -94,7 +94,7 @@ public function testRouteAllowsMethodIsCaseInsensitive()
$this->assertFalse($route->allowsMethod('POST'));
}
- public function testRouteCacheConfigurationIsStored()
+ public function testRouteCacheConfigurationIsStored(): void
{
$route = new Route(
['GET'],
@@ -111,7 +111,7 @@ public function testRouteCacheConfigurationIsStored()
);
}
- public function testRouteCompiledPatternCanBeStored()
+ public function testRouteCompiledPatternCanBeStored(): void
{
$route = new Route(
['GET'],
@@ -125,7 +125,7 @@ public function testRouteCompiledPatternCanBeStored()
$this->assertSame('^users$', $route->getCompiledPattern());
}
- public function testRouteMiddlewareStackingOrder()
+ public function testRouteMiddlewareStackingOrder(): void
{
$route = new Route(
['GET'],
@@ -143,7 +143,7 @@ public function testRouteMiddlewareStackingOrder()
);
}
- public function testRouteToArrayExportsRouteState()
+ public function testRouteToArrayExportsRouteState(): void
{
$route = new Route(
['GET'],
diff --git a/tests/Unit/Service/Factories/ServiceFactoryTest.php b/tests/Unit/Service/Factories/ServiceFactoryTest.php
index 3ef243f6a..a491da556 100644
--- a/tests/Unit/Service/Factories/ServiceFactoryTest.php
+++ b/tests/Unit/Service/Factories/ServiceFactoryTest.php
@@ -9,6 +9,9 @@ class TestService extends QtService
{
public static $count = 0;
+ /**
+ * @var TestModel
+ */
public $model;
public function __construct(TestModel $model)
@@ -18,7 +21,7 @@ public function __construct(TestModel $model)
$this->model = $model;
}
- public function hello()
+ public function hello(): string
{
return 'Hello';
}
@@ -55,7 +58,7 @@ public function tearDown(): void
TestService::$count = 0;
}
- public function testServiceFactoryGetInstance()
+ public function testServiceFactoryGetInstance(): void
{
$service = ServiceFactory::get(TestService::class);
@@ -64,7 +67,7 @@ public function testServiceFactoryGetInstance()
$this->assertInstanceOf(TestService::class, $service);
}
- public function testServiceFactoryVerifySingletonInstance()
+ public function testServiceFactoryVerifySingletonInstance(): void
{
$testServiceOne = ServiceFactory::get(TestService::class);
@@ -77,7 +80,7 @@ public function testServiceFactoryVerifySingletonInstance()
$this->assertSame($testServiceOne, $testServiceTwo);
}
- public function testServiceFactoryCreateInstance()
+ public function testServiceFactoryCreateInstance(): void
{
$service = ServiceFactory::create(TestService::class);
@@ -86,7 +89,7 @@ public function testServiceFactoryCreateInstance()
$this->assertInstanceOf(TestService::class, $service);
}
- public function testServiceFactoryVerifyFreshInstance()
+ public function testServiceFactoryVerifyFreshInstance(): void
{
$testServiceOne = ServiceFactory::create(TestService::class);
@@ -99,21 +102,21 @@ public function testServiceFactoryVerifyFreshInstance()
$this->assertNotSame($testServiceOne, $testServiceTwo);
}
- public function testServiceFactoryVerifyConstructorDependencyResolved()
+ public function testServiceFactoryVerifyConstructorDependencyResolved(): void
{
$testService = ServiceFactory::get(TestService::class);
$this->assertInstanceOf(DbModel::class, $testService->model);
}
- public function testServiceFactoryServiceMethodCall()
+ public function testServiceFactoryServiceMethodCall(): void
{
$this->assertEquals('Hello', ServiceFactory::get(TestService::class)->hello());
$this->assertEquals('Hello', ServiceFactory::create(TestService::class)->hello());
}
- public function testServiceFactoryServiceNotFound()
+ public function testServiceFactoryServiceNotFound(): void
{
$this->expectException(ServiceException::class);
diff --git a/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php b/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php
index e940480ff..8473c8f7c 100644
--- a/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php
+++ b/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php
@@ -9,7 +9,7 @@
class ServiceHelperFunctionTest extends AppTestCase
{
- public function testServiceReturnsQtServiceInstance()
+ public function testServiceReturnsQtServiceInstance(): void
{
$service = service(TokenService::class);
@@ -18,7 +18,7 @@ public function testServiceReturnsQtServiceInstance()
$this->assertInstanceOf(QtService::class, $service);
}
- public function testModelThrowsOnInvalidClass()
+ public function testModelThrowsOnInvalidClass(): void
{
$this->expectException(ServiceException::class);
diff --git a/tests/Unit/Service/QtServiceTest.php b/tests/Unit/Service/QtServiceTest.php
index af9d729b6..49fc275bb 100644
--- a/tests/Unit/Service/QtServiceTest.php
+++ b/tests/Unit/Service/QtServiceTest.php
@@ -28,7 +28,7 @@ public function setUp(): void
parent::setUp();
}
- public function testMissingMethods()
+ public function testMissingMethods(): void
{
$this->expectException(ServiceException::class);
diff --git a/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php b/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php
index afe6e8519..157302b8e 100644
--- a/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php
+++ b/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php
@@ -12,7 +12,7 @@ class DatabaseSessionAdapterTest extends AppTestCase
{
use TestCaseHelper;
- private $session;
+ private DatabaseSessionAdapter $session;
public function setUp(): void
{
@@ -32,12 +32,12 @@ public function tearDown(): void
ModelFactory::createDynamicModel('sessions')->deleteMany();
}
- public function testDatabaseSessionConstructor()
+ public function testDatabaseSessionConstructor(): void
{
$this->assertInstanceOf(DatabaseSessionAdapter::class, $this->session);
}
- public function testDatabaseSessionAll()
+ public function testDatabaseSessionAll(): void
{
$this->assertEmpty($this->session->all());
@@ -54,7 +54,7 @@ public function testDatabaseSessionAll()
$this->assertEquals('Test data', $this->session->all()['test']);
}
- public function testDatabaseSessionGetSetHasDelete()
+ public function testDatabaseSessionGetSetHasDelete(): void
{
$this->assertNull($this->session->get('auth'));
@@ -73,7 +73,7 @@ public function testDatabaseSessionGetSetHasDelete()
$this->assertNull($this->session->get('auth'));
}
- public function testDatabaseSessionGetSetFlash()
+ public function testDatabaseSessionGetSetFlash(): void
{
$this->session->setFlash('message', 'Flash message');
@@ -82,7 +82,7 @@ public function testDatabaseSessionGetSetFlash()
$this->assertNull($this->session->getFlash('message'));
}
- public function testDatabaseSessionFlush()
+ public function testDatabaseSessionFlush(): void
{
$this->session->set('test', 'Test data');
@@ -93,12 +93,12 @@ public function testDatabaseSessionFlush()
$this->assertEmpty($this->session->all());
}
- public function testDatabaseSessionGetSessionId()
+ public function testDatabaseSessionGetSessionId(): void
{
$this->assertEquals(session_id(), $this->session->getId());
}
- public function testDatabaseSessionRegenerateSessionId()
+ public function testDatabaseSessionRegenerateSessionId(): void
{
$sessionId = $this->session->getId();
diff --git a/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php b/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php
index cfcd8d6dd..b48f51c9e 100644
--- a/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php
+++ b/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php
@@ -7,7 +7,7 @@
class NativeSessionAdapterTest extends AppTestCase
{
- private $session;
+ private NativeSessionAdapter $session;
public function setUp(): void
{
@@ -18,12 +18,12 @@ public function setUp(): void
$this->session->delete('LAST_ACTIVITY');
}
- public function testNativeSessionConstructor()
+ public function testNativeSessionConstructor(): void
{
$this->assertInstanceOf(NativeSessionAdapter::class, $this->session);
}
- public function testNativeSessionSessionAll()
+ public function testNativeSessionSessionAll(): void
{
$this->assertEmpty($this->session->all());
@@ -40,7 +40,7 @@ public function testNativeSessionSessionAll()
$this->assertEquals('Test data', $this->session->all()['test']);
}
- public function testNativeSessionGetSetHasDelete()
+ public function testNativeSessionGetSetHasDelete(): void
{
$this->assertNull($this->session->get('auth'));
@@ -59,7 +59,7 @@ public function testNativeSessionGetSetHasDelete()
$this->assertNull($this->session->get('auth'));
}
- public function testNativeSessionGetSetFlash()
+ public function testNativeSessionGetSetFlash(): void
{
$this->session->setFlash('message', 'Flash message');
@@ -68,7 +68,7 @@ public function testNativeSessionGetSetFlash()
$this->assertNull($this->session->getFlash('message'));
}
- public function testNativeSessionFlush()
+ public function testNativeSessionFlush(): void
{
$this->session->set('test', 'Test data');
@@ -81,12 +81,12 @@ public function testNativeSessionFlush()
session_start();
}
- public function testNativeSessionGetSessionId()
+ public function testNativeSessionGetSessionId(): void
{
$this->assertEquals(session_id(), $this->session->getId());
}
- public function testNativeSessionRegenerateSessionId()
+ public function testNativeSessionRegenerateSessionId(): void
{
$sessionId = $this->session->getId();
diff --git a/tests/Unit/Session/Factories/SessionFactoryTest.php b/tests/Unit/Session/Factories/SessionFactoryTest.php
index 6913dd60b..0db03a381 100644
--- a/tests/Unit/Session/Factories/SessionFactoryTest.php
+++ b/tests/Unit/Session/Factories/SessionFactoryTest.php
@@ -39,35 +39,35 @@ public function tearDown(): void
ModelFactory::createDynamicModel('sessions')->deleteMany();
}
- public function testSessionFactoryInstance()
+ public function testSessionFactoryInstance(): void
{
$session = SessionFactory::get();
$this->assertInstanceOf(Session::class, $session);
}
- public function testSessionFactoryGetDefaultSessionAdapter()
+ public function testSessionFactoryGetDefaultSessionAdapter(): void
{
$session = SessionFactory::get();
$this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter());
}
- public function testSessionFactoryGetNativeSessionAdapter()
+ public function testSessionFactoryGetNativeSessionAdapter(): void
{
$session = SessionFactory::get(Session::NATIVE);
$this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter());
}
- public function testSessionFactoryGetDatabaseAdapter()
+ public function testSessionFactoryGetDatabaseAdapter(): void
{
$session = SessionFactory::get(Session::DATABASE);
$this->assertInstanceOf(DatabaseSessionAdapter::class, $session->getAdapter());
}
- public function testSessionSubsequentRequests()
+ public function testSessionSubsequentRequests(): void
{
config()->set('session.default', 'database');
@@ -102,7 +102,7 @@ public function testSessionSubsequentRequests()
$this->assertEquals('Data saved in persistent storage', $session->get('data'));
}
- public function testSessionFactoryInvalidTypeAdapter()
+ public function testSessionFactoryInvalidTypeAdapter(): void
{
$this->expectException(SessionException::class);
@@ -111,7 +111,7 @@ public function testSessionFactoryInvalidTypeAdapter()
SessionFactory::get('invalid_type');
}
- public function testMailerFactoryReturnsSameInstance()
+ public function testMailerFactoryReturnsSameInstance(): void
{
$session1 = SessionFactory::get(Session::NATIVE);
$session2 = SessionFactory::get(Session::NATIVE);
diff --git a/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php b/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php
index 28096c073..b1b7ee494 100644
--- a/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php
+++ b/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php
@@ -9,7 +9,7 @@
class SessionHelperFunctionsTest extends AppTestCase
{
- public function testSessionHelperGetDefaultSessionAdapter()
+ public function testSessionHelperGetDefaultSessionAdapter(): void
{
config()->delete('session');
@@ -20,7 +20,7 @@ public function testSessionHelperGetDefaultSessionAdapter()
$this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter());
}
- public function testSessionHelperGetNativeSessionAdapter()
+ public function testSessionHelperGetNativeSessionAdapter(): void
{
$session = session(Session::NATIVE);
@@ -29,7 +29,7 @@ public function testSessionHelperGetNativeSessionAdapter()
$this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter());
}
- public function testSessionHelperGetDatabaseSessionAdapter()
+ public function testSessionHelperGetDatabaseSessionAdapter(): void
{
$session = session(Session::DATABASE);
@@ -38,7 +38,7 @@ public function testSessionHelperGetDatabaseSessionAdapter()
$this->assertInstanceOf(DatabaseSessionAdapter::class, $session->getAdapter());
}
- public function testSessionMethodsViaHelper()
+ public function testSessionMethodsViaHelper(): void
{
$this->assertFalse(session()->has('test'));
diff --git a/tests/Unit/Session/SessionTest.php b/tests/Unit/Session/SessionTest.php
index e180c088a..56c3b787a 100644
--- a/tests/Unit/Session/SessionTest.php
+++ b/tests/Unit/Session/SessionTest.php
@@ -21,7 +21,7 @@ public function setUp(): void
}
}
- public function testSessionGetAdapter()
+ public function testSessionGetAdapter(): void
{
$session = new Session(new NativeSessionAdapter());
@@ -36,7 +36,7 @@ public function testSessionGetAdapter()
$this->assertInstanceOf(SessionStorageInterface::class, $session->getAdapter());
}
- public function testSessionCallingValidMethod()
+ public function testSessionCallingValidMethod(): void
{
$session = new Session(new NativeSessionAdapter());
@@ -45,7 +45,7 @@ public function testSessionCallingValidMethod()
$this->assertEquals('Test data', $session->get('test'));
}
- public function testSessionCallingInvalidMethod()
+ public function testSessionCallingInvalidMethod(): void
{
$mailer = new Session(new NativeSessionAdapter());
diff --git a/tests/Unit/Session/TestCaseHelper.php b/tests/Unit/Session/TestCaseHelper.php
index 3ff2a429d..62280d160 100644
--- a/tests/Unit/Session/TestCaseHelper.php
+++ b/tests/Unit/Session/TestCaseHelper.php
@@ -6,7 +6,7 @@
trait TestCaseHelper
{
- private function _createSessionsTable()
+ private function _createSessionsTable(): void
{
IdiormDbal::execute(
'CREATE TABLE IF NOT EXISTS sessions (
diff --git a/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php b/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php
index bfd03f8ae..b12901e17 100644
--- a/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php
+++ b/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php
@@ -11,35 +11,17 @@ class DropboxAppTest extends AppTestCase
use DropboxTokenServiceTestCase;
use HttpClientTestCase;
- /**
- * @var DropboxApp
- */
- private $dropboxApp;
-
- /**
- * @var string
- */
- private $appKey = 'x0hwm8wy63rrynm';
-
- /**
- * @var string
- */
- private $appSecret = 'xxx123yyy';
-
- /**
- * @var string
- */
- private $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA';
-
- /**
- * @var string
- */
- private $redirectUrl = 'http://localhost/confirm';
-
- /**
- * @var array
- */
- private $tokensGrantResponse = [
+ private DropboxApp $dropboxApp;
+
+ private string $appKey = 'x0hwm8wy63rrynm';
+
+ private string $appSecret = 'xxx123yyy';
+
+ private string $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA';
+
+ private string $redirectUrl = 'http://localhost/confirm';
+
+ private array $tokensGrantResponse = [
'access_token' => 'sl.BYEQ1_VadTz6nBU36WPBBVwokc3zWVMXGjcOKxV4Tadms8ZlEPM85aHVFa_k1sfjilCWOnl79RUncPZzJ3GhrqhLGIBFFRCH0rKMa_ZtcqkerJn-f5lu10Ki5PSw4fxYM80V4PL_',
'token_type' => 'bearer',
'expires_in' => 14400,
@@ -49,10 +31,7 @@ class DropboxAppTest extends AppTestCase
'account_id' => 'dbid:AAC9tDKbzTQlyNms0ZcB_iH3wLv7yNn-iyE',
];
- /**
- * @var array
- */
- private $profileDataResponse = [
+ private array $profileDataResponse = [
'account_id' => 'dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc',
'disabled' => false,
'email' => 'franz@dropbox.com',
@@ -68,20 +47,14 @@ class DropboxAppTest extends AppTestCase
'profile_photo_url' => 'https://dl-web.dropbox.com/account_photo/get/69330102&size=128x128',
];
- /**
- * @var array
- */
- private $errorResponse = [
+ private array $errorResponse = [
'error' => [
'.tag' => 'no_account',
],
'error_summary' => 'no_account/...',
];
- /**
- * @var string
- */
- private $fileContentResponse = 'Some plain text!';
+ private string $fileContentResponse = 'Some plain text!';
public function setUp(): void
{
@@ -94,7 +67,7 @@ public function setUp(): void
$this->dropboxApp = new DropboxApp($this->appKey, $this->appSecret, $tokenServiceMock, $httpClientMock);
}
- public function testDropboxGetAuthUrl()
+ public function testDropboxGetAuthUrl(): void
{
$authUrl = $this->dropboxApp->getAuthUrl($this->redirectUrl);
@@ -105,7 +78,7 @@ public function testDropboxGetAuthUrl()
$this->assertStringContainsString('token_access_type', $authUrl);
}
- public function testDropboxFetchTokens()
+ public function testDropboxFetchTokens(): void
{
$this->currentResponse = (object) $this->tokensGrantResponse;
@@ -118,7 +91,7 @@ public function testDropboxFetchTokens()
$this->assertTrue(property_exists($response, 'refresh_token'));
}
- public function testDropboxRpcRequest()
+ public function testDropboxRpcRequest(): void
{
$this->currentResponse = (object) $this->profileDataResponse;
@@ -131,7 +104,7 @@ public function testDropboxRpcRequest()
$this->assertTrue(property_exists($response, 'name'));
}
- public function testDropboxContentRequest()
+ public function testDropboxContentRequest(): void
{
$this->currentResponse = $this->fileContentResponse;
@@ -142,7 +115,7 @@ public function testDropboxContentRequest()
$this->assertEquals('Some plain text!', $response);
}
- public function testDropboxSendRequest()
+ public function testDropboxSendRequest(): void
{
$this->currentResponse = (object) $this->profileDataResponse;
@@ -153,7 +126,7 @@ public function testDropboxSendRequest()
$this->assertEquals((object) $this->profileDataResponse, $response);
}
- public function testDropboxRequestWithAccessTokenExpired()
+ public function testDropboxRequestWithAccessTokenExpired(): void
{
$this->currentErrors = ['code' => 401];
@@ -166,7 +139,7 @@ public function testDropboxRequestWithAccessTokenExpired()
$this->assertEquals((object) $this->profileDataResponse, $response);
}
- public function testDropboxPathNormalizer()
+ public function testDropboxPathNormalizer(): void
{
$this->assertEquals(['path' => '/message.txt'], $this->dropboxApp->path('/message.txt'));
diff --git a/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php b/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php
index 79aca06bd..07a80a9bd 100644
--- a/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php
+++ b/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php
@@ -14,25 +14,13 @@ class DropboxFileSystemAdapterTest extends AppTestCase
*/
protected $fs;
- /**
- * @var string
- */
- private $dirname = 'common';
+ private string $dirname = 'common';
- /**
- * @var string
- */
- private $filename = 'sample.txt';
+ private string $filename = 'sample.txt';
- /**
- * @var string
- */
- private $content = 'This file was created via dropbox api';
+ private string $content = 'This file was created via dropbox api';
- /**
- * @var array
- */
- private static $response = [];
+ private static array $response = [];
public function setUp(): void
{
@@ -42,7 +30,7 @@ public function setUp(): void
$dropboxAppMock
->shouldReceive('rpcRequest')
- ->andReturnUsing(function ($endpoint, $params) {
+ ->andReturnUsing(function ($endpoint, $params): array {
self::$response = array_merge(self::$response, $params);
return self::$response;
});
@@ -59,7 +47,7 @@ public function setUp(): void
$dropboxAppMock
->shouldReceive('path')
- ->andReturnUsing(fn ($path) => ['path' => '/' . trim($path, '/')]);
+ ->andReturnUsing(fn ($path): array => ['path' => '/' . trim($path, '/')]);
$this->fs = new DropboxFileSystemAdapter($dropboxAppMock);
}
@@ -69,7 +57,7 @@ public function tearDown(): void
self::$response = [];
}
- public function testDropboxMakeCheckRemoveDirectory()
+ public function testDropboxMakeCheckRemoveDirectory(): void
{
$this->assertFalse($this->fs->isDirectory($this->dirname));
@@ -86,7 +74,7 @@ public function testDropboxMakeCheckRemoveDirectory()
$this->assertFalse($this->fs->isDirectory($this->dirname));
}
- public function testDropboxCreateGetCheckRemoveFile()
+ public function testDropboxCreateGetCheckRemoveFile(): void
{
$this->assertFalse($this->fs->isFile($this->filename));
@@ -107,7 +95,7 @@ public function testDropboxCreateGetCheckRemoveFile()
$this->assertFalse($this->fs->exists($this->filename));
}
- public function testDropboxFileAppend()
+ public function testDropboxFileAppend(): void
{
self::$response['.tag'] = 'file';
@@ -122,7 +110,7 @@ public function testDropboxFileAppend()
$this->assertEquals($this->content . $moreContent, $this->fs->get($this->filename));
}
- public function testDropboxFileRename()
+ public function testDropboxFileRename(): void
{
$this->fs->put($this->filename, $this->content);
@@ -139,7 +127,7 @@ public function testDropboxFileRename()
$this->fs->remove($newFilename);
}
- public function testDropboxFileCopy()
+ public function testDropboxFileCopy(): void
{
$dirName = 'testing';
@@ -160,7 +148,7 @@ public function testDropboxFileCopy()
$this->fs->removeDirectory($dirName);
}
- public function testDropboxFileSize()
+ public function testDropboxFileSize(): void
{
$text = 'some bytes';
@@ -171,7 +159,7 @@ public function testDropboxFileSize()
$this->assertEquals(10, $this->fs->size($this->filename));
}
- public function testDropboxFileLastModified()
+ public function testDropboxFileLastModified(): void
{
$modified = '2023-02-12T15:50:38Z';
@@ -184,7 +172,7 @@ public function testDropboxFileLastModified()
$this->assertEquals(strtotime($modified), $this->fs->lastModified($this->filename));
}
- public function testDropboxListDirectory()
+ public function testDropboxListDirectory(): void
{
self::$response['entries'] = [
[
diff --git a/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php b/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php
index 365f4b81e..c7e72b907 100644
--- a/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php
+++ b/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php
@@ -13,7 +13,7 @@ protected function mockTokenService()
$tokenServiceMock
->shouldReceive('getRefreshToken')
- ->andReturnUsing(function () {
+ ->andReturnUsing(function (): string {
$this->currentResponse = (object) $this->tokensGrantResponse;
return 'ref_tok_1234';
});
@@ -24,7 +24,7 @@ protected function mockTokenService()
$tokenServiceMock
->shouldReceive('saveTokens')
- ->andReturnUsing(function ($tokens) {
+ ->andReturnUsing(function ($tokens): bool {
$this->currentResponse = (object) $this->profileDataResponse;
return true;
});
diff --git a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php
index dc2d48d59..58d7f8f43 100644
--- a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php
+++ b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php
@@ -11,58 +11,34 @@ class GoogleDriveAppTest extends AppTestCase
use GoogleDriveTokenServiceTestCase;
use HttpClientTestCase;
- /**
- * @var GoogleDriveApp
- */
- private $googleDriveApp;
+ private GoogleDriveApp $googleDriveApp;
- /**
- * @var string
- */
- private $appKey = 'x0hwm8wy63rrynm';
+ private string $appKey = 'x0hwm8wy63rrynm';
- /**
- * @var string
- */
- private $appSecret = 'xxx123yyy';
+ private string $appSecret = 'xxx123yyy';
- /**
- * @var string
- */
- private $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA';
+ private string $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA';
- /**
- * @var string
- */
- private $redirectUrl = 'http://localhost/confirm';
+ private string $redirectUrl = 'http://localhost/confirm';
- /**
- * @var array
- */
- private $tokensGrantResponse = [
+ private array $tokensGrantResponse = [
'access_token' => 'sl.BYEQ1_VadTz6nBU36WPBBVwokc3zWVMXGjcOKxV4Tadms8ZlEPM85aHVFa_k1sfjilCWOnl79RUncPZzJ3GhrqhLGIBFFRCH0rKMa_ZtcqkerJn-f5lu10Ki5PSw4fxYM80V4PL_',
'refresh_token' => '-3S067m3M5kAAAAAAAAAAcQF8zVqFUuhK-PFkFqiOfFTgiazWj5NyU-1EGWIh0ZS',
];
- /**
- * @var array
- */
- private $fileMetadataResponse = [
+ private array $fileMetadataResponse = [
'id' => 'file1',
'kind' => GoogleDriveApp::DRIVE_FILE_KIND,
'name' => 'myFile',
'mimeType' => 'text/plain',
];
- /**
- * @var string
- */
- private $fileContentResponse = 'Some plain text!';
+ private string $fileContentResponse = 'Some plain text!';
/**
* @var string
*/
- private $errorResponse = [
+ private array $errorResponse = [
'code' => GoogleDriveApp::INVALID_TOKEN_ERROR_CODE,
'message' => 'Invalid access token',
];
@@ -78,7 +54,7 @@ public function setUp(): void
$this->googleDriveApp = new GoogleDriveApp($this->appKey, $this->appSecret, $tokenServiceMock, $httpClientMock);
}
- public function testGoogleDriveGetAuthUrl()
+ public function testGoogleDriveGetAuthUrl(): void
{
$authUrl = $this->googleDriveApp->getAuthUrl($this->redirectUrl);
@@ -89,7 +65,7 @@ public function testGoogleDriveGetAuthUrl()
$this->assertStringContainsString('access_type', $authUrl);
}
- public function testGoogleDriveFetchTokens()
+ public function testGoogleDriveFetchTokens(): void
{
$this->currentResponse = (object) $this->tokensGrantResponse;
@@ -102,7 +78,7 @@ public function testGoogleDriveFetchTokens()
$this->assertTrue(property_exists($response, 'refresh_token'));
}
- public function testGoogleDriveRpcRequest()
+ public function testGoogleDriveRpcRequest(): void
{
$this->currentResponse = (object) $this->fileMetadataResponse;
@@ -119,7 +95,7 @@ public function testGoogleDriveRpcRequest()
$this->assertTrue(property_exists($response, 'mimeType'));
}
- public function testGoogleDriveGetFileInfo()
+ public function testGoogleDriveGetFileInfo(): void
{
$this->currentResponse = $this->fileContentResponse;
@@ -130,7 +106,7 @@ public function testGoogleDriveGetFileInfo()
$this->assertEquals('Some plain text!', $response);
}
- public function testGoogleDriveRequestWithAccessTokenExpired()
+ public function testGoogleDriveRequestWithAccessTokenExpired(): void
{
$this->currentErrors = ['code' => 401];
diff --git a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php
index 9b71b7cd8..90b53c116 100644
--- a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php
+++ b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php
@@ -14,30 +14,15 @@ class GoogleDriveFileSystemAdapterTest extends AppTestCase
*/
protected $fs;
- /**
- * @var string
- */
- private $dirname = 'common';
+ private string $dirname = 'common';
- /**
- * @var string
- */
- private $filename = 'sample.txt';
+ private string $filename = 'sample.txt';
- /**
- * @var string
- */
- private $newFilename = 'new_name.txt';
+ private string $newFilename = 'new_name.txt';
- /**
- * @var string
- */
- private $content = 'This file was created via gdrive api';
+ private string $content = 'This file was created via gdrive api';
- /**
- * @var array
- */
- private static $response = [];
+ private static array $response = [];
public function setUp(): void
{
@@ -63,7 +48,7 @@ public function tearDown(): void
self::$response = [];
}
- public function testGoogleDriveMakeCheckRemoveDirectory()
+ public function testGoogleDriveMakeCheckRemoveDirectory(): void
{
$this->assertFalse($this->fs->isDirectory($this->dirname));
@@ -80,7 +65,7 @@ public function testGoogleDriveMakeCheckRemoveDirectory()
$this->assertFalse($this->fs->isDirectory($this->dirname));
}
- public function testGoogleDriveCreateGetCheckRemoveFile()
+ public function testGoogleDriveCreateGetCheckRemoveFile(): void
{
$this->assertFalse($this->fs->isFile($this->filename));
@@ -102,7 +87,7 @@ public function testGoogleDriveCreateGetCheckRemoveFile()
$this->assertFalse($this->fs->exists($this->filename));
}
- public function testGoogleDriveFileAppend()
+ public function testGoogleDriveFileAppend(): void
{
self::$response['kind'] = GoogleDriveApp::DRIVE_FILE_KIND;
self::$response['mimeType'] = 'text/plain';
@@ -118,7 +103,7 @@ public function testGoogleDriveFileAppend()
$this->assertEquals($this->content . $moreContent, $this->fs->get($this->filename));
}
- public function testGoogleDriveFileRename()
+ public function testGoogleDriveFileRename(): void
{
$this->fs->put($this->filename, $this->content);
@@ -134,7 +119,7 @@ public function testGoogleDriveFileRename()
$this->fs->remove($this->newFilename);
}
- public function testGoogleDriveFileCopy()
+ public function testGoogleDriveFileCopy(): void
{
$this->fs->makeDirectory($this->dirname);
@@ -154,7 +139,7 @@ public function testGoogleDriveFileCopy()
$this->fs->removeDirectory($this->dirname);
}
- public function testGoogleDriveFileSize()
+ public function testGoogleDriveFileSize(): void
{
$text = 'some bytes';
@@ -165,7 +150,7 @@ public function testGoogleDriveFileSize()
$this->assertEquals(strlen($text), $this->fs->size($this->filename));
}
- public function testGoogleDriveFileLastModified()
+ public function testGoogleDriveFileLastModified(): void
{
$modified = '2023-02-12T15:50:38Z';
@@ -179,7 +164,7 @@ public function testGoogleDriveFileLastModified()
$this->assertEquals(strtotime($modified), $result);
}
- public function testGoogleDriveListDirectory()
+ public function testGoogleDriveListDirectory(): void
{
self::$response['files'] = [
[
diff --git a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php
index c884b30b2..f27f59388 100644
--- a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php
+++ b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php
@@ -11,14 +11,14 @@ protected function mockTokenService()
{
$tokenServiceMock = Mockery::mock(TokenServiceInterface::class);
- $tokenServiceMock->shouldReceive('getRefreshToken')->andReturnUsing(function () {
+ $tokenServiceMock->shouldReceive('getRefreshToken')->andReturnUsing(function (): string {
$this->currentResponse = (object) $this->tokensGrantResponse;
return 'ref_tok_1234';
});
$tokenServiceMock->shouldReceive('getAccessToken')->andReturn('acc_tok_1234');
- $tokenServiceMock->shouldReceive('saveTokens')->andReturnUsing(function ($tokens) {
+ $tokenServiceMock->shouldReceive('saveTokens')->andReturnUsing(function ($tokens): bool {
$this->currentResponse = (object) $this->fileMetadataResponse;
return true;
});
diff --git a/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php b/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php
index a9fab2268..330c4bd69 100644
--- a/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php
+++ b/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php
@@ -12,20 +12,11 @@ class LocalFileSystemAdapterTest extends AppTestCase
*/
protected $fs;
- /**
- * @var string
- */
- private $dirname;
+ private string $dirname;
- /**
- * @var string
- */
- private $filename;
+ private string $filename;
- /**
- * @var string
- */
- private $content = 'Hello world';
+ private string $content = 'Hello world';
public function setUp(): void
{
@@ -47,7 +38,7 @@ public function tearDown(): void
}
}
- public function testLocalMakeRemoveDirectory()
+ public function testLocalMakeRemoveDirectory(): void
{
$this->assertDirectoryDoesNotExist($this->dirname);
@@ -60,7 +51,7 @@ public function testLocalMakeRemoveDirectory()
$this->assertDirectoryDoesNotExist($this->dirname);
}
- public function testLocalFileGetPut()
+ public function testLocalFileGetPut(): void
{
$this->fs->put($this->filename, $this->content);
@@ -69,7 +60,7 @@ public function testLocalFileGetPut()
$this->assertEquals($this->content, $this->fs->get($this->filename));
}
- public function testLocalFileAppend()
+ public function testLocalFileAppend(): void
{
$this->fs->put($this->filename, $this->content);
@@ -82,7 +73,7 @@ public function testLocalFileAppend()
$this->assertEquals($this->content . $moreContent, $this->fs->get($this->filename));
}
- public function tesLocalFileRename()
+ public function tesLocalFileRename(): void
{
$this->fs->put($this->filename, $this->content);
@@ -97,7 +88,7 @@ public function tesLocalFileRename()
$this->fs->remove($newFilename);
}
- public function testLocalFileCopy()
+ public function testLocalFileCopy(): void
{
$this->fs->makeDirectory($this->dirname);
@@ -114,7 +105,7 @@ public function testLocalFileCopy()
$this->fs->removeDirectory($this->dirname);
}
- public function testLocalFileExists()
+ public function testLocalFileExists(): void
{
$newFilename = base_dir() . DS . 'new_name.txt';
@@ -127,21 +118,21 @@ public function testLocalFileExists()
$this->fs->remove($newFilename);
}
- public function testLocalFileSize()
+ public function testLocalFileSize(): void
{
$this->fs->put($this->filename, 'some bytes');
$this->assertEquals(10, $this->fs->size($this->filename));
}
- public function testLocalFileLastModified()
+ public function testLocalFileLastModified(): void
{
$this->fs->put($this->filename, $this->content);
$this->assertIsInt($this->fs->lastModified($this->filename));
}
- public function testLocalFileRemove()
+ public function testLocalFileRemove(): void
{
$this->fs->put($this->filename, $this->content);
@@ -152,21 +143,21 @@ public function testLocalFileRemove()
$this->assertFileDoesNotExist($this->filename);
}
- public function testLocalIsFile()
+ public function testLocalIsFile(): void
{
$this->assertTrue($this->fs->isFile(__FILE__));
$this->assertFalse($this->fs->isFile(__DIR__));
}
- public function testLocalIsDirectory()
+ public function testLocalIsDirectory(): void
{
$this->assertTrue($this->fs->isDirectory(__DIR__));
$this->assertFalse($this->fs->isDirectory(__FILE__));
}
- public function testLocalListDirectory()
+ public function testLocalListDirectory(): void
{
$entries = $this->fs->listDirectory(base_dir());
@@ -177,7 +168,7 @@ public function testLocalListDirectory()
$this->assertEmpty($this->fs->listDirectory('nowhere'));
}
- public function testLocalGlob()
+ public function testLocalGlob(): void
{
$entries = $this->fs->glob(base_dir() . DS . '*.log');
@@ -186,7 +177,7 @@ public function testLocalGlob()
$this->assertIsString(current($entries));
}
- public function testLocalFileIsReadableWritable()
+ public function testLocalFileIsReadableWritable(): void
{
$this->fs->put($this->filename, '');
@@ -201,7 +192,7 @@ public function testLocalFileIsReadableWritable()
$this->assertFalse($this->fs->isWritable($this->filename));
}
- public function testLocalFileGetLines()
+ public function testLocalFileGetLines(): void
{
$lineOne = 'It\'s was started then ' . PHP_EOL;
$lineTwo = 'something happens' . PHP_EOL;
@@ -227,19 +218,19 @@ public function testLocalFileGetLines()
$this->assertCount(4, $lines);
}
- public function testLocalFileNameAndExtension()
+ public function testLocalFileNameAndExtension(): void
{
$this->assertEquals('test', $this->fs->fileName($this->filename));
$this->assertEquals('txt', $this->fs->extension($this->filename));
}
- public function testLocalFileNameWithExtension()
+ public function testLocalFileNameWithExtension(): void
{
$this->assertEquals('test.txt', $this->fs->fileNameWithExtension($this->filename));
}
- public function testLocalRequireOutput()
+ public function testLocalRequireOutput(): void
{
$this->fs->put($this->filename, $this->content);
@@ -252,7 +243,7 @@ public function testLocalRequireOutput()
$this->assertSame($this->content, $output);
}
- public function testLocalRequireReturn()
+ public function testLocalRequireReturn(): void
{
$this->fs->put($this->filename, " 'abc'];");
@@ -265,7 +256,7 @@ public function testLocalRequireReturn()
$this->assertEquals($result['key'], 'abc');
}
- public function testLocalRequireBehavior()
+ public function testLocalRequireBehavior(): void
{
$this->fs->put($this->filename, 'assertEquals(3, $GLOBALS['include_count']);
}
- public function testLocalRequireOnceBehavior()
+ public function testLocalRequireOnceBehavior(): void
{
$file = base_dir() . DS . 'track1.txt';
@@ -291,7 +282,7 @@ public function testLocalRequireOnceBehavior()
$this->fs->remove($file);
}
- public function testLocalIncludeOutput()
+ public function testLocalIncludeOutput(): void
{
$this->fs->put($this->filename, $this->content);
@@ -304,7 +295,7 @@ public function testLocalIncludeOutput()
$this->assertSame($this->content, $output);
}
- public function testLocalIncludeReturn()
+ public function testLocalIncludeReturn(): void
{
$this->fs->put($this->filename, " 'abc'];");
@@ -317,7 +308,7 @@ public function testLocalIncludeReturn()
$this->assertEquals($result['key'], 'abc');
}
- public function testLocalIncludeBehavior()
+ public function testLocalIncludeBehavior(): void
{
$this->fs->put($this->filename, 'assertEquals(3, $GLOBALS['include_count']);
}
- public function testLocalIncludeOnceBehavior()
+ public function testLocalIncludeOnceBehavior(): void
{
$file = base_dir() . DS . 'track2.txt';
diff --git a/tests/Unit/Storage/Factories/FileSystemFactoryTest.php b/tests/Unit/Storage/Factories/FileSystemFactoryTest.php
index 271531996..92214cff9 100644
--- a/tests/Unit/Storage/Factories/FileSystemFactoryTest.php
+++ b/tests/Unit/Storage/Factories/FileSystemFactoryTest.php
@@ -17,42 +17,42 @@ public function setUp(): void
parent::setUp();
}
- public function testFileSystemFactoryInstance()
+ public function testFileSystemFactoryInstance(): void
{
$fs = FileSystemFactory::get();
$this->assertInstanceOf(FileSystem::class, $fs);
}
- public function testFileSystemFactoryDefaultAdapter()
+ public function testFileSystemFactoryDefaultAdapter(): void
{
$fs = FileSystemFactory::get();
$this->assertInstanceOf(LocalFileSystemAdapter::class, $fs->getAdapter());
}
- public function testFileSystemFactoryLocalAdapter()
+ public function testFileSystemFactoryLocalAdapter(): void
{
$fs = FileSystemFactory::get(FileSystem::LOCAL);
$this->assertInstanceOf(LocalFileSystemAdapter::class, $fs->getAdapter());
}
- public function testFileSystemFactoryDropboxAdapter()
+ public function testFileSystemFactoryDropboxAdapter(): void
{
$fs = FileSystemFactory::get(FileSystem::DROPBOX);
$this->assertInstanceOf(DropboxFileSystemAdapter::class, $fs->getAdapter());
}
- public function testFileSystemFactoryGoogleDriveAdapter()
+ public function testFileSystemFactoryGoogleDriveAdapter(): void
{
$fs = FileSystemFactory::get(FileSystem::GDRIVE);
$this->assertInstanceOf(GoogleDriveFileSystemAdapter::class, $fs->getAdapter());
}
- public function testFileSystemFactoryInvalidTypeAdapter()
+ public function testFileSystemFactoryInvalidTypeAdapter(): void
{
$this->expectException(FileSystemException::class);
@@ -61,7 +61,7 @@ public function testFileSystemFactoryInvalidTypeAdapter()
FileSystemFactory::get('invalid_type');
}
- public function testFileSystemFactoryReturnsSameInstance()
+ public function testFileSystemFactoryReturnsSameInstance(): void
{
$fs1 = FileSystemFactory::get(FileSystem::LOCAL);
$fs2 = FileSystemFactory::get(FileSystem::LOCAL);
diff --git a/tests/Unit/Storage/FileSystemTest.php b/tests/Unit/Storage/FileSystemTest.php
index a95faa1ec..88a92299f 100644
--- a/tests/Unit/Storage/FileSystemTest.php
+++ b/tests/Unit/Storage/FileSystemTest.php
@@ -27,7 +27,7 @@ public function setUp(): void
$this->googleDriveAppMock = Mockery::mock(GoogleDriveApp::class);
}
- public function testFileSystemGetAdapter()
+ public function testFileSystemGetAdapter(): void
{
$localFs = new FileSystem(new LocalFileSystemAdapter());
@@ -48,14 +48,14 @@ public function testFileSystemGetAdapter()
$this->assertInstanceOf(FilesystemAdapterInterface::class, $googleDriveFs->getAdapter());
}
- public function testFileSystemCallingValidMethod()
+ public function testFileSystemCallingValidMethod(): void
{
$fs = new FileSystem(new LocalFileSystemAdapter());
$this->assertFalse($fs->exists('test.txt'));
}
- public function testMailerCallingInvalidMethod()
+ public function testMailerCallingInvalidMethod(): void
{
$mailer = new FileSystem(new LocalFileSystemAdapter());
diff --git a/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php b/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php
index c4a3ad1c1..0c2f69150 100644
--- a/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php
+++ b/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php
@@ -10,28 +10,28 @@
class FileSystemHelperFunctionsTest extends AppTestCase
{
- public function testFileSystemHelperGetDefaultFileSystem()
+ public function testFileSystemHelperGetDefaultFileSystem(): void
{
$this->assertInstanceOf(FileSystem::class, fs());
$this->assertInstanceOf(LocalFileSystemAdapter::class, fs()->getAdapter());
}
- public function testFileSystemHelperGetLocalFileSystem()
+ public function testFileSystemHelperGetLocalFileSystem(): void
{
$this->assertInstanceOf(FileSystem::class, fs(FileSystem::LOCAL));
$this->assertInstanceOf(LocalFileSystemAdapter::class, fs(FileSystem::LOCAL)->getAdapter());
}
- public function testFileSystemHelperGetDropboxFileSystem()
+ public function testFileSystemHelperGetDropboxFileSystem(): void
{
$this->assertInstanceOf(FileSystem::class, fs(FileSystem::DROPBOX));
$this->assertInstanceOf(DropboxFileSystemAdapter::class, fs(FileSystem::DROPBOX)->getAdapter());
}
- public function testFileSystemHelperGetGoogleDriveFileSystem()
+ public function testFileSystemHelperGetGoogleDriveFileSystem(): void
{
$this->assertInstanceOf(FileSystem::class, fs(FileSystem::GDRIVE));
diff --git a/tests/Unit/Storage/HttpClientTestCase.php b/tests/Unit/Storage/HttpClientTestCase.php
index 4d2686fa3..ae1cf845f 100644
--- a/tests/Unit/Storage/HttpClientTestCase.php
+++ b/tests/Unit/Storage/HttpClientTestCase.php
@@ -42,7 +42,7 @@ protected function mockHttpClient()
return $httpClientMock;
});
- $httpClientMock->shouldReceive('getErrors')->andReturnUsing(fn () => (array) $this->response[$this->url]['errors']);
+ $httpClientMock->shouldReceive('getErrors')->andReturnUsing(fn (): array => (array) $this->response[$this->url]['errors']);
$httpClientMock->shouldReceive('getResponseBody')->andReturnUsing(fn () => $this->response[$this->url]['body']);
diff --git a/tests/Unit/Storage/UploadedFileTest.php b/tests/Unit/Storage/UploadedFileTest.php
index f3536c7c3..5982253c1 100644
--- a/tests/Unit/Storage/UploadedFileTest.php
+++ b/tests/Unit/Storage/UploadedFileTest.php
@@ -26,7 +26,7 @@ protected function moveUploadedFile(string $filePath): bool
class UploadedFileTest extends AppTestCase
{
- private $fileMeta;
+ private array $fileMeta;
public function setUp(): void
{
@@ -52,14 +52,14 @@ public function tearDown(): void
}
}
- public function testUploadedFileConstructor()
+ public function testUploadedFileConstructor(): void
{
$uploadedFile = new UploadedFile($this->fileMeta);
$this->assertInstanceOf(UploadedFile::class, $uploadedFile);
}
- public function testUploadedFileGetSetName()
+ public function testUploadedFileGetSetName(): void
{
$uploadedFile = new UploadedFile($this->fileMeta);
@@ -70,7 +70,7 @@ public function testUploadedFileGetSetName()
$this->assertEquals('bar', $uploadedFile->getName());
}
- public function testUploadedFileSetGetRemoteFileSystem()
+ public function testUploadedFileSetGetRemoteFileSystem(): void
{
$dropboxAppMock = Mockery::mock(DropboxApp::class);
@@ -81,35 +81,35 @@ public function testUploadedFileSetGetRemoteFileSystem()
}
- public function testUploadedFileGetExtension()
+ public function testUploadedFileGetExtension(): void
{
$uploadedFile = new UploadedFile($this->fileMeta);
$this->assertEquals('jpg', $uploadedFile->getExtension());
}
- public function testUploadedFileGetNameWithExtension()
+ public function testUploadedFileGetNameWithExtension(): void
{
$uploadedFile = new UploadedFile($this->fileMeta);
$this->assertEquals('foo.jpg', $uploadedFile->getNameWithExtension());
}
- public function testUploadedFileGetMimeType()
+ public function testUploadedFileGetMimeType(): void
{
$uploadedFile = new UploadedFile($this->fileMeta);
$this->assertSame('image/jpeg', $uploadedFile->getMimeType());
}
- public function testUploadedFileGetMd5()
+ public function testUploadedFileGetMd5(): void
{
$uploadedFile = new UploadedFile($this->fileMeta);
$this->assertIsString($uploadedFile->getMd5());
}
- public function testUploadedFileGetDimensions()
+ public function testUploadedFileGetDimensions(): void
{
$uploadedFile = new UploadedFile($this->fileMeta);
@@ -118,7 +118,7 @@ public function testUploadedFileGetDimensions()
$this->assertEquals(300, $uploadedFile->getDimensions()['height']);
}
- public function testUploadedFileUploadWithoutFileSent()
+ public function testUploadedFileUploadWithoutFileSent(): void
{
$fileMeta = [
'size' => 500,
@@ -137,7 +137,7 @@ public function testUploadedFileUploadWithoutFileSent()
$this->assertFalse($uploadedFile->save(base_dir()));
}
- public function testUploadedFileUploadAndSave()
+ public function testUploadedFileUploadAndSave(): void
{
$uploadedFile = new UploadedDouble($this->fileMeta);
@@ -148,7 +148,7 @@ public function testUploadedFileUploadAndSave()
$this->assertTrue(file_exists(base_dir() . DS . $uploadedFile->getNameWithExtension()));
}
- public function testUploadedFileUploadNotAllowedExtensionForMimeType()
+ public function testUploadedFileUploadNotAllowedExtensionForMimeType(): void
{
$fileMeta = $this->fileMeta;
$fileMeta['name'] = 'foo.php';
@@ -161,7 +161,7 @@ public function testUploadedFileUploadNotAllowedExtensionForMimeType()
$uploadedFile->save(base_dir());
}
- public function testUploadedFileUploadNotAllowedMimeType()
+ public function testUploadedFileUploadNotAllowedMimeType(): void
{
$fileMeta = $this->fileMeta;
$fileMeta['name'] = 'foo.jpg';
@@ -175,7 +175,7 @@ public function testUploadedFileUploadNotAllowedMimeType()
$uploadedFile->save(base_dir());
}
- public function testUploadedFileUploadAllowedAfterSetterOverride()
+ public function testUploadedFileUploadAllowedAfterSetterOverride(): void
{
$fileMeta = $this->fileMeta;
$fileMeta['name'] = 'foo.txt';
@@ -191,7 +191,7 @@ public function testUploadedFileUploadAllowedAfterSetterOverride()
$this->assertTrue(file_exists(base_dir() . DS . $uploadedFile->getNameWithExtension()));
}
- public function testUploadedFileSaveAndTryOverwrite()
+ public function testUploadedFileSaveAndTryOverwrite(): void
{
$uploadedFile = new UploadedDouble($this->fileMeta);
@@ -208,7 +208,7 @@ public function testUploadedFileSaveAndTryOverwrite()
$uploadedFile->save(base_dir());
}
- public function testUploadedFileSaveAndOverwrite()
+ public function testUploadedFileSaveAndOverwrite(): void
{
$uploadedFile = new UploadedDouble($this->fileMeta);
@@ -219,7 +219,7 @@ public function testUploadedFileSaveAndOverwrite()
$this->assertTrue($uploadedFile->save(base_dir(), true));
}
- public function testUploadedFileModifyAndSave()
+ public function testUploadedFileModifyAndSave(): void
{
$uploadedFile = new UploadedDouble($this->fileMeta);
@@ -234,7 +234,7 @@ public function testUploadedFileModifyAndSave()
$this->assertEquals(100, $img[1]);
}
- public function testUploadedFileGetErrorCodeAndMessage()
+ public function testUploadedFileGetErrorCodeAndMessage(): void
{
$fileMeta = [
'size' => 500,
diff --git a/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php b/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php
index ed91828ab..6e30d05aa 100644
--- a/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php
+++ b/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php
@@ -51,7 +51,7 @@ class TransformerHelperFunctionsTest extends AppTestCase
'author' => 'Ken Watson',
],
];
- public function testTransformerHelper()
+ public function testTransformerHelper(): void
{
$transformed = transform($this->posts, new PostTransformer());
diff --git a/tests/Unit/Transformer/PostTransformer.php b/tests/Unit/Transformer/PostTransformer.php
index 5662f6304..b8b2b9aaa 100644
--- a/tests/Unit/Transformer/PostTransformer.php
+++ b/tests/Unit/Transformer/PostTransformer.php
@@ -6,7 +6,7 @@
class PostTransformer implements TransformerInterface
{
- public function transform($item)
+ public function transform($item): array
{
return [
'id' => $item['id'],
diff --git a/tests/Unit/Transformer/TransformerTest.php b/tests/Unit/Transformer/TransformerTest.php
index 5c058087e..e2f7d5a02 100644
--- a/tests/Unit/Transformer/TransformerTest.php
+++ b/tests/Unit/Transformer/TransformerTest.php
@@ -52,7 +52,7 @@ class TransformerTest extends TestCase
],
];
- public function testDataTransforming()
+ public function testDataTransforming(): void
{
$transformed = Transformer::transform($this->posts, new PostTransformer());
diff --git a/tests/Unit/Validation/Traits/FileRuleTest.php b/tests/Unit/Validation/Traits/FileRuleTest.php
index 3e3f8d949..4a3d3ccc5 100644
--- a/tests/Unit/Validation/Traits/FileRuleTest.php
+++ b/tests/Unit/Validation/Traits/FileRuleTest.php
@@ -9,8 +9,8 @@
class FileRuleTest extends AppTestCase
{
- public $validator;
- private $request;
+ public Validator $validator;
+ private Request $request;
public function setUp(): void
{
@@ -39,7 +39,7 @@ public function tearDown(): void
unlink(base_dir() . DS . 'php8fe2.tmp');
}
- public function testRuleFileSize()
+ public function testRuleFileSize(): void
{
$file = [
'image' => [
@@ -72,7 +72,7 @@ public function testRuleFileSize()
$this->assertEquals('validation.fileSize', $errors['image'][0]);
}
- public function testRuleFileMimeType()
+ public function testRuleFileMimeType(): void
{
$file = [
'image' => [
@@ -111,7 +111,7 @@ public function testRuleFileMimeType()
$this->assertEquals('validation.fileMimeType', $errors['image'][0]);
}
- public function testRuleFileExtension()
+ public function testRuleFileExtension(): void
{
$file = [
'image' => [
@@ -150,7 +150,7 @@ public function testRuleFileExtension()
$this->assertEquals('validation.fileExtension', $errors['image'][0]);
}
- public function testRuleImageDimensions()
+ public function testRuleImageDimensions(): void
{
$file = [
'image' => [
diff --git a/tests/Unit/Validation/Traits/GeneralRuleTest.php b/tests/Unit/Validation/Traits/GeneralRuleTest.php
index 0f658de8c..27b75633e 100644
--- a/tests/Unit/Validation/Traits/GeneralRuleTest.php
+++ b/tests/Unit/Validation/Traits/GeneralRuleTest.php
@@ -12,7 +12,7 @@
class GeneralRuleTest extends AppTestCase
{
- public $validator;
+ public Validator $validator;
public function setUp(): void
{
parent::setUp();
@@ -33,7 +33,7 @@ public function tearDown(): void
Database::execute('DROP TABLE IF EXISTS users');
}
- public function testRuleRequired()
+ public function testRuleRequired(): void
{
$this->validator->setRule('text', [
Rule::required(),
@@ -52,7 +52,7 @@ public function testRuleRequired()
$this->assertEquals('validation.required', $errors['text'][0]);
}
- public function testRuleEmail()
+ public function testRuleEmail(): void
{
$this->validator->setRule('text', [
Rule::email(),
@@ -69,7 +69,7 @@ public function testRuleEmail()
$this->assertEquals('validation.email', $errors['text'][0]);
}
- public function testRuleCreditCard()
+ public function testRuleCreditCard(): void
{
$this->validator->setRule('text', [
Rule::creditCard(),
@@ -86,7 +86,7 @@ public function testRuleCreditCard()
$this->assertEquals('validation.creditCard', $errors['text'][0]);
}
- public function testRuleIban()
+ public function testRuleIban(): void
{
$this->validator->setRule('text', [
Rule::iban(),
@@ -105,7 +105,7 @@ public function testRuleIban()
$this->assertEquals('validation.iban', $errors['text'][0]);
}
- public function testRuleName()
+ public function testRuleName(): void
{
$this->validator->setRule('text', [
Rule::name(),
@@ -126,7 +126,7 @@ public function testRuleName()
$this->assertEquals('validation.name', $errors['text'][0]);
}
- public function testRuleStreetAddress()
+ public function testRuleStreetAddress(): void
{
$this->validator->setRule('text', [
Rule::streetAddress(),
@@ -147,7 +147,7 @@ public function testRuleStreetAddress()
$this->assertEquals('validation.streetAddress', $errors['text'][0]);
}
- public function testRulePhoneNumber()
+ public function testRulePhoneNumber(): void
{
$this->validator->setRule('text', [
Rule::phoneNumber(),
@@ -176,7 +176,7 @@ public function testRulePhoneNumber()
$this->assertEquals('validation.phoneNumber', $errors['text'][0]);
}
- public function testRuleDate()
+ public function testRuleDate(): void
{
$this->validator->setRule('text', [
Rule::date(),
@@ -207,7 +207,7 @@ public function testRuleDate()
$this->assertEquals('validation.date', $errors['text'][0]);
}
- public function testRuleStarts()
+ public function testRuleStarts(): void
{
$this->validator->setRule('text', [
Rule::starts('b'),
@@ -230,7 +230,7 @@ public function testRuleStarts()
$this->assertEquals('validation.starts', $errors['text'][0]);
}
- public function testRuleRegex()
+ public function testRuleRegex(): void
{
$this->validator->setRule('text', [
Rule::regex('/^[1-9]+$/'),
@@ -255,7 +255,7 @@ public function testRuleRegex()
$this->assertEquals('validation.regex', $errors['text'][0]);
}
- public function testRuleJsonString()
+ public function testRuleJsonString(): void
{
$this->validator->setRule('text', [
Rule::jsonString(),
@@ -272,7 +272,7 @@ public function testRuleJsonString()
$this->assertEquals('validation.jsonString', $errors['text'][0]);
}
- public function testRuleSame()
+ public function testRuleSame(): void
{
$this->validator->setRule('password', [
Rule::same('confirm_password'),
@@ -289,7 +289,7 @@ public function testRuleSame()
$this->assertEquals('validation.same', $errors['password'][0]);
}
- public function testRuleUnique()
+ public function testRuleUnique(): void
{
$this->createUsersTable();
@@ -310,7 +310,7 @@ public function testRuleUnique()
$this->assertEquals('validation.unique', $errors['username'][0]);
}
- public function testRuleExists()
+ public function testRuleExists(): void
{
$this->createUsersTable();
diff --git a/tests/Unit/Validation/Traits/LengthRuleTest.php b/tests/Unit/Validation/Traits/LengthRuleTest.php
index 9837a441d..2a505454c 100644
--- a/tests/Unit/Validation/Traits/LengthRuleTest.php
+++ b/tests/Unit/Validation/Traits/LengthRuleTest.php
@@ -8,7 +8,7 @@
class LengthRuleTest extends AppTestCase
{
- public $validator;
+ public Validator $validator;
public function setUp(): void
{
@@ -18,7 +18,7 @@ public function setUp(): void
}
- public function testRuleMinLen()
+ public function testRuleMinLen(): void
{
$this->validator->setRule('text', [
Rule::minLen(3),
@@ -35,7 +35,7 @@ public function testRuleMinLen()
$this->assertEquals('validation.minLen', $errors['text'][0]);
}
- public function testRuleMaxLen()
+ public function testRuleMaxLen(): void
{
$this->validator->setRule('text', [
Rule::maxLen(5),
@@ -52,7 +52,7 @@ public function testRuleMaxLen()
$this->assertEquals('validation.maxLen', $errors['text'][0]);
}
- public function testRuleExactLen()
+ public function testRuleExactLen(): void
{
$this->validator->setRule('text', [
Rule::exactLen(4),
diff --git a/tests/Unit/Validation/Traits/ListRuleTest.php b/tests/Unit/Validation/Traits/ListRuleTest.php
index f1dd49512..a47911c51 100644
--- a/tests/Unit/Validation/Traits/ListRuleTest.php
+++ b/tests/Unit/Validation/Traits/ListRuleTest.php
@@ -8,8 +8,7 @@
class ListRuleTest extends AppTestCase
{
- public $validator;
- private $request;
+ public Validator $validator;
public function setUp(): void
{
@@ -19,7 +18,7 @@ public function setUp(): void
}
- public function testRuleContains()
+ public function testRuleContains(): void
{
$this->validator->setRule('text', [
Rule::contains('Fisherman goes out'),
@@ -40,7 +39,7 @@ public function testRuleContains()
$this->assertEquals('validation.contains', $errors['text'][0]);
}
- public function testRuleContainsList()
+ public function testRuleContainsList(): void
{
$this->validator->setRule('text', [
Rule::containsList('male', 'female'),
@@ -59,7 +58,7 @@ public function testRuleContainsList()
$this->assertEquals('validation.containsList', $errors['text'][0]);
}
- public function testRuleDoesntContainsList()
+ public function testRuleDoesntContainsList(): void
{
$this->validator->setRule('text', [
Rule::doesntContainsList('male', 'famale'),
diff --git a/tests/Unit/Validation/Traits/ResourceRuleTest.php b/tests/Unit/Validation/Traits/ResourceRuleTest.php
index b5ee157cf..313bf0820 100644
--- a/tests/Unit/Validation/Traits/ResourceRuleTest.php
+++ b/tests/Unit/Validation/Traits/ResourceRuleTest.php
@@ -8,7 +8,7 @@
class ResourceRuleTest extends AppTestCase
{
- public $validator;
+ public Validator $validator;
public function setUp(): void
{
@@ -18,7 +18,7 @@ public function setUp(): void
}
- public function testRuleUrl()
+ public function testRuleUrl(): void
{
$this->validator->setRule('text', [
Rule::url(),
@@ -39,7 +39,7 @@ public function testRuleUrl()
$this->assertEquals('validation.url', $errors['text'][0]);
}
- public function testRuleUrlExists()
+ public function testRuleUrlExists(): void
{
$this->validator->setRule('text', [
Rule::urlExists(),
@@ -56,7 +56,7 @@ public function testRuleUrlExists()
$this->assertEquals('validation.urlExists', $errors['text'][0]);
}
- public function testRuleIp()
+ public function testRuleIp(): void
{
$this->validator->setRule('text', [
Rule::ip(),
@@ -73,7 +73,7 @@ public function testRuleIp()
$this->assertEquals('validation.ip', $errors['text'][0]);
}
- public function testRuleIpV4()
+ public function testRuleIpV4(): void
{
$this->validator->setRule('text', [
Rule::ipv4(),
@@ -90,7 +90,7 @@ public function testRuleIpV4()
$this->assertEquals('validation.ipv4', $errors['text'][0]);
}
- public function testRuleIpV6()
+ public function testRuleIpV6(): void
{
$this->validator->setRule('text', [
Rule::ipv6(),
diff --git a/tests/Unit/Validation/Traits/TypeRuleTest.php b/tests/Unit/Validation/Traits/TypeRuleTest.php
index d2a2ce052..75ae1cce1 100644
--- a/tests/Unit/Validation/Traits/TypeRuleTest.php
+++ b/tests/Unit/Validation/Traits/TypeRuleTest.php
@@ -8,7 +8,7 @@
class TypeRuleTest extends AppTestCase
{
- public $validator;
+ public Validator $validator;
public function setUp(): void
{
parent::setUp();
@@ -16,7 +16,7 @@ public function setUp(): void
$this->validator = new Validator();
}
- public function testRuleAlpha()
+ public function testRuleAlpha(): void
{
$this->validator->setRule('text', [
Rule::alpha(),
@@ -35,7 +35,7 @@ public function testRuleAlpha()
$this->assertEquals('validation.alpha', $errors['text'][0]);
}
- public function testRuleAlphaNumeric()
+ public function testRuleAlphaNumeric(): void
{
$this->validator->setRule('text', [
Rule::alphaNumeric(),
@@ -56,7 +56,7 @@ public function testRuleAlphaNumeric()
$this->assertEquals('validation.alphaNumeric', $errors['text'][0]);
}
- public function testRuleAlphaDash()
+ public function testRuleAlphaDash(): void
{
$this->validator->setRule('text', [
Rule::alphaDash(),
@@ -75,7 +75,7 @@ public function testRuleAlphaDash()
$this->assertEquals('validation.alphaDash', $errors['text'][0]);
}
- public function testRuleAlphaSpace()
+ public function testRuleAlphaSpace(): void
{
$this->validator->setRule('text', [
Rule::alphaSpace(),
@@ -96,7 +96,7 @@ public function testRuleAlphaSpace()
$this->assertEquals('validation.alphaSpace', $errors['text'][0]);
}
- public function testRuleNumeric()
+ public function testRuleNumeric(): void
{
$this->validator->setRule('text', [
Rule::numeric(),
@@ -115,7 +115,7 @@ public function testRuleNumeric()
$this->assertEquals('validation.numeric', $errors['text'][0]);
}
- public function testRuleInteger()
+ public function testRuleInteger(): void
{
$this->validator->setRule('text', [
Rule::integer(),
@@ -134,7 +134,7 @@ public function testRuleInteger()
$this->assertEquals('validation.integer', $errors['text'][0]);
}
- public function testRuleFloat()
+ public function testRuleFloat(): void
{
$this->validator->setRule('text', [
Rule::float(),
@@ -155,7 +155,7 @@ public function testRuleFloat()
$this->assertEquals('validation.float', $errors['text'][0]);
}
- public function testRuleBoolean()
+ public function testRuleBoolean(): void
{
$this->validator->setRule('text', [
Rule::boolean(),
@@ -182,7 +182,7 @@ public function testRuleBoolean()
$this->assertEquals('validation.boolean', $errors['text'][0]);
}
- public function testRuleMinNumeric()
+ public function testRuleMinNumeric(): void
{
$this->validator->setRule('text', [
Rule::minNumeric(20),
@@ -199,7 +199,7 @@ public function testRuleMinNumeric()
$this->assertEquals('validation.minNumeric', $errors['text'][0]);
}
- public function testRuleMaxNumeric()
+ public function testRuleMaxNumeric(): void
{
$this->validator->setRule('text', [
Rule::maxNumeric(20),
diff --git a/tests/Unit/Validation/ValidatorTest.php b/tests/Unit/Validation/ValidatorTest.php
index 82659c243..503647b0d 100644
--- a/tests/Unit/Validation/ValidatorTest.php
+++ b/tests/Unit/Validation/ValidatorTest.php
@@ -8,7 +8,7 @@
class ValidatorTest extends AppTestCase
{
- private $validator;
+ private Validator $validator;
public function setUp(): void
{
@@ -17,12 +17,12 @@ public function setUp(): void
$this->validator = new Validator();
}
- public function testValidatorConstructor()
+ public function testValidatorConstructor(): void
{
$this->assertInstanceOf(Validator::class, $this->validator);
}
- public function testAddUpdateDeleteRule()
+ public function testAddUpdateDeleteRule(): void
{
$this->validator->setRule('text', [
Rule::minLen(5),
@@ -46,7 +46,7 @@ public function testAddUpdateDeleteRule()
$this->assertTrue($this->validator->isValid(['text' => 'some long text goes']));
}
- public function testMultipleRules()
+ public function testMultipleRules(): void
{
$this->validator->setRule('text', [
Rule::minLen(7),
@@ -75,7 +75,7 @@ public function testMultipleRules()
$this->assertEquals('validation.maxLen', $errors['text'][0]);
}
- public function testMultipleFields()
+ public function testMultipleFields(): void
{
$this->validator->setRules([
'name' => [
@@ -134,7 +134,7 @@ public function testMultipleFields()
$this->assertFalse($this->validator->isValid($data));
}
- public function testDifferentMultipleFields()
+ public function testDifferentMultipleFields(): void
{
$this->validator->setRules([
'name' => [
@@ -166,9 +166,9 @@ public function testDifferentMultipleFields()
$this->assertTrue($this->validator->isValid($data));
}
- public function testCustomValidator()
+ public function testCustomValidator(): void
{
- $this->validator->addRule('checkName', fn ($value, $param = null) => $value == $param);
+ $this->validator->addRule('checkName', fn ($value, $param = null): bool => $value == $param);
$this->validator->setRules([
'name' => [
diff --git a/tests/Unit/View/Factories/ViewFactoryTest.php b/tests/Unit/View/Factories/ViewFactoryTest.php
index 92b033230..e87edf72b 100644
--- a/tests/Unit/View/Factories/ViewFactoryTest.php
+++ b/tests/Unit/View/Factories/ViewFactoryTest.php
@@ -8,7 +8,7 @@
class ViewFactoryTest extends AppTestCase
{
- private $viewFactory;
+ private ViewFactory $viewFactory;
public function setUp(): void
{
@@ -17,12 +17,12 @@ public function setUp(): void
$this->viewFactory = new ViewFactory();
}
- public function testGetInstance()
+ public function testGetInstance(): void
{
$this->assertInstanceOf(QtView::class, $this->viewFactory->get());
}
- public function testProxyCalls()
+ public function testProxyCalls(): void
{
$view = $this->viewFactory->get();
diff --git a/tests/Unit/View/Helpers/ViewHelperTest.php b/tests/Unit/View/Helpers/ViewHelperTest.php
index 7b0b29d0c..ca3e0790d 100644
--- a/tests/Unit/View/Helpers/ViewHelperTest.php
+++ b/tests/Unit/View/Helpers/ViewHelperTest.php
@@ -8,10 +8,11 @@
use Quantum\Http\Request;
use Quantum\Di\Di;
use Quantum\Tests\Unit\AppTestCase;
+use Quantum\View\QtView;
class ViewHelperTest extends AppTestCase
{
- private $view;
+ private QtView $view;
public function setUp(): void
{
@@ -21,8 +22,7 @@ public function setUp(): void
['GET', 'POST'],
'/test',
'TestController',
- 'testAction',
- null
+ 'testAction'
);
$route->module('Test');
@@ -40,7 +40,7 @@ public function tearDown(): void
$this->view->setLayout(null);
}
- public function testView()
+ public function testView(): void
{
$this->view->setLayout('layout');
@@ -49,7 +49,7 @@ public function testView()
$this->assertEquals('Hello World, this is rendered html view
', view());
}
- public function testPartial()
+ public function testPartial(): void
{
$this->assertEquals('Hello World, this is rendered partial html view
', partial('partial'));
diff --git a/tests/Unit/View/QtViewTest.php b/tests/Unit/View/QtViewTest.php
index 766270b69..d1d181f5b 100644
--- a/tests/Unit/View/QtViewTest.php
+++ b/tests/Unit/View/QtViewTest.php
@@ -6,6 +6,7 @@
use Quantum\View\Factories\ViewFactory;
use Quantum\Tests\Unit\AppTestCase;
use Quantum\Router\MatchedRoute;
+use Quantum\View\QtView;
use Quantum\View\RawParam;
use Quantum\Router\Route;
use Quantum\Http\Request;
@@ -13,7 +14,7 @@
class QtViewTest extends AppTestCase
{
- private $view;
+ private QtView $view;
public function setUp(): void
{
@@ -23,8 +24,7 @@ public function setUp(): void
['GET'],
'/test',
'SomeController',
- 'test',
- null
+ 'test'
);
$route->module('Test');
@@ -45,7 +45,7 @@ public function tearDown(): void
$this->view->flushParams();
}
- public function testSetGetLayout()
+ public function testSetGetLayout(): void
{
$this->assertNull($this->view->getLayout());
@@ -56,7 +56,7 @@ public function testSetGetLayout()
$this->assertIsString($this->view->getLayout());
}
- public function testSetGetParams()
+ public function testSetGetParams(): void
{
$this->assertEmpty($this->view->getParams());
@@ -75,7 +75,7 @@ public function testSetGetParams()
$this->assertNotEmpty($this->view->getParams());
}
- public function testSetGetRawParams()
+ public function testSetGetRawParams(): void
{
$this->assertEmpty($this->view->getParams());
@@ -103,7 +103,7 @@ public function testSetGetRawParams()
$this->assertEquals('Monkey people
', $this->view->getParam('chapter_two'));
}
- public function testRenderWithoutLayout()
+ public function testRenderWithoutLayout(): void
{
$this->expectException(ViewException::class);
@@ -112,7 +112,7 @@ public function testRenderWithoutLayout()
$this->view->render('index');
}
- public function testRenderWithLayout()
+ public function testRenderWithLayout(): void
{
$this->view->setLayout('layout');
@@ -123,7 +123,7 @@ public function testRenderWithLayout()
$this->assertEquals('' . PHP_EOL . '' . PHP_EOL . '' . PHP_EOL . 'Hello World, this is rendered html view
' . PHP_EOL . '' . PHP_EOL, $renderedView);
}
- public function testRenderWithData()
+ public function testRenderWithData(): void
{
$this->view->setLayout('layout');
@@ -138,7 +138,7 @@ public function testRenderWithData()
$this->assertEquals('Hello dolor sit amet, this is rendered html view
', $this->view->getView());
}
- public function testRenderWithEscapedHtmlData()
+ public function testRenderWithEscapedHtmlData(): void
{
$this->view->setLayout('layout');
@@ -149,7 +149,7 @@ public function testRenderWithEscapedHtmlData()
$this->assertEquals('<h1>Hello</h1>', $this->view->getView());
}
- public function testRenderWithUnEscapedHtmlData()
+ public function testRenderWithUnEscapedHtmlData(): void
{
$this->view->setLayout('layout');
@@ -160,7 +160,7 @@ public function testRenderWithUnEscapedHtmlData()
$this->assertEquals('Hello
', $this->view->getView());
}
- public function testRenderPartial()
+ public function testRenderPartial(): void
{
$this->assertIsString($this->view->renderPartial('partial'));
diff --git a/tests/Unit/View/RawParamTest.php b/tests/Unit/View/RawParamTest.php
index df5523b6b..f10e8f4e6 100644
--- a/tests/Unit/View/RawParamTest.php
+++ b/tests/Unit/View/RawParamTest.php
@@ -7,39 +7,39 @@
class RawParamTest extends AppTestCase
{
- public function testStoresAndReturnsString()
+ public function testStoresAndReturnsString(): void
{
$raw = new RawParam('test');
$this->assertSame('test', $raw->getValue());
}
- public function testStoresAndReturnsInteger()
+ public function testStoresAndReturnsInteger(): void
{
$raw = new RawParam(123);
$this->assertSame(123, $raw->getValue());
}
- public function testStoresAndReturnsArray()
+ public function testStoresAndReturnsArray(): void
{
$value = ['key' => 'value'];
$raw = new RawParam($value);
$this->assertSame($value, $raw->getValue());
}
- public function testStoresAndReturnsObject()
+ public function testStoresAndReturnsObject(): void
{
$value = (object) ['foo' => 'bar'];
$raw = new RawParam($value);
$this->assertSame($value, $raw->getValue());
}
- public function testStoresAndReturnsNull()
+ public function testStoresAndReturnsNull(): void
{
$raw = new RawParam(null);
$this->assertNull($raw->getValue());
}
- public function testStoresAndReturnsBoolean()
+ public function testStoresAndReturnsBoolean(): void
{
$rawTrue = new RawParam(true);
$rawFalse = new RawParam(false);
diff --git a/tests/_root/modules/Test/Controllers/TestController.php b/tests/_root/modules/Test/Controllers/TestController.php
index 17e48e18a..bf5079b6a 100644
--- a/tests/_root/modules/Test/Controllers/TestController.php
+++ b/tests/_root/modules/Test/Controllers/TestController.php
@@ -4,7 +4,7 @@
class TestController
{
- public function tests()
+ public function tests(): void
{
//
}
diff --git a/tests/_root/modules/Test/routes/routes.php b/tests/_root/modules/Test/routes/routes.php
index a5cd9152d..cf056a4e0 100644
--- a/tests/_root/modules/Test/routes/routes.php
+++ b/tests/_root/modules/Test/routes/routes.php
@@ -1,6 +1,6 @@
get('[:alpha:2]?/tests', 'TestController', 'tests');
$route->get('[:alpha:2]?/Test/[id=:any]', 'TestController', 'test');
};
diff --git a/tests/_root/shared/Commands/TestCommand.php b/tests/_root/shared/Commands/TestCommand.php
index 267a00ad9..d7f72e645 100644
--- a/tests/_root/shared/Commands/TestCommand.php
+++ b/tests/_root/shared/Commands/TestCommand.php
@@ -6,19 +6,19 @@
class TestCommand extends QtCommand
{
- protected $name = 'test:dummy';
- protected $description = 'Dummy test command';
- protected $help = 'Used only for core command discovery tests';
+ protected ?string $name = 'test:dummy';
+ protected ?string $description = 'Dummy test command';
+ protected ?string $help = 'Used only for core command discovery tests';
- protected $args = [
+ protected array $args = [
['uuid', 'optional', 'User uuid'],
];
- protected $options = [
+ protected array $options = [
['force', 'f', 'none', 'Force execution'],
];
- public function exec()
+ public function exec(): void
{
// intentionally empty
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 4fa5639eb..8f8fefceb 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -16,6 +16,6 @@
createEnvFile();
-register_shutdown_function(function () {
+register_shutdown_function(function (): void {
removeEnvFile();
});