-
Notifications
You must be signed in to change notification settings - Fork 28
PHPStan improvements #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPStan improvements #100
Changes from 2 commits
ff64b4e
e4f3f1e
54126b5
a8c2fb2
efcc5de
613d036
a64cf16
9a9d3e2
8e296ed
786d9b7
a1950ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,9 @@ | |
|
|
||
| class FixturesKernel implements HttpKernelInterface | ||
| { | ||
| public const WEB_FIXTURES_DIR = __DIR__ . '/../web-fixtures'; | ||
| public const KERNEL_FIXTURES_DIR = __DIR__ . '/../http-kernel-fixtures'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why making those public constants ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was the main point actually, so that code needing those paths:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are values of these constants used anywhere else outside of this class?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes (WEB_FIXTURES is used by FixturesKernel, GeneralTest and ChangeEventTest), testcases can use them when they need to use a specific fixture. KERNEL_FIXTURES isn't used elsewhere in this case, it's not entirely clear to me where/when it is needed, but it feels like it should be public too.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kernel fixtures doesn't seem to be used outside at all: https://github.com/search?q=%22%2Fhttp-kernel-fixtures%22&type=code Web fixtures is used also by users:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what mink-panther-driver does is a huge hack though. They are altering the shared testsuite, meaning that what they run is not actually the shared testsuite (and so their driver might not respect the expected shared behavior, creating interoperability issues). I don't think we should consider this a valid use case.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a hack, yes, but the intention is clear - they want to extend tests, not alter existing ones (they're adding a new fixture and the original tests are unaltered nor excluded in the config). From user-perspective, there could be better ways (e.g. putting the fixture in a "custom" directory or somehow altering the php server), but that feels like it's also our responsibility to provide that. In this case, for example, we could have provided a CUSTOM_WEB_FIXTURES constant which is exactly for this case. There might still be uses for WEB_FIXTURES... but in any case being public is just one side of that constant. |
||
|
|
||
| public function handle(Request $request, $type = 1 /* self::MAIN_REQUEST */ , $catch = true): Response | ||
| { | ||
| $this->prepareSession($request); | ||
|
|
@@ -25,8 +28,8 @@ public function handle(Request $request, $type = 1 /* self::MAIN_REQUEST */ , $c | |
|
|
||
| private function handleFixtureRequest(Request $request): Response | ||
| { | ||
| $fixturesDir = realpath(__DIR__ . '/../web-fixtures'); | ||
| $overwriteDir = realpath(__DIR__ . '/../http-kernel-fixtures'); | ||
| $fixturesDir = realpath(self::WEB_FIXTURES_DIR); | ||
| $overwriteDir = realpath(self::KERNEL_FIXTURES_DIR); | ||
|
|
||
| require_once $fixturesDir . '/utils.php'; | ||
|
|
||
|
|
@@ -60,8 +63,9 @@ private function prepareSession(Request $request): void | |
|
|
||
| $cookies = $request->cookies; | ||
|
|
||
| if ($cookies->has($session->getName())) { | ||
| $session->setId($cookies->get($session->getName())); | ||
| $value = $cookies->get($session->getName()); | ||
| if ($value !== null) { | ||
|
uuf6429 marked this conversation as resolved.
Outdated
|
||
| $session->setId($value); | ||
| } else { | ||
| $session->migrate(false); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| use Behat\Mink\Exception\DriverException; | ||
| use Behat\Mink\Tests\Driver\TestCase; | ||
| use Behat\Mink\Tests\Driver\Util\FixturesKernel; | ||
|
uuf6429 marked this conversation as resolved.
Outdated
|
||
|
|
||
| final class GeneralTest extends TestCase | ||
| { | ||
|
|
@@ -77,14 +78,15 @@ public function testFormSubmitWays(string $submitVia): void | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * @return iterable<array{string}> | ||
| */ | ||
| public static function formSubmitWaysDataProvider(): iterable | ||
| { | ||
| return [ | ||
| ['Save'], | ||
| ['input-type-image'], | ||
| ['button-without-type'], | ||
| ['button-type-submit'], | ||
| ]; | ||
| yield ['Save']; | ||
| yield ['input-type-image']; | ||
| yield ['button-without-type']; | ||
| yield ['button-type-submit']; | ||
| } | ||
|
|
||
| public function testFormSubmit(): void | ||
|
|
@@ -189,7 +191,7 @@ public function testAdvancedForm(): void | |
| $notes->setValue('new notes'); | ||
| $this->assertEquals('new notes', $notes->getValue()); | ||
|
|
||
| $about->attachFile($this->mapRemoteFilePath(__DIR__ . '/../../web-fixtures/some_file.txt')); | ||
| $about->attachFile($this->mapRemoteFilePath(FixturesKernel::WEB_FIXTURES_DIR . '/some_file.txt')); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making GeneralTest depend on the kernel is bad, because this introduces a hard dependency on
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the beginning I was going to do it the other way round: class TestCase {
public const XXXXX;
}
class FixturesKernel {
...
TestCase::XXXXX;
...
}But then I figured that That begs the follow-up question...since this test suite IS the main point of project, shouldn't everything in Anyway, we have these options:
I'll go for option 2, let me know if 3 sounds better or you have a different idea.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
no. I'd rather keep the shared testsuite under a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't suggesting to merge I'd just like to know out of those 3 options if option 2 is fine. |
||
|
|
||
| $button = $page->findButton('Register'); | ||
| $this->assertNotNull($button); | ||
|
|
@@ -352,7 +354,7 @@ public function testSubmitEmptyTextarea(): void | |
| /** | ||
| * @dataProvider provideInvalidValues | ||
| * | ||
| * @param mixed $value | ||
| * @param array<array-key, mixed>|bool|string $value | ||
| */ | ||
| public function testSetInvalidValueInField(string $field, $value): void | ||
| { | ||
|
|
@@ -366,6 +368,9 @@ public function testSetInvalidValueInField(string $field, $value): void | |
| $color->setValue($value); | ||
| } | ||
|
|
||
| /** | ||
| * @return iterable<string, array{string, mixed}> | ||
| */ | ||
| public static function provideInvalidValues(): iterable | ||
| { | ||
| $trueValue = ['true', true]; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.