Skip to content

Commit

Permalink
[minor] add test for submitting form with different submit button val…
Browse files Browse the repository at this point in the history
…ues (#54)
  • Loading branch information
kbond authored Aug 23, 2021
1 parent 12c6d5c commit 4739145
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
27 changes: 27 additions & 0 deletions tests/BrowserTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,33 @@ public function select_field(): void
;
}

/**
* @test
*/
public function can_submit_form_with_different_submit_buttons(): void
{
// Submit and Submit B, have the same field name but different values
// Submit C has a different field name (and value)

$this->browser()
->visit('/page1')
->click('Submit')
->assertOn('/submit-form')
->assertContains('"submit_1":"a"')
->assertNotContains('submit_2')
->visit('/page1')
->click('Submit B')
->assertOn('/submit-form')
->assertContains('"submit_1":"b"')
->assertNotContains('submit_2')
->visit('/page1')
->click('Submit C')
->assertOn('/submit-form')
->assertContains('"submit_2":"c"')
->assertNotContains('submit_1')
;
}

/**
* @test
*/
Expand Down
4 changes: 3 additions & 1 deletion tests/Fixture/files/page1.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ <h1>h1 title</h1>
<label for="radio3">Radio 3</label>
<input type="radio" id="radio3" name="input_8" value="option 3">

<button>Submit</button>
<button type="submit" name="submit_1" value="a">Submit</button>
<button type="submit" name="submit_1" value="b">Submit B</button>
<button type="submit" name="submit_2" value="c">Submit C</button>
</form>
</body>
</html>

0 comments on commit 4739145

Please sign in to comment.