コード例 #1
0
ファイル: ServiceTest.php プロジェクト: Ryan-Nolan/boxbilling
 public function testcreateGroup()
 {
     $adminGroupModel = new \Model_AdminGroup();
     $adminGroupModel->loadBean(new \RedBeanPHP\OODBBean());
     $newGroupId = 1;
     $systemServiceMock = $this->getMockBuilder('\\Box\\Mod\\System\\Service')->getMock();
     $systemServiceMock->expects($this->atLeastOnce())->method('checkLimits');
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('dispense')->will($this->returnValue($adminGroupModel));
     $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue($newGroupId));
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $di['logger'] = new \Box_Log();
     $di['mod_service'] = $di->protect(function () use($systemServiceMock) {
         return $systemServiceMock;
     });
     $service = new \Box\Mod\Staff\Service();
     $service->setDi($di);
     $result = $service->createGroup('new_group_name');
     $this->assertInternalType('int', $result);
     $this->assertEquals($newGroupId, $result);
 }