mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-11 21:38:40 +00:00
More unit tests
This commit is contained in:
parent
5b1da2d6a8
commit
aa0366838d
|
|
@ -255,54 +255,4 @@ class Installer extends InstallerAbstract
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide group and permission install for other modules
|
||||
*
|
||||
* @param DatabasePool $dbPool Database pool
|
||||
* @param array $data Data to install
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function installExternal(DatabasePool $dbPool, array $data) : void
|
||||
{
|
||||
foreach ($data as $type => $element) {
|
||||
if ($type === InstallType::GROUP) {
|
||||
self::installGroup($dbPool, $element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Install group
|
||||
*
|
||||
* @param DatabasePool $dbPool Database pool
|
||||
* @param array $data Data to install
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function installGroup(DatabasePool $dbPool, array $data) : int
|
||||
{
|
||||
$sth = $dbPool->get()->con->prepare(
|
||||
'INSERT INTO `' . $dbPool->get()->prefix . 'group` (
|
||||
`group_id`, `group_name`, `group_description`, `group_description_raw`, `group_status`, `group_created`)
|
||||
VALUES (:id, :name, :desc, :desc_raw, :status, :created);'
|
||||
);
|
||||
|
||||
$sth->bindValue(':id', $data['id'] ?? 0, \PDO::PARAM_INT);
|
||||
$sth->bindValue(':name', $data['name'] ?? '', \PDO::PARAM_STR);
|
||||
$sth->bindValue(':desc', $data['desc'] ?? '', \PDO::PARAM_STR);
|
||||
$sth->bindValue(':desc_raw', $data['desc_raw'] ?? '', \PDO::PARAM_STR);
|
||||
$sth->bindValue(':status', $data['status'] ?? 1, \PDO::PARAM_INT);
|
||||
$sth->bindValue(':created', (new \DateTime('now'))->format('Y-m-d H:i:s'), \PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
|
||||
$lastInsertID = $dbPool->get()->con->lastInsertId();
|
||||
|
||||
return $lastInsertID;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -625,6 +625,8 @@ final class ApiController extends Controller
|
|||
$permission = $this->createPermissionFromRequest($request);
|
||||
|
||||
if (!($permission instanceof GroupPermission)) {
|
||||
$response->set('permission_create', new FormValidation($val));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -665,6 +667,8 @@ final class ApiController extends Controller
|
|||
$permission = $this->createPermissionFromRequest($request);
|
||||
|
||||
if (!($permission instanceof AccountPermission)) {
|
||||
$response->set('permission_create', new FormValidation($val));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user