Skip to content

Commit 3a2813e

Browse files
abnegateclaude
andcommitted
test: resolve the rename-codemod report for tests
The CR dry run over tests/ and bin/ left these to hand-resolve. Query::TYPE_ELEM_MATCH is deleted (DEC-55), so the fingerprint and shape tests build elemMatch through Query::elemMatch(). getRelationshipHook() is @internal in 8.0, so the e2e setUp swaps the relationship hook the way it already swaps the permission hook; the unit tests of the hook mechanics keep reading it. getConnectionId() returns null without Feature\Connection, so the e2e check asserts a string before comparing it with ''. The skipDuplicates() statement test is named after ignoreDuplicates(), which it drives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f1fb33e commit 3a2813e

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎tests/e2e/Adapter/Base.php‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ protected function setUp(): void
9393

9494
self::$authorization->addRole('any');
9595

96-
$db = $this->getDatabase();
97-
if ($db->getRelationshipHook() === null) {
98-
$db->addHook(new Relationships());
99-
}
100-
$db->removeHook(Permissions::class)->addHook(new Permissions());
96+
$this->getDatabase()
97+
->removeHook(Relationships::class)->addHook(new Relationships())
98+
->removeHook(Permissions::class)->addHook(new Permissions());
10199
}
102100

103101
protected function tearDown(): void

‎tests/e2e/Adapter/Scopes/CollectionTests.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ public function testGetCollectionId(): void
444444
return;
445445
}
446446

447-
$this->assertNotSame('', $database->getConnectionId());
447+
$id = $database->getConnectionId();
448+
$this->assertIsString($id);
449+
$this->assertNotSame('', $id);
448450
}
449451

450452
public function testKeywords(): void

tests/unit/Adapter/SkipDuplicatesStatementTest.php renamed to tests/unit/Adapter/IgnoreDuplicatesStatementTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
use Utopia\Database\Helpers\Role;
1616

1717
/**
18-
* The statements skipDuplicates() sends on the engines the host cannot run.
18+
* The statements ignoreDuplicates() sends on the engines the host cannot run.
1919
*/
20-
final class SkipDuplicatesStatementTest extends TestCase
20+
final class IgnoreDuplicatesStatementTest extends TestCase
2121
{
2222
private const string STORED = 'stored';
2323

‎tests/unit/QueryTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,12 @@ public function testFingerprintNestedLogicalQueries(): void
573573
$this->assertNotSame(Query::fingerprint([$andOne]), Query::fingerprint([$andTwo]));
574574

575575
// elemMatch attribute matters: same inner shape on different fields must NOT collide
576-
$elemTags = new Query(Query::TYPE_ELEM_MATCH, 'tags', [Query::equal('name', ['php'])]);
577-
$elemCategories = new Query(Query::TYPE_ELEM_MATCH, 'categories', [Query::equal('name', ['php'])]);
576+
$elemTags = Query::elemMatch('tags', [Query::equal('name', ['php'])]);
577+
$elemCategories = Query::elemMatch('categories', [Query::equal('name', ['php'])]);
578578
$this->assertNotSame(Query::fingerprint([$elemTags]), Query::fingerprint([$elemCategories]));
579579

580580
// elemMatch values-only change (same field, same child shape) still collides — as expected
581-
$elemTagsOther = new Query(Query::TYPE_ELEM_MATCH, 'tags', [Query::equal('name', ['js'])]);
581+
$elemTagsOther = Query::elemMatch('tags', [Query::equal('name', ['js'])]);
582582
$this->assertSame(Query::fingerprint([$elemTags]), Query::fingerprint([$elemTagsOther]));
583583
}
584584

@@ -599,7 +599,7 @@ public function testShape(): void
599599
$this->assertSame('and:(equal:name|greaterThan:age)', $and->shape());
600600

601601
// elemMatch preserves the attribute (the field being matched)
602-
$elem = new Query(Query::TYPE_ELEM_MATCH, 'tags', [Query::equal('name', ['php'])]);
602+
$elem = Query::elemMatch('tags', [Query::equal('name', ['php'])]);
603603
$this->assertSame('elemMatch:tags(equal:name)', $elem->shape());
604604

605605
// Deeply nested — iterative traversal must match recursive result

0 commit comments

Comments
 (0)