|
8 | 8 | use Illuminate\Session\Store;
|
9 | 9 | use Illuminate\Support\Carbon;
|
10 | 10 | use Illuminate\Support\Collection;
|
| 11 | +use Illuminate\Support\Stringable; |
11 | 12 | use Illuminate\Tests\Database\Fixtures\Models\Money\Price;
|
12 | 13 | use InvalidArgumentException;
|
13 | 14 | use Mockery as m;
|
@@ -585,6 +586,32 @@ public function testInputMethod()
|
585 | 586 | $this->assertInstanceOf(SymfonyUploadedFile::class, $request['file']);
|
586 | 587 | }
|
587 | 588 |
|
| 589 | + public function testStringMethod() |
| 590 | + { |
| 591 | + $request = Request::create('/', 'GET', [ |
| 592 | + 'int' => 123, |
| 593 | + 'int_str' => '456', |
| 594 | + 'float' => 123.456, |
| 595 | + 'float_str' => '123.456', |
| 596 | + 'float_zero' => 0.000, |
| 597 | + 'float_str_zero' => '0.000', |
| 598 | + 'str' => 'abc', |
| 599 | + 'empty_str' => '', |
| 600 | + 'null' => null, |
| 601 | + ]); |
| 602 | + $this->assertTrue($request->string('int') instanceof Stringable); |
| 603 | + $this->assertTrue($request->string('unknown_key') instanceof Stringable); |
| 604 | + $this->assertSame('123', $request->string('int')->value()); |
| 605 | + $this->assertSame('456', $request->string('int_str')->value()); |
| 606 | + $this->assertSame('123.456', $request->string('float')->value()); |
| 607 | + $this->assertSame('123.456', $request->string('float_str')->value()); |
| 608 | + $this->assertSame('0', $request->string('float_zero')->value()); |
| 609 | + $this->assertSame('0.000', $request->string('float_str_zero')->value()); |
| 610 | + $this->assertSame('', $request->string('empty_str')->value()); |
| 611 | + $this->assertSame('', $request->string('null')->value()); |
| 612 | + $this->assertSame('', $request->string('unknown_key')->value()); |
| 613 | + } |
| 614 | + |
588 | 615 | public function testBooleanMethod()
|
589 | 616 | {
|
590 | 617 | $request = Request::create('/', 'GET', ['with_trashed' => 'false', 'download' => true, 'checked' => 1, 'unchecked' => '0', 'with_on' => 'on', 'with_yes' => 'yes']);
|
|
0 commit comments