public function testcanChangeCurrencyHasOrder() { $currency = 'EUR'; $model = new \Model_Client(); $model->loadBean(new \RedBeanPHP\OODBBean()); $model->id = rand(1, 100); $model->currency = 'USD'; $clientOrderModel = new \Model_ClientOrder(); $clientOrderModel->loadBean(new \RedBeanPHP\OODBBean()); $database = $this->getMockBuilder('\\Box_Database')->getMock(); $database->expects($this->at(0))->method('findOne')->will($this->returnValue(null)); $database->expects($this->at(1))->method('findOne')->will($this->returnValue($clientOrderModel)); $di = new \Box_Di(); $di['db'] = $database; $clientService = new \Box\Mod\Client\Service(); $clientService->setDi($di); $this->setExpectedException('\\Box_Exception', 'Currency can not be changed. Client already have orders.'); $clientService->canChangeCurrency($model, $currency); }