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

[8.x] Adds datetime parsing to Request instance #39945

Merged
merged 12 commits into from
Dec 17, 2021
Prev Previous commit
Next Next commit
Style fixes.
  • Loading branch information
DarkGhostHunter committed Dec 8, 2021
commit c49469f46f027caf0e9b5d4e189cb4539ed7bb1a
2 changes: 0 additions & 2 deletions src/Illuminate/Http/Concerns/InteractsWithInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use stdClass;
use Symfony\Component\VarDumper\VarDumper;

use function is_null;

trait InteractsWithInput
{
/**
Expand Down
6 changes: 2 additions & 4 deletions tests/Http/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;

use function now;

class HttpRequestTest extends TestCase
{
protected function tearDown(): void
Expand Down Expand Up @@ -546,15 +544,15 @@ public function testDatetimeMethod()
'as_timezone' => '20-01-01 13:30:25',
]);

$current = Carbon::create(2020, 1, 1,16,30,25,'UTC');
$current = Carbon::create(2020, 1, 1, 16, 30, 25, 'UTC');

$this->assertNull($request->datetime('as_null'));
$this->assertNull($request->datetime('doesnt_exists'));
$this->assertTrue($request->datetime('as_date')->isSameDay($current));
$this->assertEquals($current, $request->datetime('as_datetime'));
$this->assertTrue($request->datetime('as_time')->isSameSecond('16:30:25'));
$this->assertEquals($current, $request->datetime('as_format', 'U'));
$this->assertEquals($current, $request->datetime('as_timezone', null, 'America/Santiago'));
$this->assertEquals($current, $request->datetime('as_timezone', null, 'America/Santiago'));

Carbon::setTestNow($current);

Expand Down