Skip to content

Commit 29f07d3

Browse files
committed
fix: Update select() in test
1 parent 24dcc8b commit 29f07d3

2 files changed

Lines changed: 25 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: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ 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, \'new property\' AS "virtual"', false)->withDeleted()->find(1);
693+
693694
$this->assertInstanceOf(Member::class, $member);
694695
$this->assertSame($selectedMember, $member->toRawArray());
695696

@@ -699,7 +700,6 @@ public function testUpdateOnlyChangedAndMergeAttributesOnInjectFlags(UserModel $
699700
$result = $model->update(1, $member);
700701

701702
$this->assertTrue($result);
702-
703703
$memberSilentOverwrite = $model->withDeleted()->find(1);
704704

705705
$this->assertSame($updatedMember, $memberSilentOverwrite->toRawArray());
@@ -714,6 +714,9 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
714714
new class () extends UserModel {
715715
protected $returnType = Member::class;
716716
protected bool $updateOnlyChanged = true;
717+
protected array $casts = [
718+
'id' => '?int',
719+
];
717720
},
718721
[
719722
'id' => 1,
@@ -735,15 +738,18 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
735738
new class () extends UserModel {
736739
protected $returnType = MemberStrict::class;
737740
protected bool $updateOnlyChanged = true;
741+
protected array $casts = [
742+
'id' => '?int',
743+
];
738744
},
739745
[
740746
'id' => 1,
741747
'name' => 'Derek Jones',
742748
'email' => 'unknown',
743749
'country' => 'unknown',
744-
'created_at' => 'unknown',
745-
'updated_at' => 'unknown',
746-
'deleted_at' => 'unknown',
750+
'created_at' => '2026-11-10 14:50:00',
751+
'updated_at' => '2026-11-10 14:50:00',
752+
'deleted_at' => '2026-11-10 14:50:00',
747753
'profile' => 'profile',
748754
'virtual' => 'new property',
749755
],
@@ -763,6 +769,9 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
763769
new class () extends UserModel {
764770
protected $returnType = Member::class;
765771
protected bool $updateOnlyChanged = false;
772+
protected array $casts = [
773+
'id' => '?int',
774+
];
766775
},
767776
[
768777
'id' => 1,
@@ -784,15 +793,18 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
784793
new class () extends UserModel {
785794
protected $returnType = MemberStrict::class;
786795
protected bool $updateOnlyChanged = false;
796+
protected array $casts = [
797+
'id' => '?int',
798+
];
787799
},
788800
[
789801
'id' => 1,
790802
'name' => 'Derek Jones',
791803
'email' => 'unknown',
792804
'country' => 'unknown',
793-
'created_at' => 'unknown',
794-
'updated_at' => 'unknown',
795-
'deleted_at' => 'unknown',
805+
'created_at' => '2026-11-10 14:50:00',
806+
'updated_at' => '2026-11-10 14:50:00',
807+
'deleted_at' => '2026-11-10 14:50:00',
796808
'profile' => 'profile',
797809
'virtual' => 'new property',
798810
],
@@ -803,7 +815,7 @@ public static function provideUpdateOnlyChangedAndMergeAttributesOnInjectFlags()
803815
'country' => 'unknown',
804816
'created_at' => null,
805817
'updated_at' => null,
806-
'deleted_at' => 'unknown',
818+
'deleted_at' => '2026-11-10 14:50:00',
807819
'profile' => 'profile',
808820
],
809821
];

0 commit comments

Comments
 (0)