Skip to content

Commit f67babc

Browse files
committed
update tests
1 parent 1625eaf commit f67babc

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

tests/_support/Database/Migrations/20160428212500_Create_test_tables.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ public function up(): void
4747
'value' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
4848
])->addKey('id', true)->createTable('misc', true);
4949

50+
// Team members Table (composite key)
5051
$this->forge->addField([
51-
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
52-
'city' => ['type' => 'VARCHAR', 'constraint' => 40],
53-
'country' => ['type' => 'VARCHAR', 'constraint' => 40],
54-
'population' => ['type' => 'INTEGER', 'constraint' => 3, 'unsigned' => true, 'null' => true],
52+
'team_id' => ['type' => 'INTEGER', 'constraint' => 3],
53+
'person_id' => ['type' => 'INTEGER', 'constraint' => 3],
54+
'role' => ['type' => 'VARCHAR', 'constraint' => 40],
55+
'status' => ['type' => 'VARCHAR', 'constraint' => 40],
5556
'created_at' => ['type' => 'DATETIME', 'null' => true],
56-
'updated_at' => ['type' => 'DATETIME', 'null' => true],
57-
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
58-
])->addKey('id', true)->addUniqueKey(['city', 'country'])->createTable('cities', true);
57+
])->addUniqueKey(['team_id', 'person_id'])->createTable('team_members', true);
5958

6059
// Database Type test table
6160
// missing types:

tests/_support/Database/Seeds/CITestSeeder.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,18 @@ public function run(): void
107107
'value' => 'ടൈപ്പ്',
108108
],
109109
],
110-
'cities' => [
110+
'team_members' => [
111111
[
112-
'city' => 'Tokyo',
113-
'country' => 'Japan',
114-
'population' => 37_115_035,
112+
'team_id' => 1,
113+
'person_id' => 22,
114+
'role' => 'member',
115+
'status' => 'active',
115116
],
116117
[
117-
'city' => 'Delhi',
118-
'country' => 'India',
119-
'population' => 33_807_403,
118+
'team_id' => 1,
119+
'person_id' => 33,
120+
'role' => 'mentor',
121+
'status' => 'active',
120122
],
121123
],
122124
'type_test' => [

tests/system/Database/Live/MetadataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ protected function setUp(): void
4444

4545
$tables = [
4646
$prefix . 'migrations',
47-
$prefix . 'cities',
4847
$prefix . 'user',
4948
$prefix . 'job',
5049
$prefix . 'misc',
50+
$prefix . 'team_members',
5151
$prefix . 'type_test',
5252
$prefix . 'empty',
5353
$prefix . 'secondary',

tests/system/Database/Live/UpsertTest.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -614,24 +614,27 @@ public function testUpsertBatchCompositeUniqueIndex(): void
614614
{
615615
$data = [
616616
[
617-
'id' => 1,
618-
'city' => 'Tokyo',
619-
'country' => 'Japan',
620-
'population' => 222,
617+
'team_id' => 1,
618+
'person_id' => 22,
619+
'role' => 'leader',
620+
'status' => 'active',
621621
],
622622
[
623-
'id' => 2,
624-
'city' => 'Delhi',
625-
'country' => 'India',
626-
'population' => 111,
623+
'team_id' => 1,
624+
'person_id' => 33,
625+
'role' => 'member',
626+
'status' => 'active',
627627
],
628628
];
629629

630-
// uses city_country (city,country) - composite unique index
631-
$this->db->table('cities')->upsertBatch($data);
630+
// uses (team_id, person_id) - composite unique index
631+
$this->db->table('team_members')->upsertBatch($data);
632632

633-
$this->seeInDatabase('cities', ['id' => 1, 'population' => 222]);
634-
$this->seeInDatabase('cities', ['id' => 2, 'population' => 111]);
633+
$this->seeInDatabase('team_members', ['team_id' => 1, 'person_id' => 22, 'role' => 'leader']);
634+
$this->dontSeeInDatabase('team_members', ['team_id' => 1, 'person_id' => 22, 'role' => 'member']);
635+
636+
$this->seeInDatabase('team_members', ['team_id' => 1, 'person_id' => 33, 'role' => 'member']);
637+
$this->dontSeeInDatabase('team_members', ['team_id' => 1, 'person_id' => 33, 'role' => 'mentor']);
635638
}
636639

637640
public function testSetBatchOneRow(): void

0 commit comments

Comments
 (0)