I would like, for crazy no point in explaining reasons, to create a mock Eloquent Collection
I have tried this:
$collection = new \Illuminate\Database\Eloquent\Collection(
array(
new User( array( "id" => 1 ) ),
new User( array( "id" => 2 ) ),
new User( array( "id" => 3 ) ),
new User( array( "id" => 4 ) ),
new User( array( "id" => 5 ) )
)
);
$collection->get(); // Fails
but it turns out that this collection does not have a ->get()
method like it normally does when you'd do, something like:
User::take( 2 )->get();
this ends up being because the \Illuminate\Database\Eloquent\Collection is just a namespaced and used \Illuminate\Database\Collection
any ideas how to mock an Eloquent Collection that actually works properly?
Aucun commentaire:
Enregistrer un commentaire