Merge pull request #48286 from nextcloud/backport/48215/stable30

[stable30] fix(tests): Fix test selection and run unit tests of DAV and user_status
This commit is contained in:
Joas Schilling 2024-09-25 09:00:57 +02:00 committed by GitHub
commit cfb8f1289e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 50 additions and 15915 deletions

View file

@ -114,20 +114,30 @@ class ContactsMigratorTest extends TestCase {
$exportMetadata = array_filter(['displayName' => $displayName, 'description' => $description]);
$this->assertEquals($importMetadata, $exportMetadata);
$this->assertEquals(count($importCards), count($exportCards));
$this->assertSameSize($importCards, $exportCards);
for ($i = 0; $i < count($importCards); ++$i) {
$this->assertNotEqualsCanonicalizing(
$this->getPropertiesChangedOnImport($importCards[$i]),
$this->getPropertiesChangedOnImport($exportCards[$i]),
);
$importProperties = [];
$exportProperties = [];
for ($i = 0, $iMax = count($importCards); $i < $iMax; ++$i) {
$importProperties[] = $this->getPropertiesChangedOnImport($importCards[$i]);
$exportProperties[] = $this->getPropertiesChangedOnImport($exportCards[$i]);
}
for ($i = 0; $i < count($importCards); ++$i) {
$this->assertEqualsCanonicalizing(
$this->getProperties($importCards[$i]),
$this->getProperties($exportCards[$i]),
);
$this->assertNotEqualsCanonicalizing(
$importProperties,
$exportProperties,
);
$importProperties = [];
$exportProperties = [];
for ($i = 0, $iMax = count($importCards); $i < $iMax; ++$i) {
$importProperties[] = $this->getProperties($importCards[$i]);
$exportProperties[] = $this->getProperties($exportCards[$i]);
}
$this->assertEqualsCanonicalizing(
$importProperties,
$exportProperties,
);
}
}

View file

@ -7,7 +7,7 @@ declare(strict_types=1);
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\UserStatus\Tests\Integration\BackgroundJob;
namespace OCA\UserStatus\Tests\Integration\Service;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Db\DoesNotExistException;
@ -42,17 +42,20 @@ class StatusServiceIntegrationTest extends TestCase {
}
public function testCustomStatusMessageTimestamp(): void {
$before = time();
$this->service->setCustomMessage(
'test123',
'🍕',
'Lunch',
null,
);
$after = time();
$status = $this->service->findByUserId('test123');
self::assertSame('Lunch', $status->getCustomMessage());
self::assertGreaterThanOrEqual(time(), $status->getStatusMessageTimestamp());
self::assertGreaterThanOrEqual($before, $status->getStatusMessageTimestamp());
self::assertLessThanOrEqual($after, $status->getStatusMessageTimestamp());
}
public function testOnlineStatusKeepsMessageTimestamp(): void {
@ -95,15 +98,29 @@ class StatusServiceIntegrationTest extends TestCase {
'meeting',
true,
);
self::assertSame(
'meeting',
$this->service->findByUserId('test123')->getMessageId(),
);
self::assertSame(
IUserStatus::ONLINE,
$this->service->findByUserId('_test123')->getStatus(),
);
$this->service->revertUserStatus(
$revertedStatus = $this->service->revertUserStatus(
'test123',
'meeting',
);
self::assertNotNull($revertedStatus, 'Status should have been reverted');
try {
$this->service->findByUserId('_test123');
$this->fail('Expected DoesNotExistException() to be thrown when finding backup status after reverting');
} catch (DoesNotExistException) {
}
self::assertSame(
IUserStatus::ONLINE,
$this->service->findByUserId('test123')->getStatus(),
@ -154,32 +171,26 @@ class StatusServiceIntegrationTest extends TestCase {
);
$this->service->setUserStatus(
'test123',
IUserStatus::AWAY,
IUserStatus::MESSAGE_CALENDAR_BUSY,
IUserStatus::DND,
IUserStatus::MESSAGE_AVAILABILITY,
true,
);
self::assertSame(
'meeting',
'availability',
$this->service->findByUserId('test123')->getMessageId(),
);
$nostatus = $this->service->setUserStatus(
'test123',
IUserStatus::AWAY,
IUserStatus::MESSAGE_AVAILABILITY,
IUserStatus::MESSAGE_CALENDAR_BUSY,
true,
);
self::assertNull($nostatus);
self::assertSame(
IUserStatus::MESSAGE_CALENDAR_BUSY,
IUserStatus::MESSAGE_AVAILABILITY,
$this->service->findByUserId('test123')->getMessageId(),
);
}
public function testCi(): void {
// TODO: remove if CI turns red
self::assertTrue(false);
}
}

View file

@ -64,7 +64,7 @@ class SearchBuilder {
'owner' => 'string',
];
/** @var array<string, int> */
/** @var array<string, int|string> */
protected static $paramTypeMap = [
'string' => IQueryBuilder::PARAM_STR,
'integer' => IQueryBuilder::PARAM_INT,

View file

@ -10,6 +10,7 @@ namespace OCP\DB\QueryBuilder;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Types\Types;
use OCP\DB\Exception;
use OCP\DB\IResult;
use OCP\IDBConnection;
@ -28,7 +29,7 @@ interface IQueryBuilder {
/**
* @since 9.0.0
*/
public const PARAM_BOOL = ParameterType::BOOLEAN;
public const PARAM_BOOL = Types::BOOLEAN;
/**
* @since 9.0.0
*/

View file

@ -6,11 +6,7 @@
*/
function loadDirectory($path): void {
if (strpos($path, 'integration')) {
return;
}
if (strpos($path, 'Integration')) {
if (strpos($path, 'apps/user_ldap/tests/Integration')) {
return;
}