Skip to content

Commit 4d2f36f

Browse files
author
francoism90
committed
Add simplePaginate append test
1 parent 596141a commit 4d2f36f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/AppendTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Http\Request;
77
use Illuminate\Pagination\LengthAwarePaginator;
8+
use Illuminate\Pagination\Paginator;
89
use Illuminate\Support\Collection;
910
use Spatie\QueryBuilder\Exceptions\InvalidAppendQuery;
1011
use Spatie\QueryBuilder\QueryBuilder;
@@ -159,4 +160,14 @@ protected function assertPaginateAttributeLoaded(LengthAwarePaginator $collectio
159160

160161
$this->assertFalse($hasModelWithoutAttributeLoaded, "The `{$attribute}` attribute was expected but not loaded.");
161162
}
163+
164+
protected function assertSimplePaginateAttributeLoaded(Paginator $collection, string $attribute)
165+
{
166+
$hasModelWithoutAttributeLoaded = $collection
167+
->contains(function (Model $model) use ($attribute) {
168+
return ! array_key_exists($attribute, $model->toArray());
169+
});
170+
171+
$this->assertFalse($hasModelWithoutAttributeLoaded, "The `{$attribute}` attribute was expected but not loaded.");
172+
}
162173
}

0 commit comments

Comments
 (0)