Skip to content

Commit 17988b4

Browse files
committed
update ContainsOneTest
1 parent 74262f2 commit 17988b4

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

tests/ContainsOneTest.php

+42-9
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
class Invoice1 extends Model
2323
{
2424
public $table = 'invoice';
25-
public $title_field = 'ref_no';
2625

2726
protected function init(): void
2827
{
2928
parent:: init();
3029

30+
$this->title_field = 'ref_no';
31+
3132
$this->addField('ref_no', ['required' => true]);
3233

3334
// will contain one Address
@@ -103,14 +104,28 @@ protected function setUp(): void
103104
// fill in some default values
104105
$m = new Country1($this->db);
105106
$m->import([
106-
['id' => 1, 'name' => 'Latvia'],
107-
['id' => 2, 'name' => 'United Kingdom'],
107+
[
108+
'id' => 1,
109+
'name' => 'Latvia',
110+
],
111+
[
112+
'id' => 2,
113+
'name' => 'United Kingdom',
114+
],
108115
]);
109116

110117
$m = new Invoice1($this->db);
111118
$m->import([
112-
['id' => 1, 'ref_no' => 'A1', 'addr' => null],
113-
['id' => 2, 'ref_no' => 'A2', 'addr' => null],
119+
[
120+
'id' => 1,
121+
'ref_no' => 'A1',
122+
'addr' => null,
123+
],
124+
[
125+
'id' => 2,
126+
'ref_no' => 'A2',
127+
'addr' => null,
128+
],
114129
]);
115130
}
116131

@@ -140,7 +155,14 @@ public function testContainsOne()
140155
$this->assertFalse($a->loaded());
141156

142157
// now store some address
143-
$a->setMulti($row = ['id' => 1, 'country_id' => 1, 'address' => 'foo', 'built_date' => new \DateTime('2019-01-01'), 'tags' => ['foo', 'bar'], 'door_code' => null]);
158+
$a->setMulti($row = [
159+
'id' => 1,
160+
'country_id' => 1,
161+
'address' => 'foo',
162+
'built_date' => new \DateTime('2019-01-01'),
163+
'tags' => ['foo', 'bar'],
164+
'door_code' => null,
165+
]);
144166
$a->save();
145167

146168
// now reload invoice and see if it is saved
@@ -154,7 +176,11 @@ public function testContainsOne()
154176

155177
// now add nested containsOne - DoorCode
156178
$c = $i->ref('addr')->ref('door_code');
157-
$c->setMulti($row = ['id' => 1, 'code' => 'ABC', 'valid_till' => new \DateTime('2019-07-01')]);
179+
$c->setMulti($row = [
180+
'id' => 1,
181+
'code' => 'ABC',
182+
'valid_till' => new \DateTime('2019-07-01'),
183+
]);
158184
$c->save();
159185
$this->assertEquals($row, $i->ref('addr')->ref('door_code')->get());
160186

@@ -203,7 +229,7 @@ public function testContainsOne()
203229
$this->assertNull($i->get('addr'));
204230
$this->assertFalse($i->ref('addr')->loaded());
205231

206-
//var_dump($i->export(), $i->export(null,null,false));
232+
//var_dump($i->export(), $i->export(null, null, false));
207233
}
208234

209235
/**
@@ -216,7 +242,14 @@ public function testContainsOneWhenChangeModelFields()
216242

217243
// with address
218244
$a = $i->ref('addr');
219-
$a->setMulti($row = ['id' => 1, 'country_id' => 1, 'address' => 'foo', 'built_date' => new \DateTime('2019-01-01'), 'tags' => [], 'door_code' => null]);
245+
$a->setMulti($row = [
246+
'id' => 1,
247+
'country_id' => 1,
248+
'address' => 'foo',
249+
'built_date' => new \DateTime('2019-01-01'),
250+
'tags' => [],
251+
'door_code' => null,
252+
]);
220253
$a->save();
221254

222255
// now let's add one more field in address model and save

0 commit comments

Comments
 (0)