1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nip\Collections\Tests\Lazy; |
4
|
|
|
|
5
|
|
|
use Nip\Collections\Tests\AbstractTest; |
6
|
|
|
use Nip\Collections\Tests\Fixtures\LazyCollection; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class AbstractLazyCollectionTest |
10
|
|
|
* @package Nip\Collections\Tests\Lazy |
11
|
|
|
*/ |
12
|
|
|
class AbstractLazyCollectionTest extends AbstractTest |
13
|
|
|
{ |
14
|
|
|
public function test_lazy() |
15
|
|
|
{ |
16
|
|
|
$mock = \Mockery::mock(LazyCollection::class)->shouldAllowMockingProtectedMethods()->makePartial(); |
17
|
|
|
$mock->shouldReceive('doLoad')->never(); |
18
|
|
|
|
19
|
|
|
self::assertInstanceOf(LazyCollection::class, $mock); |
20
|
|
|
// self::assertSame(0, $mock->count()); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function test_doLoad_once() |
24
|
|
|
{ |
25
|
|
|
$mock = \Mockery::mock(LazyCollection::class)->shouldAllowMockingProtectedMethods()->makePartial(); |
26
|
|
|
$mock->shouldReceive('doLoad')->once(); |
27
|
|
|
|
28
|
|
|
self::assertInstanceOf(LazyCollection::class, $mock); |
29
|
|
|
self::assertSame(0, $mock->count()); |
30
|
|
|
self::assertSame(0, $mock->count()); |
31
|
|
|
self::assertSame(0, $mock->count()); |
32
|
|
|
self::assertSame(0, $mock->count()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function test_doLoad() |
36
|
|
|
{ |
37
|
|
|
$collection = new LazyCollection(); |
38
|
|
|
self::assertInstanceOf(LazyCollection::class, $collection); |
39
|
|
|
self::assertSame(2, $collection->count()); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|