Skip to content

Commit

Permalink
test current implode behavior for collections with models (#54704)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuernbergerA authored Feb 19, 2025
1 parent 6e41df6 commit bd278a7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Exception;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;
use Illuminate\Support\ItemNotFoundException;
Expand Down Expand Up @@ -2331,6 +2332,19 @@ public function testImplode($collection)
$this->assertSame('taylor-foo,dayle-bar', $data->implode(fn ($user) => $user['name'].'-'.$user['email'], ','));
}

#[DataProvider('collectionClassProvider')]
public function testImplodeModels($collection)
{
$model = new class extends Model {};
$model->setAttribute('email', 'foo');
$modelTwo = new class extends Model {};
$modelTwo->setAttribute('email', 'bar');
$data = new $collection([$model, $modelTwo]);

$this->assertSame('foobar', $data->implode('email'));
$this->assertSame('foo,bar', $data->implode('email', ','));
}

#[DataProvider('collectionClassProvider')]
public function testTake($collection)
{
Expand Down

0 comments on commit bd278a7

Please sign in to comment.