32 $this->connection = $this->getMockForAbstractClass(
33 \
Magento\Framework\DB\Adapter\AdapterInterface::class,
42 $this->connection->expects($this->any())
43 ->method(
'lastInsertId')
46 $metadata = $this->createMock(\
Magento\Framework\EntityManager\EntityMetadata::class);
48 $metadata->expects($this->any())
49 ->method(
'getLinkField')
50 ->willReturn(
'entity_id');
52 $metadata->expects($this->any())
53 ->method(
'getEntityTable')
54 ->willReturn(
'entity_table');
56 $metadata->expects($this->any())
57 ->method(
'getEntityConnection')
58 ->willReturn($this->connection);
60 $metadata->expects($this->any())
61 ->method(
'getIdentifierField')
62 ->willReturn(
'identifier');
64 $metadata->expects($this->once())
65 ->method(
'generateIdentifier')
66 ->willReturn(
'100000001');
68 $this->metadataPool = $this->createMock(\
Magento\Framework\EntityManager\MetadataPool::class);
70 $this->metadataPool->expects($this->any())
71 ->method(
'getMetadata')
72 ->with(
'Test\Entity\Type')
73 ->willReturn($metadata);
75 $this->subject = new \Magento\Framework\Model\ResourceModel\Db\CreateEntityRow(
87 public function testExecute($inputData, $tableData, $preparedData, $finalData)
89 $this->connection->expects($this->any())
90 ->method(
'describeTable')
91 ->with(
'entity_table')
92 ->willReturn($tableData);
94 $this->connection->expects($this->once())
96 ->with(
'entity_table', $preparedData);
98 $actualData = $this->subject->execute(
'Test\Entity\Type', $inputData);
100 $this->assertEquals($finalData, $actualData);
109 'test_field_1' =>
'test_value_1',
110 'test_field_2' => 100,
111 'test_field_3' =>
'test_value_2' 116 'COLUMN_NAME' =>
'TEST_FIELD_1',
120 'COLUMN_NAME' =>
'TEST_FIELD_2',
124 'COLUMN_NAME' =>
'TEST_FIELD_3',
125 'DEFAULT' =>
'CURRENT_TIMESTAMP' 128 'COLUMN_NAME' =>
'TEST_FIELD_4',
134 'test_field_1' =>
'test_value_1',
135 'test_field_2' => 100,
136 'test_field_4' =>
null,
137 'identifier' =>
'100000001' 141 'test_field_1' =>
'test_value_1',
142 'test_field_2' => 100,
143 'test_field_3' =>
'test_value_2',
148 [$inputData, $tableData, $preparedData, $finalData]
testExecute($inputData, $tableData, $preparedData, $finalData)