Skip to content

Commit 8e3f256

Browse files
Merge pull request #125 from utopia-php/chore-assert-same
Chore: Replace assertEquals with assertSame
2 parents f84a064 + 6d490c4 commit 8e3f256

4 files changed

Lines changed: 72 additions & 72 deletions

File tree

tests/Migration/E2E/Sources/NHostTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ public function testValidateUserTransfer($state): void
183183
$this->fail('User "test@test.com" not found');
184184
}
185185

186-
$this->assertEquals('success', $foundUser->getStatus());
187-
$this->assertEquals('$2a$10$ARQ/f.K6OmCjZ8XF0U.6fezPMlxDqsmcl0Rs6xQVkvj62u7gcSzOW', $foundUser->getPasswordHash()->getHash());
188-
$this->assertEquals('bcrypt', $foundUser->getPasswordHash()->getAlgorithm());
189-
$this->assertEquals('test@test.com', $foundUser->getUsername());
186+
$this->assertSame('success', $foundUser->getStatus());
187+
$this->assertSame('$2a$10$ARQ/f.K6OmCjZ8XF0U.6fezPMlxDqsmcl0Rs6xQVkvj62u7gcSzOW', $foundUser->getPasswordHash()->getHash());
188+
$this->assertSame('bcrypt', $foundUser->getPasswordHash()->getAlgorithm());
189+
$this->assertSame('test@test.com', $foundUser->getUsername());
190190
}
191191

192192
#[Depends('testValidateDestinationErrors')]
@@ -209,9 +209,9 @@ public function testValidateDatabaseTransfer($state)
209209
$this->fail('Database "public" not found');
210210
}
211211

212-
$this->assertEquals('success', $foundDatabase->getStatus());
213-
$this->assertEquals('public', $foundDatabase->getDatabaseName());
214-
$this->assertEquals('public', $foundDatabase->getId());
212+
$this->assertSame('success', $foundDatabase->getStatus());
213+
$this->assertSame('public', $foundDatabase->getDatabaseName());
214+
$this->assertSame('public', $foundDatabase->getId());
215215

216216
// Find known table
217217
$tables = $state['source']->cache->get(Resource::TYPE_TABLE);
@@ -230,10 +230,10 @@ public function testValidateDatabaseTransfer($state)
230230
$this->fail('Table "TestTable" not found');
231231
}
232232

233-
$this->assertEquals('success', $foundTable->getStatus());
234-
$this->assertEquals('TestTable', $foundTable->getTableName());
235-
$this->assertEquals('TestTable', $foundTable->getId());
236-
$this->assertEquals('public', $foundTable->getDatabase()->getId());
233+
$this->assertSame('success', $foundTable->getStatus());
234+
$this->assertSame('TestTable', $foundTable->getTableName());
235+
$this->assertSame('TestTable', $foundTable->getId());
236+
$this->assertSame('public', $foundTable->getDatabase()->getId());
237237

238238
return $state;
239239
}
@@ -258,10 +258,10 @@ public function testDatabaseFunctionalDefaultsWarn($state): void
258258
$this->fail('Table "FunctionalDefaultTestTable" not found');
259259
}
260260

261-
$this->assertEquals('warning', $foundTable->getStatus());
262-
$this->assertEquals('FunctionalDefaultTestTable', $foundTable->getTableName());
263-
$this->assertEquals('FunctionalDefaultTestTable', $foundTable->getId());
264-
$this->assertEquals('public', $foundTable->getDatabase()->getId());
261+
$this->assertSame('warning', $foundTable->getStatus());
262+
$this->assertSame('FunctionalDefaultTestTable', $foundTable->getTableName());
263+
$this->assertSame('FunctionalDefaultTestTable', $foundTable->getId());
264+
$this->assertSame('public', $foundTable->getDatabase()->getId());
265265
}
266266

267267
#[Depends('testValidateDatabaseTransfer')]
@@ -284,8 +284,8 @@ public function testValidateStorageTransfer($state): void
284284
$this->fail('Bucket "default" not found');
285285
}
286286

287-
$this->assertEquals('success', $foundBucket->getStatus());
288-
$this->assertEquals('default', $foundBucket->getId());
287+
$this->assertSame('success', $foundBucket->getStatus());
288+
$this->assertSame('default', $foundBucket->getId());
289289

290290
// Find known file
291291
$files = $state['source']->cache->get(Resource::TYPE_FILE);
@@ -304,11 +304,11 @@ public function testValidateStorageTransfer($state): void
304304
$this->fail('File "tulips.png" not found');
305305
}
306306
/** @var File $foundFile */
307-
$this->assertEquals('success', $foundFile->getStatus());
308-
$this->assertEquals('tulips.png', $foundFile->getFileName());
309-
$this->assertEquals('default', $foundFile->getBucket()->getId());
310-
$this->assertEquals('image/png', $foundFile->getMimeType());
311-
$this->assertEquals(679233, $foundFile->getSize());
312-
$this->assertEquals('', $foundFile->getData()); // Memory Leak Check
307+
$this->assertSame('success', $foundFile->getStatus());
308+
$this->assertSame('tulips.png', $foundFile->getFileName());
309+
$this->assertSame('default', $foundFile->getBucket()->getId());
310+
$this->assertSame('image/png', $foundFile->getMimeType());
311+
$this->assertSame(679233, $foundFile->getSize());
312+
$this->assertSame('', $foundFile->getData()); // Memory Leak Check
313313
}
314314
}

tests/Migration/E2E/Sources/SupabaseTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ public function testValidateUserTransfer($state): void
164164
$this->fail('User "albert.kihn95@yahoo.com" not found');
165165
}
166166

167-
$this->assertEquals('success', $foundUser->getStatus());
168-
$this->assertEquals('$2a$10$NGZAAOfXeheUoH9V3dnRoeR.r3J5ynnSZ6KjvHxOUlV8XUrulJzQa', $foundUser->getPasswordHash()->getHash());
169-
$this->assertEquals('bcrypt', $foundUser->getPasswordHash()->getAlgorithm());
167+
$this->assertSame('success', $foundUser->getStatus());
168+
$this->assertSame('$2a$10$NGZAAOfXeheUoH9V3dnRoeR.r3J5ynnSZ6KjvHxOUlV8XUrulJzQa', $foundUser->getPasswordHash()->getHash());
169+
$this->assertSame('bcrypt', $foundUser->getPasswordHash()->getAlgorithm());
170170
}
171171

172172
#[Depends('testValidateDestinationErrors')]
@@ -190,9 +190,9 @@ public function testValidateDatabaseTransfer($state)
190190
$this->fail('Database "public" not found');
191191
}
192192

193-
$this->assertEquals('success', $foundDatabase->getStatus());
194-
$this->assertEquals('public', $foundDatabase->getDatabaseName());
195-
$this->assertEquals('public', $foundDatabase->getId());
193+
$this->assertSame('success', $foundDatabase->getStatus());
194+
$this->assertSame('public', $foundDatabase->getDatabaseName());
195+
$this->assertSame('public', $foundDatabase->getId());
196196

197197
// Find Known Tables
198198
$tables = $state['source']->cache->get(Resource::TYPE_TABLE);
@@ -213,10 +213,10 @@ public function testValidateDatabaseTransfer($state)
213213
$this->fail('Table "test" not found');
214214
}
215215

216-
$this->assertEquals('success', $foundTable->getStatus());
217-
$this->assertEquals('test', $foundTable->getTableName());
218-
$this->assertEquals('public', $foundTable->getDatabase()->getDatabaseName());
219-
$this->assertEquals('public', $foundTable->getDatabase()->getId());
216+
$this->assertSame('success', $foundTable->getStatus());
217+
$this->assertSame('test', $foundTable->getTableName());
218+
$this->assertSame('public', $foundTable->getDatabase()->getDatabaseName());
219+
$this->assertSame('public', $foundTable->getDatabase()->getId());
220220

221221
// Find Known Documents
222222
$documents = $state['source']->cache->get(Resource::TYPE_ROW);
@@ -237,7 +237,7 @@ public function testValidateDatabaseTransfer($state)
237237
// $this->fail('Document "1" not found');
238238
// }
239239
//
240-
// $this->assertEquals('success', $foundDocument->getStatus());
240+
// $this->assertSame('success', $foundDocument->getStatus());
241241

242242
return $state;
243243
}
@@ -262,10 +262,10 @@ public function testDatabaseFunctionalDefaultsWarn($state): void
262262
$this->fail('Table "FunctionalDefaultTestTable" not found');
263263
}
264264

265-
$this->assertEquals('warning', $foundTable->getStatus());
266-
$this->assertEquals('FunctionalDefaultTestTable', $foundTable->getTableName());
267-
$this->assertEquals('FunctionalDefaultTestTable', $foundTable->getId());
268-
$this->assertEquals('public', $foundTable->getDatabase()->getId());
265+
$this->assertSame('warning', $foundTable->getStatus());
266+
$this->assertSame('FunctionalDefaultTestTable', $foundTable->getTableName());
267+
$this->assertSame('FunctionalDefaultTestTable', $foundTable->getId());
268+
$this->assertSame('public', $foundTable->getDatabase()->getId());
269269
}
270270

271271
#[Depends('testValidateDestinationErrors')]
@@ -290,7 +290,7 @@ public function testValidateStorageTransfer($state): void
290290
$this->fail('Bucket "Test Bucket 1" not found');
291291
}
292292

293-
$this->assertEquals('success', $foundBucket->getStatus());
293+
$this->assertSame('success', $foundBucket->getStatus());
294294

295295
// Find known file
296296
$files = $state['source']->cache->get(Resource::TYPE_FILE);
@@ -311,10 +311,10 @@ public function testValidateStorageTransfer($state): void
311311
$this->fail('File "tulips.png" not found');
312312
}
313313
/** @var File $foundFile */
314-
$this->assertEquals('success', $foundFile->getStatus());
315-
$this->assertEquals('tulips.png', $foundFile->getFileName());
316-
$this->assertEquals('image/png', $foundFile->getMimeType());
317-
$this->assertEquals(679233, $foundFile->getSize());
318-
$this->assertEquals('', $foundFile->getData()); // Memory Leak Check
314+
$this->assertSame('success', $foundFile->getStatus());
315+
$this->assertSame('tulips.png', $foundFile->getFileName());
316+
$this->assertSame('image/png', $foundFile->getMimeType());
317+
$this->assertSame(679233, $foundFile->getSize());
318+
$this->assertSame('', $foundFile->getData()); // Memory Leak Check
319319
}
320320
}

tests/Migration/Unit/General/CSVTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testDetectDelimiter()
7070
$delimiter = $this->detectDelimiter($stream);
7171
fclose($stream);
7272

73-
$this->assertEquals($case['expected'], $delimiter, "Failed for {$case['file']}");
73+
$this->assertSame($case['expected'], $delimiter, "Failed for {$case['file']}");
7474
}
7575
}
7676

@@ -105,7 +105,7 @@ public function testCSVExportBasic()
105105
$csvDestination->testableImport([$row1, $row2], function ($resources) {
106106
// Callback - verify resources are marked as successful
107107
foreach ($resources as $resource) {
108-
$this->assertEquals('success', $resource->getStatus());
108+
$this->assertSame('success', $resource->getStatus());
109109
}
110110
});
111111

@@ -138,12 +138,12 @@ public function testCSVExportBasic()
138138
$this->assertContains('email', $header);
139139

140140
// Check first row data
141-
$this->assertEquals('row1', $row1Data[0]); // $id
141+
$this->assertSame('row1', $row1Data[0]); // $id
142142
$this->assertStringContainsString('user:123', $row1Data[1]); // $permissions
143143
// $createdAt and $updatedAt are empty for test data
144-
$this->assertEquals('John Doe', $row1Data[4]); // name
145-
$this->assertEquals('30', $row1Data[5]); // age
146-
$this->assertEquals('john@example.com', $row1Data[6]); // email
144+
$this->assertSame('John Doe', $row1Data[4]); // name
145+
$this->assertSame('30', $row1Data[5]); // age
146+
$this->assertSame('john@example.com', $row1Data[6]); // email
147147

148148
// Cleanup
149149
if (is_dir($tempDir)) {
@@ -187,10 +187,10 @@ public function testCSVExportWithSpecialCharacters()
187187

188188
// Verify special characters are properly handled
189189
// Indices are shifted by 2 due to $createdAt and $updatedAt
190-
$this->assertEquals('Text with "quotes"', $rowData[4]); // quote_field
191-
$this->assertEquals('Text, with, commas', $rowData[5]); // comma_field
192-
$this->assertEquals("Text with\nnewlines", $rowData[6]); // newline_field
193-
$this->assertEquals('Text with "quotes", commas, and\nnewlines', $rowData[7]); // mixed_field
190+
$this->assertSame('Text with "quotes"', $rowData[4]); // quote_field
191+
$this->assertSame('Text, with, commas', $rowData[5]); // comma_field
192+
$this->assertSame("Text with\nnewlines", $rowData[6]); // newline_field
193+
$this->assertSame('Text with "quotes", commas, and\nnewlines', $rowData[7]); // mixed_field
194194

195195
// Cleanup
196196
if (is_dir($tempDir)) {
@@ -233,9 +233,9 @@ public function testCSVExportWithArrays()
233233

234234
// Arrays should be JSON encoded
235235
// Indices are shifted by 2 due to $createdAt and $updatedAt
236-
$this->assertEquals('["php","csv","export"]', $rowData[4]); // tags
236+
$this->assertSame('["php","csv","export"]', $rowData[4]); // tags
237237
$this->assertJson($rowData[5]); // metadata should be valid JSON
238-
$this->assertEquals('', $rowData[6]); // empty_array
238+
$this->assertSame('', $rowData[6]); // empty_array
239239
$this->assertJson($rowData[7]); // nested should be valid JSON
240240

241241
// Cleanup
@@ -279,11 +279,11 @@ public function testCSVExportWithNullValues()
279279
$this->assertNotFalse($rowData);
280280

281281
// Indices are shifted by 2 due to $createdAt and $updatedAt
282-
$this->assertEquals('Test', $rowData[4]); // name
283-
$this->assertEquals('null', $rowData[5]); // null_field -> "null" string
284-
$this->assertEquals('', $rowData[6]); // empty_string
285-
$this->assertEquals('0', $rowData[7]); // zero
286-
$this->assertEquals('false', $rowData[8]); // false_bool
282+
$this->assertSame('Test', $rowData[4]); // name
283+
$this->assertSame('null', $rowData[5]); // null_field -> "null" string
284+
$this->assertSame('', $rowData[6]); // empty_string
285+
$this->assertSame('0', $rowData[7]); // zero
286+
$this->assertSame('false', $rowData[8]); // false_bool
287287

288288
// Cleanup
289289
if (is_dir($tempDir)) {
@@ -385,12 +385,12 @@ public function testCSVExportImportCompatibility()
385385
// Verify we can reconstruct the data
386386
$reconstructed = \array_combine($header, $data);
387387

388-
$this->assertEquals('compat_row', $reconstructed['$id']);
389-
$this->assertEquals('John Doe', $reconstructed['name']);
390-
$this->assertEquals('30', $reconstructed['age']);
391-
$this->assertEquals('null', $reconstructed['null_field']); // null becomes "null" string
392-
$this->assertEquals('', $reconstructed['empty_field']);
393-
$this->assertEquals('true', $reconstructed['bool_field']); // bool becomes string
388+
$this->assertSame('compat_row', $reconstructed['$id']);
389+
$this->assertSame('John Doe', $reconstructed['name']);
390+
$this->assertSame('30', $reconstructed['age']);
391+
$this->assertSame('null', $reconstructed['null_field']); // null becomes "null" string
392+
$this->assertSame('', $reconstructed['empty_field']);
393+
$this->assertSame('true', $reconstructed['bool_field']); // bool becomes string
394394
// Check that createdAt and updatedAt are in the reconstructed data
395395
$this->assertArrayHasKey('$createdAt', $reconstructed);
396396
$this->assertArrayHasKey('$updatedAt', $reconstructed);
@@ -402,8 +402,8 @@ public function testCSVExportImportCompatibility()
402402
$tagsArray = json_decode($reconstructed['tags'], true);
403403
$metadataArray = json_decode($reconstructed['metadata'], true);
404404

405-
$this->assertEquals(['php', 'csv'], $tagsArray);
406-
$this->assertEquals(['key' => 'value'], $metadataArray);
405+
$this->assertSame(['php', 'csv'], $tagsArray);
406+
$this->assertSame(['key' => 'value'], $metadataArray);
407407

408408
// Cleanup
409409
if (is_dir($tempDir)) {

tests/Migration/Unit/General/TransferTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testRootResourceId(): void
3939
$this->transfer->run([Resource::TYPE_USER, Resource::TYPE_DATABASE], function () {}, 'rootResourceId');
4040
$this->fail('Multiple root resources should not be allowed');
4141
} catch (\Exception $e) {
42-
$this->assertEquals('Resource type must be set when resource ID is set.', $e->getMessage());
42+
$this->assertSame('Resource type must be set when resource ID is set.', $e->getMessage());
4343
}
4444

4545
$this->source->pushMockResource(new Database('test', 'test'));
@@ -59,7 +59,7 @@ function () {},
5959
$database = $this->destination->getResourceById(Transfer::GROUP_DATABASES, Resource::TYPE_DATABASE, 'test');
6060
/** @var Database $database */
6161
$this->assertNotNull($database);
62-
$this->assertEquals('test', $database->getDatabaseName());
63-
$this->assertEquals('test', $database->getId());
62+
$this->assertSame('test', $database->getDatabaseName());
63+
$this->assertSame('test', $database->getId());
6464
}
6565
}

0 commit comments

Comments
 (0)