Test more migrations

This commit is contained in:
Daniil Gentili 2024-03-28 23:21:13 +01:00
parent b6a82d17ce
commit e2981bbefd

View File

@ -148,6 +148,12 @@ final class OrmTest extends TestCase
$orm = $field->build(); $orm = $field->build();
$orm[$key] = $value; $orm[$key] = $value;
[$a, $b] = await([
async($orm->get(...), $key),
async($orm->get(...), $key),
]);
$this->assertSameNotObject($value, $a);
$this->assertSameNotObject($value, $b);
$this->assertSameNotObject($value, $orm[$key]); $this->assertSameNotObject($value, $orm[$key]);
$this->assertTrue(isset($orm[$key])); $this->assertTrue(isset($orm[$key]));
if (!$value instanceof DbObject) { if (!$value instanceof DbObject) {
@ -208,6 +214,8 @@ final class OrmTest extends TestCase
$this->assertCount(0, $orm); $this->assertCount(0, $orm);
$orm[$key] = $value; $orm[$key] = $value;
$this->assertCount(1, $orm); $this->assertCount(1, $orm);
$orm[$key] = $value;
$this->assertCount(1, $orm);
$cnt = 0; $cnt = 0;
foreach ($orm as $kk => $vv) { foreach ($orm as $kk => $vv) {
$cnt++; $cnt++;
@ -303,6 +311,25 @@ final class OrmTest extends TestCase
$this->assertSame(123, $vv); $this->assertSame(123, $vv);
} }
$this->assertEquals(1, $cnt); $this->assertEquals(1, $cnt);
$field = new FieldConfig(
$table.'_new',
$settings,
KeyType::INT,
ValueType::INT
);
$orm = $field->build($orm);
$this->assertSame(123, $orm[321]);
$this->assertTrue(isset($orm[321]));
$cnt = 0;
foreach ($orm as $kk => $vv) {
$cnt++;
$this->assertSame(321, $kk);
$this->assertSame(123, $vv);
}
$this->assertEquals(1, $cnt);
} }
#[DataProvider('provideSettings')] #[DataProvider('provideSettings')]