-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x] Add 'loadMorphCount' method (#32739)
* Add 'loadMorphCount' method to Eloquent Collection * Add 'loadMorphCount' proxy method to AbstractPaginator Co-authored-by: GuntherDebrauwer <22586858+GuntherDebrauwer@users.noreply.github.com>
- Loading branch information
1 parent
2d0ec75
commit ec8bf7e
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Pagination; | ||
|
||
use Illuminate\Database\Eloquent\Collection; | ||
use Illuminate\Pagination\AbstractPaginator; | ||
use Mockery as m; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PaginatorLoadMorphCountTest extends TestCase | ||
{ | ||
public function testCollectionLoadMorphCountCanChainOnThePaginator() | ||
{ | ||
$relations = [ | ||
'App\\User' => 'photos', | ||
'App\\Company' => ['employees', 'calendars'], | ||
]; | ||
|
||
$items = m::mock(Collection::class); | ||
$items->shouldReceive('loadMorphCount')->once()->with('parentable', $relations); | ||
|
||
$p = (new class extends AbstractPaginator { | ||
// | ||
})->setCollection($items); | ||
|
||
$this->assertSame($p, $p->loadMorphCount('parentable', $relations)); | ||
} | ||
} |