|
@@ 92-121 (lines=30) @@
|
| 89 |
|
$this->assertTrue($called); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
public function testShouldDispatchPreInsertObjectsEventWithExpectedArguments() |
| 93 |
|
{ |
| 94 |
|
$objectPersisterMock = $this->createObjectPersisterMock(); |
| 95 |
|
|
| 96 |
|
$options = ['indexName' => 'theIndex', 'typeName' => 'theType', 'batch_size' => 10]; |
| 97 |
|
|
| 98 |
|
$registryMock = $this->createPersisterRegistryStub($objectPersisterMock); |
| 99 |
|
$dispatcher = new EventDispatcher(); |
| 100 |
|
|
| 101 |
|
$persister = new InPlacePagerPersister($registryMock, $dispatcher); |
| 102 |
|
|
| 103 |
|
$objects = [new \stdClass(), new \stdClass()]; |
| 104 |
|
|
| 105 |
|
$pager = $this->createPager($objects); |
| 106 |
|
|
| 107 |
|
$called = false; |
| 108 |
|
$dispatcher->addListener(Events::PRE_INSERT_OBJECTS, function($event) use(&$called, $pager, $objectPersisterMock, $objects, $options) { |
| 109 |
|
$called = true; |
| 110 |
|
|
| 111 |
|
$this->assertInstanceOf(PreInsertObjectsEvent::class, $event); |
| 112 |
|
$this->assertSame($pager, $event->getPager()); |
| 113 |
|
$this->assertSame($objectPersisterMock, $event->getObjectPersister()); |
| 114 |
|
$this->assertSame($options, $event->getOptions()); |
| 115 |
|
$this->assertSame($objects, $event->getObjects()); |
| 116 |
|
}); |
| 117 |
|
|
| 118 |
|
$persister->insert($pager, $options); |
| 119 |
|
|
| 120 |
|
$this->assertTrue($called); |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
public function testShouldDispatchPostInsertObjectsEventWithExpectedArguments() |
| 124 |
|
{ |
|
@@ 123-152 (lines=30) @@
|
| 120 |
|
$this->assertTrue($called); |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
public function testShouldDispatchPostInsertObjectsEventWithExpectedArguments() |
| 124 |
|
{ |
| 125 |
|
$objectPersisterMock = $this->createObjectPersisterMock(); |
| 126 |
|
|
| 127 |
|
$options = ['indexName' => 'theIndex', 'typeName' => 'theType', 'batch_size' => 10]; |
| 128 |
|
|
| 129 |
|
$registryMock = $this->createPersisterRegistryStub($objectPersisterMock); |
| 130 |
|
$dispatcher = new EventDispatcher(); |
| 131 |
|
|
| 132 |
|
$persister = new InPlacePagerPersister($registryMock, $dispatcher); |
| 133 |
|
|
| 134 |
|
$objects = [new \stdClass(), new \stdClass()]; |
| 135 |
|
|
| 136 |
|
$pager = $this->createPager($objects); |
| 137 |
|
|
| 138 |
|
$called = false; |
| 139 |
|
$dispatcher->addListener(Events::POST_INSERT_OBJECTS, function($event) use(&$called, $pager, $objectPersisterMock, $objects, $options) { |
| 140 |
|
$called = true; |
| 141 |
|
|
| 142 |
|
$this->assertInstanceOf(PostInsertObjectsEvent::class, $event); |
| 143 |
|
$this->assertSame($pager, $event->getPager()); |
| 144 |
|
$this->assertSame($objectPersisterMock, $event->getObjectPersister()); |
| 145 |
|
$this->assertSame($options, $event->getOptions()); |
| 146 |
|
$this->assertSame($objects, $event->getObjects()); |
| 147 |
|
}); |
| 148 |
|
|
| 149 |
|
$persister->insert($pager, $options); |
| 150 |
|
|
| 151 |
|
$this->assertTrue($called); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
public function testShouldDispatchPostPersistEventWithExpectedArguments() |
| 155 |
|
{ |
|
@@ 154-182 (lines=29) @@
|
| 151 |
|
$this->assertTrue($called); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
public function testShouldDispatchPostPersistEventWithExpectedArguments() |
| 155 |
|
{ |
| 156 |
|
$objectPersisterMock = $this->createObjectPersisterMock(); |
| 157 |
|
|
| 158 |
|
$options = ['indexName' => 'theIndex', 'typeName' => 'theType', 'batch_size' => 10]; |
| 159 |
|
|
| 160 |
|
$registryMock = $this->createPersisterRegistryStub($objectPersisterMock); |
| 161 |
|
$dispatcher = new EventDispatcher(); |
| 162 |
|
|
| 163 |
|
$persister = new InPlacePagerPersister($registryMock, $dispatcher); |
| 164 |
|
|
| 165 |
|
$objects = [new \stdClass(), new \stdClass()]; |
| 166 |
|
|
| 167 |
|
$pager = $this->createPager($objects); |
| 168 |
|
|
| 169 |
|
$called = false; |
| 170 |
|
$dispatcher->addListener(Events::POST_PERSIST, function($event) use(&$called, $pager, $objectPersisterMock, $objects, $options) { |
| 171 |
|
$called = true; |
| 172 |
|
|
| 173 |
|
$this->assertInstanceOf(PostPersistEvent::class, $event); |
| 174 |
|
$this->assertSame($pager, $event->getPager()); |
| 175 |
|
$this->assertSame($objectPersisterMock, $event->getObjectPersister()); |
| 176 |
|
$this->assertSame($options, $event->getOptions()); |
| 177 |
|
}); |
| 178 |
|
|
| 179 |
|
$persister->insert($pager, $options); |
| 180 |
|
|
| 181 |
|
$this->assertTrue($called); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
public function testShouldCallObjectPersisterInsertManyMethodForEachPage() |
| 185 |
|
{ |