Skip to content

Commit f168ab0

Browse files
committed
fix: Update select() in test
1 parent 0362d40 commit f168ab0

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

‎tests/_support/Entity/Member.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
class Member extends Entity
1919
{
2020
protected $attributes = [
21-
'id' => 'unknown',
21+
'id' => 0,
2222
'name' => 'unknown',
2323
'email' => 'unknown',
2424
'country' => 'unknown',
25-
'created_at' => 'unknown',
26-
'updated_at' => 'unknown',
27-
'deleted_at' => 'unknown',
25+
'created_at' => '2026-11-10 14:50:00',
26+
'updated_at' => '2026-11-10 14:50:00',
27+
'deleted_at' => '2026-11-10 14:50:00',
2828

2929
// The property is not stored in the database
3030
'profile' => 'unknown',

‎tests/system/Models/UpdateModelTest.php‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,10 @@ public function testUpdateEntityUpdateOnlyChangedFalse(): void
689689
#[DataProvider('provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags')]
690690
public function testUpdateOnlyChangedAndMergeAttributesOnInjectFlags(UserModel $model, array $selectedMember, array $updatedMember): void
691691
{
692-
$member = $model->select('`id`, `name`, \'new property\' as `virtual`')->withDeleted()->find(1);
692+
$member = $model->select('id, name')
693+
->select('\'new property\' AS ' . $model->db->escapeIdentifier('virtual'), false)
694+
->withDeleted()->find(1);
695+
693696
$this->assertInstanceOf(Member::class, $member);
694697
$this->assertSame($selectedMember, $member->toRawArray());
695698

@@ -699,7 +702,6 @@ public function testUpdateOnlyChangedAndMergeAttributesOnInjectFlags(UserModel $
699702
$result = $model->update(1, $member);
700703

701704
$this->assertTrue($result);
702-
703705
$memberSilentOverwrite = $model->withDeleted()->find(1);
704706

705707
$this->assertSame($updatedMember, $memberSilentOverwrite->toRawArray());
@@ -714,6 +716,9 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
714716
new class () extends UserModel {
715717
protected $returnType = Member::class;
716718
protected bool $updateOnlyChanged = true;
719+
protected array $casts = [
720+
'id' => '?int',
721+
];
717722
},
718723
[
719724
'id' => 1,
@@ -735,15 +740,18 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
735740
new class () extends UserModel {
736741
protected $returnType = MemberStrict::class;
737742
protected bool $updateOnlyChanged = true;
743+
protected array $casts = [
744+
'id' => '?int',
745+
];
738746
},
739747
[
740748
'id' => 1,
741749
'name' => 'Derek Jones',
742750
'email' => 'unknown',
743751
'country' => 'unknown',
744-
'created_at' => 'unknown',
745-
'updated_at' => 'unknown',
746-
'deleted_at' => 'unknown',
752+
'created_at' => '2026-11-10 14:50:00',
753+
'updated_at' => '2026-11-10 14:50:00',
754+
'deleted_at' => '2026-11-10 14:50:00',
747755
'profile' => 'profile',
748756
'virtual' => 'new property',
749757
],
@@ -763,6 +771,9 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
763771
new class () extends UserModel {
764772
protected $returnType = Member::class;
765773
protected bool $updateOnlyChanged = false;
774+
protected array $casts = [
775+
'id' => '?int',
776+
];
766777
},
767778
[
768779
'id' => 1,
@@ -784,15 +795,18 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
784795
new class () extends UserModel {
785796
protected $returnType = MemberStrict::class;
786797
protected bool $updateOnlyChanged = false;
798+
protected array $casts = [
799+
'id' => '?int',
800+
];
787801
},
788802
[
789803
'id' => 1,
790804
'name' => 'Derek Jones',
791805
'email' => 'unknown',
792806
'country' => 'unknown',
793-
'created_at' => 'unknown',
794-
'updated_at' => 'unknown',
795-
'deleted_at' => 'unknown',
807+
'created_at' => '2026-11-10 14:50:00',
808+
'updated_at' => '2026-11-10 14:50:00',
809+
'deleted_at' => '2026-11-10 14:50:00',
796810
'profile' => 'profile',
797811
'virtual' => 'new property',
798812
],
@@ -803,7 +817,7 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
803817
'country' => 'unknown',
804818
'created_at' => null,
805819
'updated_at' => null,
806-
'deleted_at' => 'unknown',
820+
'deleted_at' => '2026-11-10 14:50:00',
807821
'profile' => 'profile',
808822
],
809823
];

0 commit comments

Comments
 (0)