26 private $resourceConnection;
30 $this->resourceConnection = $this->getMockBuilder(ResourceConnection::class)
31 ->disableOriginalConstructor()
35 [
'resourceConnection' => $this->resourceConnection]
41 $connection = $this->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)
42 ->setMethods([
'getProfiler'])
43 ->getMockForAbstractClass();
44 $profiler = $this->getMockBuilder(\Zend_Db_Profiler::class)
45 ->disableOriginalConstructor()
47 $connection->expects($this->once())->method(
'getProfiler')->willReturn($profiler);
48 $this->resourceConnection->expects($this->once())->method(
'getConnection')->willReturn(
$connection);
50 $profiler->expects($this->once())->method(
'getQueryProfiles')->willReturn([]);
52 $this->unit->disable();
53 $this->assertEquals([], $this->unit->getSql());
58 $connection = $this->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)
59 ->setMethods([
'getProfiler'])
60 ->getMockForAbstractClass();
61 $profiler = $this->getMockBuilder(\Zend_Db_Profiler::class)
62 ->disableOriginalConstructor()
64 $connection->expects($this->once())->method(
'getProfiler')->willReturn($profiler);
65 $this->resourceConnection->expects($this->once())->method(
'getConnection')->willReturn(
$connection);
67 $query = $this->getMockBuilder(\Zend_Db_Profiler_Query::class)->disableOriginalConstructor()->getMock();
69 $profiler->expects($this->once())->method(
'getQueryProfiles')->willReturn([
$query]);
71 $this->unit->disable();
72 $this->assertEquals([], $this->unit->getSql());
77 $connection = $this->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)
78 ->setMethods([
'getProfiler'])
79 ->getMockForAbstractClass();
80 $profiler = $this->getMockBuilder(\Zend_Db_Profiler::class)
81 ->disableOriginalConstructor()
83 $connection->expects($this->once())->method(
'getProfiler')->willReturn($profiler);
84 $this->resourceConnection->expects($this->once())->method(
'getConnection')->willReturn(
$connection);
86 $query = $this->getMockBuilder(\Zend_Db_Profiler_Query::class)->disableOriginalConstructor()->getMock();
88 $query->expects($this->once())->method(
'getQuery')->willReturn(
89 'INSERT INTO `catalog_product_entity` (id, sku, type, created_at, attribute_set)' 90 .
' VALUES (?, ?, ?, \'2013-12-11\', ?), (?, ?, ?, \'2013-12-11\', ?)' 92 $query->expects($this->once())->method(
'getQueryParams')->willReturn([
93 4,
'sku_4',
'simple', 4, 5,
'sku_5',
'simple', 12
95 $profiler->expects($this->once())->method(
'getQueryProfiles')->willReturn([
$query]);
97 $this->unit->disable();
106 'created_at' =>
'2013-12-11',
107 'attribute_set' => 4,
113 'created_at' =>
'2013-12-11',
114 'attribute_set' => 12,
117 'catalog_product_entity' 120 $this->unit->getSql()
testGetEmptySqlWhenSelectQueryProcessed()