Skip to content

Commit

Permalink
test: add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
vanthao03596 committed May 8, 2021
1 parent 643f2d1 commit 49a4df1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/CursorPaginatorLoadMorphCountTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Vanthao03596\LaravelCursorPaginate\Tests;

use Illuminate\Database\Eloquent\Collection;
use Vanthao03596\LaravelCursorPaginate\AbstractCursorPaginator;
use Mockery as m;
use PHPUnit\Framework\TestCase;

class CursorPaginatorLoadMorphCountTest 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 AbstractCursorPaginator
{
//
})->setCollection($items);

$this->assertSame($p, $p->loadMorphCount('parentable', $relations));
}
}
29 changes: 29 additions & 0 deletions tests/CursorPaginatorLoadMorphTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Vanthao03596\LaravelCursorPaginate\Tests;

use Illuminate\Database\Eloquent\Collection;
use Vanthao03596\LaravelCursorPaginate\AbstractCursorPaginator;
use Mockery as m;
use PHPUnit\Framework\TestCase;

class CursorPaginatorLoadMorphTest extends TestCase
{
public function testCollectionLoadMorphCanChainOnThePaginator()
{
$relations = [
'App\\User' => 'photos',
'App\\Company' => ['employees', 'calendars'],
];

$items = m::mock(Collection::class);
$items->shouldReceive('loadMorph')->once()->with('parentable', $relations);

$p = (new class extends AbstractCursorPaginator
{
//
})->setCollection($items);

$this->assertSame($p, $p->loadMorph('parentable', $relations));
}
}

0 comments on commit 49a4df1

Please sign in to comment.