Skip to content

Commit ba522b7

Browse files
committed
Add table to tests
1 parent 1c1eb75 commit ba522b7

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/_support/Database/Migrations/2019-09-02-092335_create_test_tables.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ public function up()
136136
$this->forge->addForeignKey('servicer_id', 'servicers', 'id', false, 'CASCADE');
137137

138138
$this->forge->createTable('lawyers');
139+
140+
// Lawsuits
141+
$fields = [
142+
'client' => ['type' => 'int', 'null' => true],
143+
'factory_id' => ['type' => 'int', 'null' => true],
144+
'lawyer_id' => ['type' => 'int', 'null' => true],
145+
'created_at' => ['type' => 'datetime', 'null' => true],
146+
'updated_at' => ['type' => 'datetime', 'null' => true],
147+
'deleted_at' => ['type' => 'datetime', 'null' => true],
148+
];
149+
150+
$this->forge->addField('id');
151+
$this->forge->addField($fields);
152+
153+
$this->forge->addForeignKey('client', 'workers', 'id', false, 'CASCADE');
154+
$this->forge->addKey('lawyer_id');
155+
$this->forge->addKey(['deleted_at', 'id']);
156+
$this->forge->addKey('created_at');
157+
158+
$this->forge->createTable('lawsuits');
139159

140160
$this->db->enableForeignKeyChecks();
141161
}

tests/_support/Database/Seeds/TestSeeder.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,19 @@ public function run()
224224
{
225225
$builder->insert($lawyer);
226226
}
227+
228+
// Lawsuits
229+
$lawsuits = [
230+
['client' => 2, 'factory_id' => 1, 'lawyer_id' => 1],
231+
['client' => 8, 'factory_id' => 2, 'lawyer_id' => 5],
232+
['client' => 4, 'factory_id' => 3, 'lawyer_id' => 2],
233+
['client' => 5, 'factory_id' => 3, 'lawyer_id' => 5, 'deleted_at' => date('Y-m-d H:i:s')],
234+
];
235+
236+
$builder = $this->db->table('lawsuits');
237+
foreach ($lawsuits as $lawsuit)
238+
{
239+
$builder->insert($lawsuit);
240+
}
227241
}
228242
}

0 commit comments

Comments
 (0)