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
@@ -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();
}