37 $this->select = $this->createMock(\
Magento\Framework\DB\Select::class);
39 $this->connection = $this->getMockForAbstractClass(
40 \
Magento\Framework\DB\Adapter\AdapterInterface::class,
49 $this->connection->expects($this->any())
51 ->willReturn($this->select);
53 $this->connection->expects($this->any())
54 ->method(
'quoteIdentifier')
55 ->willReturnArgument(0);
57 $metadata = $this->createMock(\
Magento\Framework\EntityManager\EntityMetadata::class);
59 $metadata->expects($this->any())
60 ->method(
'getEntityTable')
61 ->willReturn(
'entity_table');
63 $metadata->expects($this->any())
64 ->method(
'getEntityConnection')
65 ->willReturn($this->connection);
67 $metadata->expects($this->any())
68 ->method(
'getIdentifierField')
69 ->willReturn(
'identifier');
71 $this->metadataPool = $this->createMock(\
Magento\Framework\EntityManager\MetadataPool::class);
73 $this->metadataPool->expects($this->any())
74 ->method(
'getMetadata')
75 ->with(
'Test\Entity\Type')
76 ->willReturn($metadata);
78 $this->subject = new \Magento\Framework\Model\ResourceModel\Db\ReadEntityRow(
85 $identifier =
'100000001';
87 $context = [
'store_id' => 1];
88 $expectedData = [
'entity_id' => 1];
90 $this->select->expects($this->once())
92 ->with([
't' =>
'entity_table'])
95 $this->select->expects($this->at(1))
97 ->with(
'identifier = ?', $identifier)
100 $this->select->expects($this->at(2))
102 ->with(
'store_id = ?', 1)
105 $this->connection->expects($this->once())
107 ->willReturn($expectedData);
109 $actualData = $this->subject->execute(
'Test\Entity\Type', $identifier, $context);
111 $this->assertEquals($expectedData, $actualData);