9 use \Magento\Framework\Module\Setup;
18 private $resourceModel;
32 $this->resourceModel = $this->createMock(\
Magento\Framework\
App\ResourceConnection::class);
33 $this->connection = $this->getMockForAbstractClass(\
Magento\Framework\DB\Adapter\AdapterInterface::class);
34 $this->resourceModel->expects($this->any())
35 ->method(
'getConnection')
36 ->with(self::CONNECTION_NAME)
37 ->willReturn($this->connection);
38 $this->resourceModel->expects($this->any())
39 ->method(
'getConnectionByName')
41 ->willReturn($this->connection);
42 $this->
object =
new Setup($this->resourceModel, self::CONNECTION_NAME);
47 $this->assertSame($this->connection, $this->object->getConnection());
49 $this->assertSame($this->connection, $this->object->getConnection());
55 $expectedTableName =
'expected_table';
57 $this->assertEmpty($this->object->getTable(
$tableName));
58 $this->
object->setTable(
$tableName, $expectedTableName);
59 $this->assertSame($expectedTableName, $this->object->getTable(
$tableName));
65 $expectedTableName =
'expected_table';
67 $this->resourceModel->expects($this->once())
68 ->method(
'getTableName')
70 ->will($this->returnValue($expectedTableName));
72 $this->assertSame($expectedTableName, $this->object->getTable(
$tableName));
74 $this->assertSame($expectedTableName, $this->object->getTable(
$tableName));
81 $this->connection->expects($this->once())
82 ->method(
'isTableExists')
84 ->will($this->returnValue(
true));
85 $this->assertTrue($this->object->tableExists(
$tableName));
90 $q =
'SELECT something';
91 $this->connection->expects($this->once())
94 $this->
object->run($q);
99 $this->connection->expects($this->once())
100 ->method(
'startSetup');
101 $this->
object->startSetup();
106 $this->connection->expects($this->once())
107 ->method(
'endSetup');
108 $this->
object->endSetup();