From ee9374862ef62c197046a4448cea1f9fe298cea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radim=20Vaculi=CC=81k?= Date: Sat, 4 May 2024 22:30:36 +0200 Subject: [PATCH] PHPStan for `tests` folder --- composer.json | 1 + phpstan.neon | 2 ++ ...DataSourceTest.php => DoctrineCollectionDataSourceTest.phpt} | 0 tests/Files/TestPresenter.php | 1 + tests/Files/TestingDatagridFactory.php | 2 ++ tests/Files/TestingDatagridFactoryRouter.php | 2 ++ 6 files changed, 8 insertions(+) rename tests/Cases/DataSources/{DoctrineCollectionDataSourceTest.php => DoctrineCollectionDataSourceTest.phpt} (100%) diff --git a/composer.json b/composer.json index 056ade19..1d1760be 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,7 @@ "nextras/dbal": "^4.0", "nextras/orm": "^4.0", "phpstan/phpstan-deprecation-rules": "^1.1", + "phpstan/phpstan-mockery": "^1.1", "phpstan/phpstan-nette": "^1.0.0", "phpstan/phpstan-strict-rules": "^1.4", "tharos/leanmapper": "^3.4.2 || ^4.0.0", diff --git a/phpstan.neon b/phpstan.neon index 0d42c566..d31dcdd8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,12 +3,14 @@ includes: - vendor/phpstan/phpstan-nette/extension.neon - vendor/phpstan/phpstan-nette/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon + - vendor/phpstan/phpstan-mockery/extension.neon parameters: level: 8 paths: - src + - tests checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false diff --git a/tests/Cases/DataSources/DoctrineCollectionDataSourceTest.php b/tests/Cases/DataSources/DoctrineCollectionDataSourceTest.phpt similarity index 100% rename from tests/Cases/DataSources/DoctrineCollectionDataSourceTest.php rename to tests/Cases/DataSources/DoctrineCollectionDataSourceTest.phpt diff --git a/tests/Files/TestPresenter.php b/tests/Files/TestPresenter.php index 148e9ee2..9cbfc5cf 100644 --- a/tests/Files/TestPresenter.php +++ b/tests/Files/TestPresenter.php @@ -16,6 +16,7 @@ protected function createComponentGrid(): TestGridControl protected function createTemplate(?string $class = null): Template { + // @phpstan-ignore-next-line return Mockery::mock(Template::class) ->shouldReceive('getFile') ->andReturn(__DIR__ . '/template.latte') diff --git a/tests/Files/TestingDatagridFactory.php b/tests/Files/TestingDatagridFactory.php index e200e312..18c575c4 100644 --- a/tests/Files/TestingDatagridFactory.php +++ b/tests/Files/TestingDatagridFactory.php @@ -4,6 +4,7 @@ use Contributte\Datagrid\Datagrid; use Nette\Application\PresenterFactory; +use Nette\Application\UI\Presenter; use Nette\Http\Request; use Nette\Http\Response; use Nette\Http\Session; @@ -17,6 +18,7 @@ public function createTestingDatagrid(string $presenterName = 'Testing'): Datagr $presenterFactory = new PresenterFactory(); $presenterFactory->setMapping(['*' => 'Contributte\Datagrid\Tests\Files\*Presenter']); + /** @var Presenter $presenter */ $presenter = $presenterFactory->createPresenter($presenterName); $url = new UrlScript('http://localhost'); diff --git a/tests/Files/TestingDatagridFactoryRouter.php b/tests/Files/TestingDatagridFactoryRouter.php index 197ea528..58a6c2f9 100644 --- a/tests/Files/TestingDatagridFactoryRouter.php +++ b/tests/Files/TestingDatagridFactoryRouter.php @@ -5,6 +5,7 @@ use Nette\Application\PresenterFactory; use Nette\Application\Request; use Nette\Application\Routers\SimpleRouter; +use Nette\Application\UI\Presenter; use Nette\ComponentModel\IComponent; use Nette\Http\Request as HttpRequest; use Nette\Http\Response; @@ -19,6 +20,7 @@ public function createTestingDatagrid(): ?IComponent $presenterFactory = new PresenterFactory(); $presenterFactory->setMapping(['*' => 'Contributte\Datagrid\Tests\Files\*Presenter']); + /** @var Presenter $presenter */ $presenter = $presenterFactory->createPresenter('Test'); $url = new UrlScript('http://localhost/index.php');