Skip to content

Commit

Permalink
[11.x] Prefer new Fluent over fluent() helper (#53890)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored Dec 13, 2024
1 parent fadcb3d commit 764c796
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Http/Concerns/InteractsWithInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
use Illuminate\Support\Fluent;
use Illuminate\Support\Traits\Dumpable;
use Illuminate\Support\Traits\InteractsWithData;
use SplFileInfo;
Expand Down Expand Up @@ -121,7 +122,7 @@ public function input($key = null, $default = null)
*/
public function fluent($key = null)
{
return fluent(is_array($key) ? $this->only($key) : $this->input($key));
return new Fluent(is_array($key) ? $this->only($key) : $this->input($key));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/Http/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ public function testResponseCanBeReturnedAsFluent()
$response = $this->factory->get('http://foo.com/api');

$this->assertInstanceOf(Fluent::class, $response->fluent());
$this->assertEquals(fluent(['result' => ['foo' => 'bar']]), $response->fluent());
$this->assertEquals(fluent(['foo' => 'bar']), $response->fluent('result'));
$this->assertEquals(fluent(['bar']), $response->fluent('result.foo'));
$this->assertEquals(fluent([]), $response->fluent('missing_key'));
$this->assertEquals(new Fluent(['result' => ['foo' => 'bar']]), $response->fluent());
$this->assertEquals(new Fluent(['foo' => 'bar']), $response->fluent('result'));
$this->assertEquals(new Fluent(['bar']), $response->fluent('result.foo'));
$this->assertEquals(new Fluent([]), $response->fluent('missing_key'));
}

public function testSendRequestBodyAsJsonByDefault()
Expand Down

0 comments on commit 764c796

Please sign in to comment.