Skip to content

Commit bff9dc8

Browse files
committed
feat: add task table and related seeder
1 parent afc7f0c commit bff9dc8

4 files changed

Lines changed: 52 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public function up(): void
4040
'deleted_at' => ['type' => 'INTEGER', 'constraint' => 11, 'null' => true],
4141
])->addKey('id', true)->createTable('job', true);
4242

43+
// Task Table
44+
$this->forge->addField([
45+
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
46+
'name' => ['type' => 'VARCHAR', 'constraint' => 40],
47+
'description' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
48+
'priority' => ['type' => 'VARCHAR', 'constraint' => 40, 'null' => true],
49+
'created_at' => ['type' => 'INTEGER', 'constraint' => 11, 'null' => true],
50+
'updated_at' => ['type' => 'INTEGER', 'constraint' => 11, 'null' => true],
51+
'deleted_at' => ['type' => 'INTEGER', 'constraint' => 11, 'null' => true],
52+
])->addKey('id', true)->createTable('task', true);
53+
4354
// Misc Table
4455
$this->forge->addField([
4556
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
@@ -182,6 +193,7 @@ public function down(): void
182193
{
183194
$this->forge->dropTable('user', true);
184195
$this->forge->dropTable('job', true);
196+
$this->forge->dropTable('task', true);
185197
$this->forge->dropTable('misc', true);
186198
$this->forge->dropTable('type_test', true);
187199
$this->forge->dropTable('empty', true);

tests/_support/Database/Seeds/CITestSeeder.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ public function run(): void
6060
'description' => 'Only Coldplay can actually called Musician',
6161
],
6262
],
63+
'task' => [
64+
[
65+
'name' => 'Grocery',
66+
'description' => 'Go to the grocery store and buy some food',
67+
'priority' => '1',
68+
],
69+
[
70+
'name' => 'Write Tests',
71+
'description' => 'Write tests for the application',
72+
'priority' => '2',
73+
],
74+
[
75+
'name' => 'Fix Bug',
76+
'description' => 'Fix the bug and report to the manager',
77+
'priority' => '3',
78+
],
79+
],
6380
'misc' => [
6481
[
6582
'key' => '\\xxxfoo456',

tests/system/Database/Live/IncrementTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ public function testIncrementWithValue(): void
5151
$this->seeInDatabase('job', ['name' => 'incremental', 'description' => '8']);
5252
}
5353

54+
public function testIncrementWithMultipleColumns(): void
55+
{
56+
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
57+
58+
$this->db->table('task')
59+
->where('name', 'task1')
60+
->increment(['description' => 2, 'priority' => 3]);
61+
62+
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '8', 'priority' => '4']);
63+
}
64+
5465
public function testResetStateAfterIncrement(): void
5566
{
5667
$this->hasInDatabase('job', ['name' => 'account1', 'description' => '10']);
@@ -87,6 +98,17 @@ public function testDecrementWithValue(): void
8798
$this->seeInDatabase('job', ['name' => 'incremental', 'description' => '4']);
8899
}
89100

101+
public function testDecrementWithMultipleColumns(): void
102+
{
103+
$this->hasInDatabase('task', ['name' => 'task2', 'description' => '6', 'priority' => '5']);
104+
105+
$this->db->table('task')
106+
->where('name', 'task2')
107+
->decrement(['description' => 2, 'priority' => 3]);
108+
109+
$this->seeInDatabase('task', ['name' => 'task2', 'description' => '4', 'priority' => '2']);
110+
}
111+
90112
public function testResetStateAfterDecrement(): void
91113
{
92114
$this->hasInDatabase('job', ['name' => 'account1', 'description' => '10']);

tests/system/Database/Live/MetadataTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ protected function setUp(): void
4040
$prefix . 'migrations',
4141
$prefix . 'user',
4242
$prefix . 'job',
43+
$prefix . 'task',
4344
$prefix . 'misc',
4445
$prefix . 'team_members',
4546
$prefix . 'type_test',

0 commit comments

Comments
 (0)