Skip to content

Commit ea68b61

Browse files
committed
Switch to job table instead of new task table
1 parent 789b35d commit ea68b61

3 files changed

Lines changed: 58 additions & 71 deletions

File tree

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ 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-
5443
// Misc Table
5544
$this->forge->addField([
5645
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
@@ -193,7 +182,6 @@ public function down(): void
193182
{
194183
$this->forge->dropTable('user', true);
195184
$this->forge->dropTable('job', true);
196-
$this->forge->dropTable('task', true);
197185
$this->forge->dropTable('misc', true);
198186
$this->forge->dropTable('type_test', true);
199187
$this->forge->dropTable('empty', true);

tests/system/Database/Live/IncrementTest.php

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -69,73 +69,73 @@ public function testResetStateAfterIncrement(): void
6969

7070
public function testIncrementMany(): void
7171
{
72-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
72+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
7373

74-
$this->db->table('task')
75-
->where('name', 'task1')
76-
->incrementMany(['description' => 2, 'priority' => 3]);
74+
$this->db->table('job')
75+
->where('name', 'job1')
76+
->incrementMany(['description' => 2, 'created_at' => 3]);
7777

78-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '8', 'priority' => '4']);
78+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '8', 'created_at' => 4]);
7979
}
8080

8181
public function testIncrementManyWithValue(): void
8282
{
83-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
83+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
8484

85-
$this->db->table('task')
86-
->where('name', 'task1')
87-
->incrementMany(['description', 'priority'], 2);
85+
$this->db->table('job')
86+
->where('name', 'job1')
87+
->incrementMany(['description', 'created_at'], 2);
8888

89-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '8', 'priority' => '3']);
89+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '8', 'created_at' => 3]);
9090
}
9191

9292
public function testIncrementManyWithNegativeValue(): void
9393
{
94-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
94+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
9595

96-
$this->db->table('task')
97-
->where('name', 'task1')
98-
->incrementMany(['description' => 2, 'priority' => -1]);
96+
$this->db->table('job')
97+
->where('name', 'job1')
98+
->incrementMany(['description' => 2, 'created_at' => -1]);
9999

100-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '8', 'priority' => '0']);
100+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '8', 'created_at' => 0]);
101101
}
102102

103103
public function testIncrementManyWithEmptyColumns(): void
104104
{
105-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
105+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
106106

107107
$this->expectException(InvalidArgumentException::class);
108108
$this->expectExceptionMessage('Argument #1 ($columns) cannot be empty.');
109109

110-
$this->db->table('task')
110+
$this->db->table('job')
111111
->where('name', 'task1')
112112
->incrementMany([]);
113113
}
114114

115115
public function testIncrementManyWithNonIntegerValues(): void
116116
{
117-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
117+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
118118

119119
$this->expectException(TypeError::class);
120-
$this->expectExceptionMessage('Argument #1 ($columns) must contain only int values, string given for "priority".');
120+
$this->expectExceptionMessage('Argument #1 ($columns) must contain only int values, string given for "created_at".');
121121

122-
$this->db->table('task')
123-
->where('name', 'task1')
124-
->incrementMany(['description' => 2, 'priority' => 'wrongValue']);
122+
$this->db->table('job')
123+
->where('name', 'job1')
124+
->incrementMany(['description' => 2, 'created_at' => 'wrongValue']);
125125
}
126126

127127
public function testResetStateAfterIncrementMany(): void
128128
{
129-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
130-
$this->hasInDatabase('task', ['name' => 'task2', 'description' => '2', 'priority' => '4']);
129+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
130+
$this->hasInDatabase('job', ['name' => 'job2', 'description' => '2', 'created_at' => 4]);
131131

132-
$builder = $this->db->table('task');
132+
$builder = $this->db->table('job');
133133

134-
$builder->where('name', 'task1')->incrementMany(['description', 'priority']);
135-
$builder->where('name', 'task2')->incrementMany(['description', 'priority']);
134+
$builder->where('name', 'job1')->incrementMany(['description', 'created_at']);
135+
$builder->where('name', 'job2')->incrementMany(['description', 'created_at']);
136136

137-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '7', 'priority' => '2']);
138-
$this->seeInDatabase('task', ['name' => 'task2', 'description' => '3', 'priority' => '5']);
137+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '7', 'created_at' => 2]);
138+
$this->seeInDatabase('job', ['name' => 'job2', 'description' => '3', 'created_at' => 5]);
139139
}
140140

141141
public function testDecrement(): void
@@ -176,72 +176,72 @@ public function testResetStateAfterDecrement(): void
176176

177177
public function testDecrementMany(): void
178178
{
179-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
179+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
180180

181-
$this->db->table('task')
182-
->where('name', 'task1')
183-
->decrementMany(['description' => 2, 'priority' => 3]);
181+
$this->db->table('job')
182+
->where('name', 'job1')
183+
->decrementMany(['description' => 2, 'created_at' => 3]);
184184

185-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '4', 'priority' => '-2']);
185+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '4', 'created_at' => -2]);
186186
}
187187

188188
public function testDecrementManyWithValue(): void
189189
{
190-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
190+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
191191

192-
$this->db->table('task')
193-
->where('name', 'task1')
194-
->decrementMany(['description', 'priority'], 2);
192+
$this->db->table('job')
193+
->where('name', 'job1')
194+
->decrementMany(['description', 'created_at'], 2);
195195

196-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '4', 'priority' => '-1']);
196+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '4', 'created_at' => -1]);
197197
}
198198

199199
public function testDecrementManyWithNegativeValues(): void
200200
{
201-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
201+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
202202

203-
$this->db->table('task')
204-
->where('name', 'task1')
205-
->decrementMany(['description' => 2, 'priority' => -1]);
203+
$this->db->table('job')
204+
->where('name', 'job1')
205+
->decrementMany(['description' => 2, 'created_at' => -1]);
206206

207-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '4', 'priority' => '2']);
207+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '4', 'created_at' => 2]);
208208
}
209209

210210
public function testDecrementManyWithEmptyColumns(): void
211211
{
212-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
212+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
213213

214214
$this->expectException(InvalidArgumentException::class);
215215
$this->expectExceptionMessage('Argument #1 ($columns) cannot be empty.');
216216

217-
$this->db->table('task')
217+
$this->db->table('job')
218218
->where('name', 'task1')
219219
->decrementMany([]);
220220
}
221221

222222
public function testDecrementManyWithNonIntegerValues(): void
223223
{
224-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
224+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
225225

226226
$this->expectException(TypeError::class);
227-
$this->expectExceptionMessage('Argument #1 ($columns) must contain only int values, string given for "priority".');
227+
$this->expectExceptionMessage('Argument #1 ($columns) must contain only int values, string given for "created_at".');
228228

229-
$this->db->table('task')
230-
->where('name', 'task1')
231-
->decrementMany(['description' => 2, 'priority' => 'wrongValue']);
229+
$this->db->table('job')
230+
->where('name', 'job1')
231+
->decrementMany(['description' => 2, 'created_at' => 'wrongValue']);
232232
}
233233

234234
public function testResetStateAfterDecrementMany(): void
235235
{
236-
$this->hasInDatabase('task', ['name' => 'task1', 'description' => '6', 'priority' => '1']);
237-
$this->hasInDatabase('task', ['name' => 'task2', 'description' => '2', 'priority' => '4']);
236+
$this->hasInDatabase('job', ['name' => 'job1', 'description' => '6', 'created_at' => 1]);
237+
$this->hasInDatabase('job', ['name' => 'job2', 'description' => '2', 'created_at' => 4]);
238238

239-
$builder = $this->db->table('task');
239+
$builder = $this->db->table('job');
240240

241-
$builder->where('name', 'task1')->decrementMany(['description', 'priority']);
242-
$builder->where('name', 'task2')->decrementMany(['description', 'priority']);
241+
$builder->where('name', 'job1')->decrementMany(['description', 'created_at']);
242+
$builder->where('name', 'job2')->decrementMany(['description', 'created_at']);
243243

244-
$this->seeInDatabase('task', ['name' => 'task1', 'description' => '5', 'priority' => '0']);
245-
$this->seeInDatabase('task', ['name' => 'task2', 'description' => '1', 'priority' => '3']);
244+
$this->seeInDatabase('job', ['name' => 'job1', 'description' => '5', 'created_at' => 0]);
245+
$this->seeInDatabase('job', ['name' => 'job2', 'description' => '1', 'created_at' => 3]);
246246
}
247247
}

tests/system/Database/Live/MetadataTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ protected function setUp(): void
4040
$prefix . 'migrations',
4141
$prefix . 'user',
4242
$prefix . 'job',
43-
$prefix . 'task',
4443
$prefix . 'misc',
4544
$prefix . 'team_members',
4645
$prefix . 'type_test',

0 commit comments

Comments
 (0)