public function testInstall() { $db_mock = $this->getMockBuilder('Box_Database')->getMock(); $db_mock->expects($this->atLeastOnce())->method('exec')->will($this->returnValue(true)); $di = new Box_Di(); $di['db'] = $db_mock; $di['url'] = new Box_Url(); $mod = new Box_Mod('example'); $mod->setDi($di); $bool = $mod->install(); $this->assertTrue($bool); $bool = $mod->uninstall(); $this->assertTrue($bool); $bool = $mod->update(); $this->assertTrue($bool); }
public function testgetAdminNavigation() { $staffServiceMock = $this->getMockBuilder('\\Box\\Mod\\Staff\\Service')->getMock(); $staffServiceMock->expects($this->atLeastOnce())->method('hasPermission')->will($this->returnValue(true)); $pdoStatment = $this->getMockBuilder('\\Box\\Mod\\Extension\\PdoStatmentsMock')->getMock(); $pdoStatment->expects($this->atLeastOnce())->method('execute'); $pdoStatment->expects($this->atLeastOnce())->method('fetchAll')->will($this->returnValue(array())); $pdoMock = $this->getMockBuilder('\\Box\\Mod\\Extension\\PdoMock')->getMock(); $pdoMock->expects($this->atLeastOnce())->method('prepare')->will($this->returnValue($pdoStatment)); $link = 'extension'; $urlMock = $this->getMockBuilder('Box_Url')->getMock(); $urlMock->expects($this->atLeastOnce())->method('adminLink')->willReturn('http://boxbilling.com/index.php?_url=/' . $link); $di['url'] = $urlMock; $di = new \Box_Di(); $di['mod'] = $di->protect(function ($name) use($di) { $mod = new \Box_Mod($name); $mod->setDi($di); return $mod; }); $di['tools'] = new \Box_Tools(); $di['mod_service'] = $di->protect(function () use($staffServiceMock) { return $staffServiceMock; }); $di['pdo'] = $pdoMock; $di['url'] = $urlMock; $this->service->setDi($di); $result = $this->service->getAdminNavigation(new \Model_Admin()); $this->assertInternalType('array', $result); }
return $db; }; $di['pager'] = function () use($di) { $service = new Box_Pagination(); $service->setDi($di); return $service; }; $di['url'] = function () use($di) { $url = new Box_Url(); $url->setDi($di); $url->setBaseUri(BB_URL); return $url; }; $di['mod'] = $di->protect(function ($name) use($di) { $mod = new Box_Mod($name); $mod->setDi($di); return $mod; }); $di['mod_service'] = $di->protect(function ($mod, $sub = '') use($di) { return $di['mod']($mod)->getService($sub); }); $di['mod_config'] = $di->protect(function ($name) use($di) { return $di['mod']($name)->getConfig(); }); $di['events_manager'] = function () use($di) { $service = new Box_EventManager(); $service->setDi($di); return $service; }; $di['session'] = function () use($di) { $handler = new PdoSessionHandler($di['pdo']);