8000 [11.x] Add `Macroable` and `fill()` to `Support\Fluent` by stevebauman · Pull Request #54404 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[11.x] Add Macroable and fill() to Support\Fluent #54404

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

Merged
merged 5 commits into from
Jan 29, 2025
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
Add tests for fill and macroable
  • Loading branch information
stevebauman committed Jan 29, 2025
commit b47a10f4729282d74db6897f929a3de29cf05f09
36 changes: 36 additions & 0 deletions tests/Support/SupportFluentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,42 @@ public function testEnumsMethod()
$this->assertEquals([TestBackedEnum::B], $fluent->enums('int.b', TestBackedEnum::class));
$this->assertEmpty($fluent->enums('int.doesnt_exist', TestBackedEnum::class));
}

public function testFill()
{
$fluent = new Fluent(['name' => 'John Doe',]);

$fluent->fill([
'email' => 'john.doe@example.com',
'age' => 30,
]);

$this->assertEquals([
'name' => 'John Doe',
'email' => 'john.doe@example.com',
'age' => 30,
], $fluent->getAttributes());
}

public function testMacroable()
{
Fluent::macro('foo', function () {
return $this->fill([
'foo' => 'bar',
'baz' => 'zal',
]);
});

$fluent = new Fluent([
'bee' => 'ser',
]);

$this->assertSame([
'bee' => 'ser',
'foo' => 'bar',
'baz' => 'zal',
], $fluent->foo()->all());
}
}

class FluentArrayIteratorStub implements IteratorAggregate
Expand Down
0