public function testProcessRelations() { $this->relationProcessorMock->expects($this->once())->method('processRelation')->with($this->salesModelMock); $this->salesModelMock->expects($this->once())->method('getEventPrefix')->willReturn('sales_event_prefix'); $this->eventManagerMock->expects($this->once())->method('dispatch')->with('sales_event_prefix_process_relation', ['object' => $this->salesModelMock]); $this->entityRelationComposite->processRelations($this->salesModelMock); }
public function testSyncRemove() { $this->eventObserverMock->expects($this->once())->method('getDataObject')->willReturn($this->salesModelMock); $this->salesModelMock->expects($this->once())->method('getId')->willReturn('sales-id-value'); $this->gridAggregatorMock->expects($this->once())->method('purge')->with('sales-id-value'); $this->unit->execute($this->eventObserverMock); }
public function testSyncInsert() { $this->eventObserverMock->expects($this->once())->method('getObject')->willReturn($this->salesModelMock); $this->salesModelMock->expects($this->once())->method('getId')->willReturn('sales-id-value'); $this->scopeConfigurationMock->expects($this->once())->method('getValue')->with('dev/grid/async_indexing', 'default', null)->willReturn(false); $this->gridAggregatorMock->expects($this->once())->method('refresh')->with('sales-id-value'); $this->unit->execute($this->eventObserverMock); }
/** * @expectedException \Exception * @expectedExceptionMessage Expected Exception * @throws \Exception */ public function testSaveFailed() { $this->modelMock->expects($this->any())->method('getEventPrefix')->will($this->returnValue('event_prefix')); $this->modelMock->expects($this->any())->method('getEventObject')->will($this->returnValue('event_object')); $this->appResourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->connectionMock)); $exception = new \Exception('Expected Exception'); $this->modelMock->expects($this->any())->method('getId')->will($this->throwException($exception)); $this->connectionMock->expects($this->once())->method('beginTransaction'); $this->connectionMock->expects($this->once())->method('rollback'); $this->eventManagerMock->expects($this->once())->method('dispatch')->with('event_prefix_save_attribute_before', ['event_object' => $this->attribute, 'object' => $this->modelMock, 'attribute' => ['attribute']]); $this->attribute->saveAttribute($this->modelMock, 'attribute'); }