public function toApiArray(\Model_ServiceLicense $model, $deep = false, $identity = null) { $result = array('license_key' => $model->license_key, 'validate_ip' => (bool) $model->validate_ip, 'validate_host' => (bool) $model->validate_host, 'validate_version' => (bool) $model->validate_version, 'validate_path' => (bool) $model->validate_path, 'ips' => $model->getAllowedIps(), 'hosts' => $model->getAllowedHosts(), 'paths' => $model->getAllowedPaths(), 'versions' => $model->getAllowedVersions(), 'pinged_at' => $model->pinged_at); if ($identity instanceof \Model_Admin) { $result['plugin'] = $model->plugin; } return $result; }
public function testupdate() { $data = array('license_key' => '123456Licence', 'validate_ip' => '1.1.1.1', 'validate_host' => 'boxbilling.com', 'validate_version' => '1.0', 'validate_path' => '/usr', 'ips' => '2.2.2.2\\n', 'pinged_at' => '', 'plugin' => 'Simple'); $serviceLicenseModel = new \Model_ServiceLicense(); $serviceLicenseModel->loadBean(new \RedBeanPHP\OODBBean()); $dbMock = $this->getMockBuilder('\\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce())->method('store'); $di = new \Box_Di(); $di['db'] = $dbMock; $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) { return isset($array[$key]) ? $array[$key] : $default; }); $this->service->setDi($di); $result = $this->service->update($serviceLicenseModel, $data); $this->assertInternalType('bool', $result); $this->assertTrue($result); }