0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-04-29 03:20:29 +00:00
nextcloud_server/build/integration/features/bootstrap/Activity.php
Côme Chilliet da9b6e376d fix(tests): Sort activities by id to get the last one
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-03-25 15:43:09 +01:00

32 lines
885 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert;
trait Activity {
use BasicStructure;
/**
* @Then last activity should be
* @param TableNode $activity
*/
public function lastActivityIs(TableNode $activity): void {
$this->sendRequestForJSON('GET', '/apps/activity/api/v2/activity');
$this->theHTTPStatusCodeShouldBe('200');
$data = json_decode($this->response->getBody()->getContents(), true);
$activities = $data['ocs']['data'];
/* Sort by id */
uasort($activities, fn ($a, $b) => $a['activity_id'] <=> $b['activity_id']);
$lastActivity = array_pop($activities);
foreach ($activity->getRowsHash() as $key => $value) {
Assert::assertEquals($value, $lastActivity[$key]);
}
}
}