forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-10.1' into release-10.1-tweak-narrow-sidebar
- Loading branch information
Showing
22 changed files
with
732 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
module/VuFind/src/VuFindTest/Feature/CacheManagementTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/** | ||
* Trait adding the ability to clear object cache. | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) The National Library of Finland 2024. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package Tests | ||
* @author Ere Maijala <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki | ||
*/ | ||
|
||
namespace VuFindTest\Feature; | ||
|
||
use Laminas\Http\Request; | ||
use VuFindHttp\HttpService; | ||
|
||
/** | ||
* Trait adding the ability to clear object cache. | ||
* | ||
* @category VuFind | ||
* @package Tests | ||
* @author Ere Maijala <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki | ||
*/ | ||
trait CacheManagementTrait | ||
{ | ||
/** | ||
* Get configuration required for cache clear permission | ||
* | ||
* @return array | ||
*/ | ||
protected function getCacheClearPermissionConfig(): array | ||
{ | ||
return [ | ||
'permissions' => [ | ||
'enable-admin-cache-api' => [ | ||
'permission' => 'access.api.admin.cache', | ||
'require' => 'ANY', | ||
'role' => 'guest', | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Call the API to clear object cache | ||
* | ||
* @return voi | ||
*/ | ||
protected function clearObjectCache(): void | ||
{ | ||
$http = new HttpService(); | ||
$client = $http->createClient($this->getVuFindUrl('/api/v1/admin/cache?id=object'), Request::METHOD_DELETE); | ||
$response = $client->send(); | ||
if (200 !== $response->getStatusCode()) { | ||
throw new \Exception('Could not clear object cache: ' . $response->getBody()); | ||
} | ||
} | ||
} |
Oops, something went wrong.