Skip to content

Commit

Permalink
CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uuf6429 committed Jul 12, 2023
1 parent 9984e40 commit 411839b
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions tests/Form/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
final class GeneralTest extends TestCase
{
// test multiple submit buttons
public function testIssue212(): void
public function testIssue212()

Check failure on line 11 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testIssue212() has no return type specified.
{
$session = $this->getSession();

Expand All @@ -18,7 +18,7 @@ public function testIssue212(): void
$this->assertEquals('poney', $field->getValue());
}

public function testBasicForm(): void
public function testBasicForm()

Check failure on line 21 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testBasicForm() has no return type specified.
{
$this->getSession()->visit($this->pathTo('/basic_form.html'));

Expand Down Expand Up @@ -58,7 +58,7 @@ public function testBasicForm(): void
/**
* @dataProvider formSubmitWaysDataProvider
*/
public function testFormSubmitWays(string $submitVia): void
public function testFormSubmitWays(string $submitVia)

Check failure on line 61 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testFormSubmitWays() has no return type specified.
{
$session = $this->getSession();
$session->visit($this->pathTo('/basic_form.html'));
Expand Down Expand Up @@ -87,7 +87,7 @@ public static function formSubmitWaysDataProvider(): iterable
];
}

public function testFormSubmit(): void
public function testFormSubmit()

Check failure on line 90 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testFormSubmit() has no return type specified.
{
$session = $this->getSession();
$session->visit($this->pathTo('/basic_form.html'));
Expand All @@ -102,7 +102,7 @@ public function testFormSubmit(): void
}
}

public function testFormSubmitWithoutButton(): void
public function testFormSubmitWithoutButton()

Check failure on line 105 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testFormSubmitWithoutButton() has no return type specified.
{
$session = $this->getSession();
$session->visit($this->pathTo('/form_without_button.html'));
Expand All @@ -117,7 +117,7 @@ public function testFormSubmitWithoutButton(): void
}
}

public function testBasicGetForm(): void
public function testBasicGetForm()

Check failure on line 120 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testBasicGetForm() has no return type specified.
{
$this->getSession()->visit($this->pathTo('/basic_get_form.php'));
$webAssert = $this->getAssertSession();
Expand All @@ -133,7 +133,7 @@ public function testBasicGetForm(): void
$this->assertEquals('some#query', $div->getText());
}

public function testAdvancedForm(): void
public function testAdvancedForm()

Check failure on line 136 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testAdvancedForm() has no return type specified.
{
$this->getSession()->visit($this->pathTo('/advanced_form.html'));
$page = $this->getSession()->getPage();
Expand Down Expand Up @@ -222,7 +222,7 @@ public function testAdvancedForm(): void
}
}

public function testQuoteInValue(): void
public function testQuoteInValue()

Check failure on line 225 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testQuoteInValue() has no return type specified.
{
$this->getSession()->visit($this->pathTo('/advanced_form.html'));

Expand Down Expand Up @@ -262,7 +262,7 @@ public function testQuoteInValue(): void
}
}

public function testMultiInput(): void
public function testMultiInput()

Check failure on line 265 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testMultiInput() has no return type specified.
{
$this->getSession()->visit($this->pathTo('/multi_input_form.html'));
$page = $this->getSession()->getPage();
Expand Down Expand Up @@ -307,7 +307,7 @@ public function testMultiInput(): void
$this->assertStringContainsString($out, $page->getContent());
}

public function testAdvancedFormSecondSubmit(): void
public function testAdvancedFormSecondSubmit()

Check failure on line 310 in tests/Form/GeneralTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Form\GeneralTest::testAdvancedFormSecondSubmit() has no return type specified.
{
$this->getSession()->visit($this->pathTo('/advanced_form.html'));
$page = $this->getSession()->getPage();
Expand All @@ -329,7 +329,7 @@ public function testAdvancedFormSecondSubmit(): void
}
}

public function testSubmitEmptyTextarea(): void
public function testSubmitEmptyTextarea()
{
$this->getSession()->visit($this->pathTo('/empty_textarea.html'));
$page = $this->getSession()->getPage();
Expand All @@ -354,30 +354,37 @@ public function testSubmitEmptyTextarea(): void
*
* @param mixed $value
*/
public function testSetInvalidValueInField(string $field, $value): void
public function testSetInvalidValueInField(string $field, $value)
{
$this->getSession()->visit($this->pathTo('/advanced_form.html'));

$webAssert = $this->getAssertSession();

$color = $webAssert->elementExists('named', ['id_or_name', $field]);
$color = $webAssert->elementExists('named', array('id_or_name', $field));

$this->expectException(DriverException::class);
$color->setValue($value);
}

public static function provideInvalidValues(): iterable
{
$nullValue = ['null', null];
$trueValue = ['true', true];
$falseValue = ['false', false];
$arrayValue = ['array', ['bad']];
$stringValue = ['string', 'updated'];

$scenarios = [
'about' => [null, true, false, ['bad']],
'notes' => [null, true, false, ['bad']],
'first_name' => [null, true, false, ['bad']],
'submit' => [null, true, false, ['bad'], 'update'],
// field type, name or id, list of values to check
['file', 'about', [$nullValue, $trueValue, $falseValue, $arrayValue]],
['textarea', 'notes', [$nullValue, $trueValue, $falseValue, $arrayValue]],
['text', 'first_name', [$nullValue, $trueValue, $falseValue, $arrayValue]],
['button', 'submit', [$nullValue, $trueValue, $falseValue, $arrayValue, $stringValue]],
];

foreach ($scenarios as $field => $values) {
foreach ($values as $value) {
yield "$field field with " . var_export($value, true) => [$field, $value];
foreach ($scenarios as [$fieldType, $fieldNameOrId, $values]) {
foreach ($values as [$valueDesc, $actualValue]) {
yield "$fieldType field with $valueDesc" => [$fieldNameOrId, $actualValue];
}
}
}
Expand Down

0 comments on commit 411839b

Please sign in to comment.