Skip to content
Snippets Groups Projects

dev#203399 : add libraries multi-select element in profiles

Compare and Show latest version
1 file
+ 110
0
Preferences
Compare changes
<?php
/**
* Copyright (c) 2012-2024, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class UsersControllerDynamicGroupsTestCase extends Admin_AbstractControllerTestCase
{
public function setUp()
{
parent::setUp();
$this->fixture(Class_UserGroupCategorie::class,
['id' => 1001,
'libelle' => 'Etablissement',
'parent_id' => 0]);
$this->fixture(Class_UserGroup::class,
['id' => 101,
'id_cat' => 1001,
'protected' => false,
'libelle' => 'Admin portail',
'group_type' => Class_UserGroup::TYPE_DYNAMIC,
'users' => [],
'rights' => [],
'filters' => json_encode(['search_role_level' => '6',
'search_id_site' => '1;2'])]);
$this->fixture(Class_UserGroup::class,
['id' => 102,
'id_cat' => 1001,
'protected' => false,
'libelle' => 'Admin bibliothèque',
'group_type' => Class_UserGroup::TYPE_DYNAMIC,
'users' => [],
'rights' => [],
'filters' => json_encode(['search_role_level' => '4',
'search_id_site' => '3'])]);
$this->fixture(Class_UserGroup::class,
['id' => 103,
'id_cat' => 1001,
'protected' => false,
'libelle' => 'Contributeurs',
'group_type' => Class_UserGroup::TYPE_DYNAMIC,
'users' => [],
'rights' => [],
'filters' => json_encode(['search_id_site' => '1'])]);
}
protected function _jsonContainsGroup(string $group_name): bool
{
xdebug_break();
$response = json_decode($this->_response->getBody());
foreach ($response[0]->categories[0]->items as $group)
if ($group->label == $group_name)
return true;
return false;
}
}
class UsersControllerDynamicGroupsAdminPortailTest extends UsersControllerDynamicGroupsTestCase
{
public function setUp()
{
parent::setUp();
$this->fixture(Class_Users::class,
['id' => 201,
'nom' => 'User 201',
'last_login' => '',
'idabon' => 201,
'login' => 'user201',
'password' => 'secret',
'id_site' => 1,
'role_level' => ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL]);
$this->dispatch('/admin/users/edit/id/201');
}
/** @test */
public function user201ShouldBeMemberOfGroupAdminPortailAndContributeurs()
{
$this->assertXPath('//input[@id="user_group_ids"][@value="101-103"]');
}
}