Fix migration and test improvements

This commit is contained in:
Igor Scheller 2022-01-01 16:21:40 +01:00
parent e361400f68
commit 80d87617f2
3 changed files with 21 additions and 9 deletions

View File

@ -17,11 +17,11 @@ class RemoveAdminNewsHtmlPrivilege extends Migration
$connection = $this->schema->getConnection(); $connection = $this->schema->getConnection();
// Delete unused privileges // Delete unused privilege
$connection->delete(' $connection->delete(
DELETE FROM `Privileges` 'DELETE FROM `Privileges` WHERE `name` = ?',
WHERE `name` = \'admin_news_html\' ['admin_news_html']
'); );
} }
/** /**
@ -33,9 +33,19 @@ class RemoveAdminNewsHtmlPrivilege extends Migration
return; return;
} }
$connection->insert(' $connection = $this->schema->getConnection();
INSERT INTO `Privileges` (`name`, `desc`) $connection->insert(
VALUES (\'admin_news_html\', \'Use HTML in news\') 'INSERT INTO `Privileges` (`name`, `desc`) VALUES (?, ?)',
'); ['admin_news_html', 'Use HTML in news']
);
// Add permissions to news admins to edit html news
$connection->insert(
'
INSERT IGNORE INTO GroupPrivileges (group_id, privilege_id)
VALUES ((SELECT UID FROM `Groups` WHERE `name` = ?), (SELECT id FROM `Privileges` WHERE `name` = ?))
',
['News Admin', 'admin_news_html']
);
} }
} }

View File

@ -31,6 +31,7 @@ class NewsControllerTest extends ControllerTest
/** /**
* @covers \Engelsystem\Controllers\Admin\NewsController::__construct * @covers \Engelsystem\Controllers\Admin\NewsController::__construct
* @covers \Engelsystem\Controllers\Admin\NewsController::edit * @covers \Engelsystem\Controllers\Admin\NewsController::edit
* @covers \Engelsystem\Controllers\Admin\NewsController::showEdit
*/ */
public function testEdit() public function testEdit()
{ {

View File

@ -55,6 +55,7 @@ trait HasDatabase
['migration' => '2020_12_28_000000_oauth_set_identifier_binary'], ['migration' => '2020_12_28_000000_oauth_set_identifier_binary'],
['migration' => '2021_08_26_000000_add_shirt_edit_permissions'], ['migration' => '2021_08_26_000000_add_shirt_edit_permissions'],
['migration' => '2021_10_12_000000_add_shifts_description'], ['migration' => '2021_10_12_000000_add_shifts_description'],
['migration' => '2021_12_30_000000_remove_admin_news_html_privilege'],
] ]
); );