@@ 12-29 (lines=18) @@ | ||
9 | */ |
|
10 | abstract class ListenerTest extends \PHPUnit_Framework_TestCase |
|
11 | { |
|
12 | public function testObjectInsertedOnPersist() |
|
13 | { |
|
14 | $entity = new Listener\Entity(1); |
|
15 | $persister = $this->getMockPersister($entity, 'index', 'type'); |
|
16 | $eventArgs = $this->createLifecycleEventArgs($entity, $this->getMockObjectManager()); |
|
17 | $indexable = $this->getMockIndexable('index', 'type', $entity, true); |
|
18 | ||
19 | $listener = $this->createListener($persister, $indexable, array('indexName' => 'index', 'typeName' => 'type')); |
|
20 | $listener->postPersist($eventArgs); |
|
21 | ||
22 | $this->assertEquals($entity, current($listener->scheduledForInsertion)); |
|
23 | ||
24 | $persister->expects($this->once()) |
|
25 | ->method('insertMany') |
|
26 | ->with($listener->scheduledForInsertion); |
|
27 | ||
28 | $listener->postFlush($eventArgs); |
|
29 | } |
|
30 | ||
31 | public function testPersistDeferred() |
|
32 | { |
|
@@ 31-46 (lines=16) @@ | ||
28 | $listener->postFlush($eventArgs); |
|
29 | } |
|
30 | ||
31 | public function testPersistDeferred() |
|
32 | { |
|
33 | $entity = new Listener\Entity(1); |
|
34 | $persister = $this->getMockPersister($entity, 'index', 'type'); |
|
35 | $eventArgs = $this->createLifecycleEventArgs($entity, $this->getMockObjectManager()); |
|
36 | $indexable = $this->getMockIndexable('index', 'type', $entity, true); |
|
37 | ||
38 | $listener = $this->createListener($persister, $indexable, array('indexName' => 'index', 'typeName' => 'type', 'defer' => true)); |
|
39 | $listener->postPersist($eventArgs); |
|
40 | ||
41 | $this->assertEquals($entity, current($listener->scheduledForInsertion)); |
|
42 | ||
43 | $persister->expects($this->never())->method('insertMany'); |
|
44 | ||
45 | $listener->postFlush($eventArgs); |
|
46 | } |
|
47 | ||
48 | public function testNonIndexableObjectNotInsertedOnPersist() |
|
49 | { |