chore: add and run phpstan phpunit

This commit is contained in:
Younes ENNAJI
2024-05-27 00:34:47 +01:00
parent a820277f25
commit b28525d718
61 changed files with 190 additions and 19 deletions
+3 -2
View File
@@ -35,11 +35,12 @@
"php-cs-fixer/shim": "^3.57.2",
"phpstan/phpstan": "^1.11.2",
"phpstan/phpstan-mockery": "^1.1.2",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-symfony": "^1.4.1",
"phpunit/phpunit": "^10.5.13",
"phpunit/phpunit": "^10.5.20",
"psr/container": "^1.1|^2.0",
"rector/rector": "^1.1.0",
"rector/swiss-knife": "^0.2.3",
"rector/swiss-knife": "^0.2.6",
"symfony/config": "^7.0",
"symfony/console": "^7.0",
"symfony/dependency-injection": "^7.0",
Generated
+66 -14
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7e78d762177a41a7c6e4daab644b5e32",
"content-hash": "6277b51593db73ef534b68b04ddc8f13",
"packages": [],
"packages-dev": [
{
@@ -3852,6 +3852,58 @@
},
"time": "2024-01-10T13:50:05+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "f3ea021866f4263f07ca3636bf22c64be9610c11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f3ea021866f4263f07ca3636bf22c64be9610c11",
"reference": "f3ea021866f4263f07ca3636bf22c64be9610c11",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.11"
},
"conflict": {
"phpunit/phpunit": "<7.0"
},
"require-dev": {
"nikic/php-parser": "^4.13.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpunit/phpunit": "^9.5"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"extension.neon",
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPUnit extensions and rules for PHPStan",
"support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.0"
},
"time": "2024-04-20T06:39:00+00:00"
},
{
"name": "phpstan/phpstan-symfony",
"version": "1.4.1",
@@ -4245,16 +4297,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.5.13",
"version": "10.5.20",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "20a63fc1c6db29b15da3bd02d4b6cf59900088a7"
"reference": "547d314dc24ec1e177720d45c6263fb226cc2ae3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/20a63fc1c6db29b15da3bd02d4b6cf59900088a7",
"reference": "20a63fc1c6db29b15da3bd02d4b6cf59900088a7",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/547d314dc24ec1e177720d45c6263fb226cc2ae3",
"reference": "547d314dc24ec1e177720d45c6263fb226cc2ae3",
"shasum": ""
},
"require": {
@@ -4326,7 +4378,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.13"
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.20"
},
"funding": [
{
@@ -4342,7 +4394,7 @@
"type": "tidelift"
}
],
"time": "2024-03-12T15:37:41+00:00"
"time": "2024-04-24T06:32:35+00:00"
},
{
"name": "psr/cache",
@@ -5160,16 +5212,16 @@
},
{
"name": "rector/swiss-knife",
"version": "0.2.3",
"version": "0.2.6",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/swiss-knife.git",
"reference": "618ffe570d2a5316adf9cdab092e789c7f7b0bce"
"reference": "aa076d88df0020266502d014f8b414e43b4b5da4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/swiss-knife/zipball/618ffe570d2a5316adf9cdab092e789c7f7b0bce",
"reference": "618ffe570d2a5316adf9cdab092e789c7f7b0bce",
"url": "https://api.github.com/repos/rectorphp/swiss-knife/zipball/aa076d88df0020266502d014f8b414e43b4b5da4",
"reference": "aa076d88df0020266502d014f8b414e43b4b5da4",
"shasum": ""
},
"require": {
@@ -5186,7 +5238,7 @@
"description": "Swiss knife in pocket of every upgrade architect",
"support": {
"issues": "https://github.com/rectorphp/swiss-knife/issues",
"source": "https://github.com/rectorphp/swiss-knife/tree/0.2.3"
"source": "https://github.com/rectorphp/swiss-knife/tree/0.2.6"
},
"funding": [
{
@@ -5198,7 +5250,7 @@
"type": "github"
}
],
"time": "2024-05-10T07:38:18+00:00"
"time": "2024-05-26T02:44:18+00:00"
},
{
"name": "sebastian/cli-parser",
@@ -10756,7 +10808,7 @@
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": true,
"prefer-lowest": true,
"prefer-lowest": false,
"platform": {
"php": ">=8.2",
"ext-intl": "*"
+1 -1
View File
@@ -2015,7 +2015,7 @@
},
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
"version": "1.3.0",
"extraneous": true,
"dev": true,
"inBundle": true,
"license": "MIT",
"engines": {
+5
View File
@@ -5,6 +5,8 @@ includes:
- vendor/phpstan/phpstan-symfony/rules.neon
- vendor/larastan/larastan/extension.neon
- vendor/phpstan/phpstan-mockery/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
parameters:
level: 9
@@ -14,3 +16,6 @@ parameters:
- tests/
tmpDir: .cache/phpstan
ignoreErrors:
- '#Call to method .+ with .+ will always evaluate to true.#'
@@ -21,6 +21,8 @@ final class FlasherComponentTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$flasherServiceMock = \Mockery::mock(FlasherInterface::class);
$flasherServiceMock->allows('render')
->andReturns('Your expected result');
+2
View File
@@ -19,6 +19,8 @@ final class RequestTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->laravelRequestMock = \Mockery::mock(LaravelRequest::class);
}
+2
View File
@@ -21,6 +21,8 @@ final class ResponseTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->responseHeaderBagMock = \Mockery::mock(ResponseHeaderBag::class);
$this->responseMock = \Mockery::mock(LaravelResponse::class);
@@ -24,6 +24,8 @@ final class FlasherMiddlewareTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->responseExtensionMock = \Mockery::mock(ResponseExtensionInterface::class);
$this->middleware = new FlasherMiddleware($this->responseExtensionMock);
}
@@ -30,6 +30,8 @@ final class SessionMiddlewareTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->requestExtensionMock = \Mockery::mock(RequestExtensionInterface::class);
$this->sessionMiddleware = new SessionMiddleware($this->requestExtensionMock);
}
+2
View File
@@ -23,6 +23,8 @@ final class SessionBagTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->sessionManagerMock = \Mockery::mock(SessionManager::class);
$this->sessionBag = new SessionBag($this->sessionManagerMock);
}
@@ -18,6 +18,8 @@ final class TranslatorTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->laravelTranslatorMock = \Mockery::mock(LaravelTranslator::class);
}
@@ -21,6 +21,8 @@ final class FlasherNotyServiceProviderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->app = \Mockery::mock(Application::class);
$this->serviceProvider = new FlasherNotyServiceProvider($this->app);
}
+2
View File
@@ -14,6 +14,8 @@ final class NotyBuilderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$storageManagerMock = \Mockery::mock(StorageManagerInterface::class);
$this->notyBuilder = new NotyBuilder('noty', $storageManagerMock);
}
+2
View File
@@ -15,6 +15,8 @@ final class NotyPluginTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->notyPlugin = new NotyPlugin();
}
@@ -18,6 +18,8 @@ final class FlasherNotySymfonyBundleTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->flasherNotyBundle = new FlasherNotySymfonyBundle();
}
@@ -21,6 +21,8 @@ final class FlasherNotyfServiceProviderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->app = \Mockery::mock(Application::class);
$this->serviceProvider = new FlasherNotyfServiceProvider($this->app);
}
+2
View File
@@ -14,6 +14,8 @@ final class NotyfBuilderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$storageManagerMock = \Mockery::mock(StorageManagerInterface::class);
$this->notyfBuilder = new NotyfBuilder('notyf', $storageManagerMock);
}
+2
View File
@@ -15,6 +15,8 @@ final class NotyfPluginTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->notyfPlugin = new NotyfPlugin();
}
@@ -18,6 +18,8 @@ final class FlasherNotyfSymfonyBundleTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->flasherNotyfBundle = new FlasherNotyfSymfonyBundle();
}
+4
View File
@@ -14,12 +14,16 @@ final class AssetManagerTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->publicDir = __DIR__.'/../Fixtures/Asset';
$this->manifestPath = __DIR__.'/../Fixtures/Asset/manifest.json';
}
protected function tearDown(): void
{
parent::tearDown();
if (file_exists($this->manifestPath)) {
unlink($this->manifestPath);
}
@@ -14,6 +14,8 @@ final class FlasherContainerTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
// Reset the FlasherContainer instance to ensure isolation between tests
FlasherContainer::reset();
}
@@ -19,6 +19,8 @@ final class EventDispatcherTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->dispatcher = new EventDispatcher();
}
+2
View File
@@ -26,6 +26,8 @@ final class FlasherTest extends MockeryTestCase
protected function setUp(): void
{
parent::setUp();
$this->factoryLocatorMock = \Mockery::mock(NotificationFactoryLocatorInterface::class);
$this->responseManagerMock = \Mockery::mock(ResponseManagerInterface::class);
$this->storageManagerMock = \Mockery::mock(StorageManagerInterface::class);
@@ -26,6 +26,8 @@ final class ContentSecurityPolicyHandlerTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->nonceGeneratorMock = $this->createMock(NonceGeneratorInterface::class);
$this->requestMock = $this->createMock(RequestInterface::class);
$this->responseMock = $this->createMock(ResponseInterface::class);
@@ -18,6 +18,8 @@ final class NonceGeneratorTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->nonceGenerator = new NonceGenerator();
}
@@ -30,6 +30,8 @@ final class RequestExtensionTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->flasher = \Mockery::mock(FlasherInterface::class);
$this->request = \Mockery::mock(RequestInterface::class);
$this->response = \Mockery::mock(ResponseInterface::class);
@@ -259,6 +259,7 @@ final class EnvelopeTest extends TestCase
$envelope = new Envelope($notification, new PluginStamp('flasher'));
// @phpstan-ignore-next-line
$this->assertSame([
'title' => 'PHPFlasher',
'message' => 'success message',
@@ -519,8 +519,6 @@ final class FlasherBuilderTest extends TestCase
/**
* @phpstan-param MockObject|StorageManagerInterface $storageManager
*
* @phpstan-ignore-next-line
*/
private function getNotificationBuilder(?StorageManagerInterface $storageManager = null): NotificationBuilderInterface
{
+2
View File
@@ -17,6 +17,8 @@ final class CreatedAtStampTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->time = new \DateTimeImmutable('2023-01-01 12:00:00');
$this->format = 'Y-m-d H:i:s';
$this->createdAtStamp = new CreatedAtStamp($this->time, $this->format);
+2
View File
@@ -14,6 +14,8 @@ final class DelayStampTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->testDelay = 100;
$this->instance = new DelayStamp($this->testDelay);
}
+2
View File
@@ -14,6 +14,8 @@ final class HtmlStampTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->htmlString = '<div>Hello World</div>';
$this->htmlStamp = new HtmlStamp($this->htmlString);
}
+2
View File
@@ -15,6 +15,8 @@ final class ArrayBagTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->bag = new ArrayBag();
}
@@ -15,6 +15,8 @@ final class StaticBagTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->staticBag = new StaticBag();
}
@@ -17,6 +17,8 @@ final class FilterFactoryTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->filterFactory = new FilterFactory();
}
@@ -17,6 +17,8 @@ final class FilterTest extends MockeryTestCase
protected function setUp(): void
{
parent::setUp();
$this->filter = new Filter();
}
@@ -36,6 +36,8 @@ final class StorageManagerTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->storageMock = \Mockery::mock(StorageInterface::class);
$this->filterFactoryMock = \Mockery::mock(FilterFactoryInterface::class);
$this->eventDispatcherMock = \Mockery::mock(EventDispatcherInterface::class);
+2
View File
@@ -17,6 +17,8 @@ final class StorageTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->storage = new Storage(new ArrayBag());
}
@@ -13,6 +13,8 @@ final class PHPTemplateEngineTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->templateEngine = new PHPTemplateEngine();
}
@@ -13,6 +13,8 @@ final class EchoTranslatorTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->translator = new EchoTranslator();
}
@@ -21,6 +21,8 @@ final class FlasherSweetAlertServiceProviderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->app = \Mockery::mock(Application::class);
$this->serviceProvider = new FlasherSweetAlertServiceProvider($this->app);
}
@@ -16,6 +16,8 @@ final class SweetAlertBuilderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->storageManagerMock = \Mockery::mock(StorageManagerInterface::class);
$this->sweetAlertBuilder = new SweetAlertBuilder('sweetAlert', $this->storageManagerMock);
}
@@ -15,6 +15,8 @@ final class SweetAlertPluginTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->sweetAlertPlugin = new SweetAlertPlugin();
}
@@ -18,6 +18,8 @@ final class FlasherSweetAlertSymfonyBundleTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->flasherSweetAlertBundle = new FlasherSweetAlertSymfonyBundle();
}
@@ -16,6 +16,8 @@ final class InstallCommandTest extends MockeryTestCase
protected function setUp(): void
{
parent::setUp();
$kernel = new FlasherKernel();
$kernel->boot();
@@ -21,6 +21,8 @@ final class EventListenerCompilerPassTest extends MockeryTestCase
protected function setUp(): void
{
parent::setUp();
$this->compilerPass = new EventListenerCompilerPass();
$this->container = new ContainerBuilder();
}
@@ -17,6 +17,8 @@ final class PresenterCompilerPassTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->compilerPass = new PresenterCompilerPass();
$this->container = new ContainerBuilder();
}
@@ -17,6 +17,8 @@ final class FlasherExtensionTest extends MockeryTestCase
protected function setUp(): void
{
parent::setUp();
$this->container = new ContainerBuilder();
$this->extension = new FlasherExtension(new FlasherPlugin());
@@ -25,6 +25,8 @@ final class FlasherListenerTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->responseExtensionMock = \Mockery::mock(ResponseExtensionInterface::class);
$this->flasherListener = new FlasherListener($this->responseExtensionMock);
}
@@ -25,6 +25,8 @@ final class SessionListenerTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->requestExtensionMock = \Mockery::mock(RequestExtensionInterface::class);
$this->sessionListener = new SessionListener($this->requestExtensionMock);
}
@@ -22,6 +22,8 @@ final class NotificationFactoryLocatorTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->serviceLocatorMock = \Mockery::mock(ServiceLocator::class);
$this->notificationFactoryLocator = new NotificationFactoryLocator($this->serviceLocatorMock);
}
@@ -20,6 +20,8 @@ final class FlasherSymfonyBundleTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->flasherBundle = new FlasherSymfonyBundle();
}
+2
View File
@@ -26,6 +26,8 @@ final class RequestTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->symfonyRequestMock = \Mockery::mock(SymfonyRequest::class);
}
+2
View File
@@ -21,6 +21,8 @@ final class ResponseTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->responseHeaderBagMock = \Mockery::mock(ResponseHeaderBag::class);
$this->responseMock = \Mockery::mock(SymfonyResponse::class);
@@ -17,6 +17,8 @@ final class FallbackSessionTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->session = new FallbackSession();
}
+2
View File
@@ -27,6 +27,8 @@ final class SessionBagTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->requestStackMock = \Mockery::mock(RequestStack::class);
$this->fallbackSessionMock = \Mockery::mock(FallbackSessionInterface::class);
$this->sessionBag = new SessionBag($this->requestStackMock, $this->fallbackSessionMock);
@@ -20,6 +20,8 @@ final class TranslatorTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->symfonyTranslatorMock = \Mockery::mock(SymfonyTranslatorInterface::class);
if (interface_exists(TranslatorBagInterface::class)) {
$this->symfonyTranslatorMock->allows('getCatalogue')->andReturnUndefined();
@@ -21,12 +21,16 @@ final class FlasherTwigExtensionTest extends MockeryTestCase
protected function setUp(): void
{
parent::setUp();
$this->flasher = \Mockery::mock(FlasherInterface::class);
$this->extension = new FlasherTwigExtension($this->flasher);
}
protected function tearDown(): void
{
parent::tearDown();
\Mockery::close();
}
@@ -21,6 +21,8 @@ final class FlasherToastrServiceProviderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->app = \Mockery::mock(Application::class);
$this->serviceProvider = new FlasherToastrServiceProvider($this->app);
}
+2
View File
@@ -14,6 +14,8 @@ final class ToastrBuilderTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$storageManagerMock = \Mockery::mock(StorageManagerInterface::class);
$this->toastrBuilder = new ToastrBuilder('toastr', $storageManagerMock);
}
+2
View File
@@ -15,6 +15,8 @@ final class ToastrPluginTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->toastrPlugin = new ToastrPlugin();
}
@@ -18,6 +18,8 @@ final class FlasherToastrSymfonyBundleTest extends TestCase
protected function setUp(): void
{
parent::setUp();
$this->flasherToastrBundle = new FlasherToastrSymfonyBundle();
}