Skip to content
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

[6.x] Add boolean($key) method to Request #31160

Merged
merged 5 commits into from
Jan 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update HttpRequestTest.php
Add tests for boolean method
  • Loading branch information
LasseRafn authored Jan 17, 2020
commit 9bdd911943176ae26558407553ed4ac55004b8ed
10 changes: 10 additions & 0 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,16 @@ public function testInputMethod()
$this->assertInstanceOf(SymfonyUploadedFile::class, $request['file']);
}

public function testBooleanMethod()
{
$request = Request::create('/', 'GET', ['with_trashed' => 'false', 'download' => true, 'checked' => 1, 'unchecked' => '0']);
$this->assertTrue($request->boolean('checked'));
$this->assertTrue($request->boolean('download'));
$this->assertFalse($request->boolean('unchecked'));
$this->assertFalse($request->boolean('with_trashed'));
$this->assertFalse($request->boolean('some_undefined_key'));
}

public function testArrayAccess()
{
$request = Request::create('/', 'GET', ['name' => null, 'foo' => ['bar' => null, 'baz' => '']]);
Expand Down