public function setUp() { $this->modulesMock = $this->getMock(\Magelight\Components\Modules::class, [], [], '', false); $this->configMock = $this->getMock(\Magelight\Config::class, [], [], '', false); $this->dbMock = $this->getMock(\Magelight\Db\Mysql\Adapter::class, [], [], '', false); $this->appMock = $this->getMockForAbstractClass(App::class, [], '', false, false, true, ['db']); \Magelight\Components\Modules::forgeMock($this->modulesMock); \Magelight\Config::forgeMock($this->configMock); \Magelight\Db\Mysql\Adapter::forgeMock($this->dbMock); \Magelight\App::forgeMock($this->appMock); }
public function testDbMysql() { $mysqlConfig = new \SimpleXMLElement('<config> <type>mysql</type> <host>localhost</host> </config>'); $index = \Magelight\App::DEFAULT_INDEX; $mysqlDbAdapterMock = $this->getMock(\Magelight\Db\Mysql\Adapter::class, ['init'], [], '', false); $mysqlDbAdapterMock->expects($this->once())->method('init')->with((array) $mysqlConfig); \Magelight\Db\Mysql\Adapter::forgeMock($mysqlDbAdapterMock); $this->configMock->expects($this->once())->method('getConfig')->with('/global/db/' . $index, null)->will($this->returnValue($mysqlConfig)); $this->assertInstanceOf(\Magelight\Db\Mysql\Adapter::class, $this->app->db()); }