-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/** | ||
* @phpVersion 8.0 | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
require __DIR__ . '/TestCase.php'; | ||
|
||
|
||
class ControlsReturnTypeTest extends PHPStan\Testing\TypeInferenceTestCase | ||
{ | ||
/** @return iterable<mixed> */ | ||
public function dataFileAsserts(): iterable | ||
{ | ||
yield from $this->gatherAssertTypes(__DIR__ . '/data/Controls.getValue().php'); | ||
} | ||
|
||
|
||
/** @dataProvider dataFileAsserts */ | ||
public function testFileAsserts(string $assertType, string $file, mixed ...$args): void | ||
{ | ||
$this->assertFileAsserts($assertType, $file, ...$args); | ||
} | ||
} | ||
|
||
|
||
$testCase = new ControlsReturnTypeTest; | ||
$testCase->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPUnit\Framework; | ||
|
||
use Tester\Assert; | ||
|
||
|
||
abstract class TestCase extends \Tester\TestCase | ||
{ | ||
protected function assertSame(mixed $expected, mixed $actual, string $message = ''): void | ||
{ | ||
Assert::same($expected, $actual, $message); | ||
} | ||
|
||
|
||
protected function assertTrue(mixed $actual, string $message = ''): void | ||
{ | ||
Assert::true($actual, $message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\Forms\Form; | ||
use function PHPStan\Testing\assertType; | ||
|
||
|
||
$form = new Form; | ||
|
||
$input = $form->addText('Text'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addPassword('Password'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addTextArea('TextArea'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addEmail('Email'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addInteger('Integer'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addUpload('Upload'); | ||
assertType('array<Nette\Http\FileUpload>|Nette\Http\FileUpload|null', $input->getValue()); | ||
|
||
$input = $form->addMultiUpload('MultiUpload'); | ||
assertType('array<Nette\Http\FileUpload>|Nette\Http\FileUpload|null', $input->getValue()); | ||
|
||
$input = $form->addHidden('Hidden'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addCheckbox('Checkbox'); | ||
assertType('bool|null', $input->getValue()); | ||
|
||
$input = $form->addRadioList('RadioList'); | ||
assertType('int|string|null', $input->getValue()); | ||
|
||
$input = $form->addCheckboxList('CheckboxList'); | ||
assertType('array<(int|string)>', $input->getValue()); | ||
|
||
$input = $form->addSelect('Select'); | ||
assertType('int|string|null', $input->getValue()); | ||
|
||
$input = $form->addMultiSelect('MultiSelect'); | ||
assertType('array<(int|string)>', $input->getValue()); | ||
|
||
$input = $form->addSubmit('Submit'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addButton('Button'); | ||
assertType('string|null', $input->getValue()); | ||
|
||
$input = $form->addImageButton('ImageButton'); | ||
assertType('array|null', $input->getValue()); | ||
|
||
$input = $form->addImage('Image'); | ||
assertType('array|null', $input->getValue()); |