Skip to content

Commit 68aa5ef

Browse files
authored
Change HasOne type to integer by default (#811)
1 parent ec19611 commit 68aa5ef

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

src/Reference/HasOne.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class HasOne extends Reference
2020
*
2121
* Values are: 'string', 'text', 'boolean', 'integer', 'money', 'float',
2222
* 'date', 'datetime', 'time', 'array', 'object'.
23-
* Can also be set to unspecified type for your own custom handling.
2423
*
2524
* @var string
2625
*/
27-
public $type;
26+
public $type = 'integer';
2827

2928
/**
3029
* Is it system field?

tests/RandomTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function testSameTable()
182182
$m = new Model_Item($db, 'item');
183183

184184
$this->assertSame(
185-
['id' => 3, 'name' => 'Smith', 'parent_item_id' => '2', 'parent_item' => 'Sue'],
185+
['id' => 3, 'name' => 'Smith', 'parent_item_id' => 2, 'parent_item' => 'Sue'],
186186
$m->load(3)->get()
187187
);
188188
}
@@ -206,7 +206,7 @@ public function testSameTable2()
206206
$m = new Model_Item2($db, 'item');
207207

208208
$this->assertSame(
209-
['id' => 3, 'name' => 'Smith', 'parent_item_id' => '2', 'parent_item' => 'Sue'],
209+
['id' => 3, 'name' => 'Smith', 'parent_item_id' => 2, 'parent_item' => 'Sue'],
210210
$m->load(3)->get()
211211
);
212212
}

tests/ReferenceSqlTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -390,21 +390,21 @@ public function testReferenceHasOneTraversing()
390390
$firstUserOrders->setOrder('id');
391391

392392
$this->assertEquals([
393-
['id' => '1', 'company_id' => '1', 'description' => 'Vinny Company Order 1', 'amount' => 50.0],
394-
['id' => '3', 'company_id' => '1', 'description' => 'Vinny Company Order 2', 'amount' => 15.0],
393+
['id' => '1', 'company_id' => 1, 'description' => 'Vinny Company Order 1', 'amount' => 50.0],
394+
['id' => '3', 'company_id' => 1, 'description' => 'Vinny Company Order 2', 'amount' => 15.0],
395395
], $firstUserOrders->export());
396396

397397
$user->unload();
398398

399399
$this->assertEquals([
400-
['id' => '1', 'company_id' => '1', 'description' => 'Vinny Company Order 1', 'amount' => 50.0],
401-
['id' => '3', 'company_id' => '1', 'description' => 'Vinny Company Order 2', 'amount' => 15.0],
400+
['id' => '1', 'company_id' => 1, 'description' => 'Vinny Company Order 1', 'amount' => 50.0],
401+
['id' => '3', 'company_id' => 1, 'description' => 'Vinny Company Order 2', 'amount' => 15.0],
402402
], $firstUserOrders->export());
403403

404404
$this->assertEquals([
405-
['id' => '1', 'company_id' => '1', 'description' => 'Vinny Company Order 1', 'amount' => 50.0],
406-
['id' => '2', 'company_id' => '2', 'description' => 'Zoe Company Order', 'amount' => 10.0],
407-
['id' => '3', 'company_id' => '1', 'description' => 'Vinny Company Order 2', 'amount' => 15.0],
405+
['id' => '1', 'company_id' => 1, 'description' => 'Vinny Company Order 1', 'amount' => 50.0],
406+
['id' => '2', 'company_id' => 2, 'description' => 'Zoe Company Order', 'amount' => 10.0],
407+
['id' => '3', 'company_id' => 1, 'description' => 'Vinny Company Order 2', 'amount' => 15.0],
408408
], $user->ref('Company')->ref('Orders')->setOrder('id')->export());
409409
}
410410

@@ -464,8 +464,8 @@ public function testIdFieldReferenceOurFieldCase()
464464
['name' => 'Ronaldo'],
465465
],
466466
'stadium' => [
467-
['name' => 'Sue bernabeu', 'player_id' => '3'],
468-
['name' => 'John camp', 'player_id' => '1'],
467+
['name' => 'Sue bernabeu', 'player_id' => 3],
468+
['name' => 'John camp', 'player_id' => 1],
469469
],
470470
]);
471471

@@ -480,7 +480,7 @@ public function testIdFieldReferenceOurFieldCase()
480480
$p->load(2);
481481
$p->ref('Stadium')->import([['name' => 'Nou camp nou']]);
482482
$this->assertSame('Nou camp nou', $p->ref('Stadium')->get('name'));
483-
$this->assertSame('2', $p->ref('Stadium')->get('player_id'));
483+
$this->assertSame(2, $p->ref('Stadium')->get('player_id'));
484484
}
485485

486486
public function testModelProperty()

tests/SmboTransferTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public function testTransfer()
6464
return $e1['id'] < $e2['id'] ? -1 : 1;
6565
});
6666
$this->assertSame([
67-
['id' => 1, 'transfer_document_id' => '2'],
68-
['id' => 2, 'transfer_document_id' => '1'],
67+
['id' => 1, 'transfer_document_id' => 2],
68+
['id' => 2, 'transfer_document_id' => 1],
6969
], $data);
7070
}
7171

0 commit comments

Comments
 (0)