Example #1
0
 public function testLoadBy()
 {
     $metaTableName = 'sequence_meta';
     $metaIdFieldName = 'meta_id';
     $entityType = 'order';
     $storeId = 1;
     $metaId = 1;
     $metaData = ['meta_id' => 1, 'profile_id' => 2];
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->resourceMock->expects($this->once())->method('getTableName')->willReturn($metaTableName);
     $this->connectionMock->expects($this->any())->method('select')->willReturn($this->select);
     $this->select->expects($this->at(0))->method('from')->with($metaTableName, [$metaIdFieldName])->willReturn($this->select);
     $this->select->expects($this->at(1))->method('where')->with('entity_type = :entity_type AND store_id = :store_id')->willReturn($this->select);
     $this->connectionMock->expects($this->once())->method('fetchOne')->with($this->select, ['entity_type' => $entityType, 'store_id' => $storeId])->willReturn($metaId);
     $this->metaFactory->expects($this->once())->method('create')->willReturn($this->meta);
     $this->stepCheckSaveWithActiveProfile($metaData);
     $this->assertEquals($this->meta, $this->resource->loadByEntityTypeAndStore($entityType, $storeId));
 }
Example #2
0
 /**
  * Returns sequence for given entityType and store
  *
  * @param string $entityType
  * @param int $storeId
  * @return \Magento\Framework\DB\Sequence\SequenceInterface
  */
 public function getSequence($entityType, $storeId)
 {
     return $this->sequenceFactory->create(['meta' => $this->resourceSequenceMeta->loadByEntityTypeAndStore($entityType, $storeId)]);
 }