@@ -976,6 +976,7 @@ public function testUpdateBatchValidationFail()
976976
977977 public function testSelectAndEntitiesSaveOnlyChangedValues ()
978978 {
979+ // Insert value in job table
979980 $ this ->hasInDatabase ('job ' , [
980981 'name ' => 'Rocket Scientist ' ,
981982 'description ' => 'Plays guitar for Queen ' ,
@@ -984,20 +985,35 @@ public function testSelectAndEntitiesSaveOnlyChangedValues()
984985
985986 $ model = new EntityModel ();
986987
988+ // get only id, name column
987989 $ job = $ model ->select ('id, name ' )
988- ->where ('name ' , 'Rocket Scientist ' )
989- ->first ();
990+ ->where ('name ' , 'Rocket Scientist ' )
991+ ->first ();
990992
993+ // Hence getting Null as description column not in select clause
991994 $ this ->assertNull ($ job ->description );
995+
996+ // Equals with name to check, correct record fetched or not.
992997 $ this ->assertEquals ('Rocket Scientist ' , $ job ->name );
993998
999+ $ job ->description = 'Some guitar description ' ;
1000+
1001+ // saving the result set with description as empty
9941002 $ model ->save ($ job );
9951003
1004+ // check for the record to same entry exists or not
9961005 $ this ->seeInDatabase ('job ' , [
997- 'id ' => $ job ->id ,
998- 'name ' => 'Rocket Scientist ' ,
999- 'description ' => 'Plays guitar for Queen ' ,
1006+ 'id ' => $ job ->id ,
1007+ 'name ' => 'Rocket Scientist ' ,
10001008 ]);
1009+
1010+ // select all columns from job table
1011+ $ job = $ model ->select ('id, name, description ' )
1012+ ->where ('name ' , 'Rocket Scientist ' )
1013+ ->first ();
1014+
1015+ // check whether the Null value successfully updated or not
1016+ $ this ->assertEquals ('Some guitar description ' , $ job ->description );
10011017 }
10021018
10031019 public function testUpdateNoPrimaryKey ()
0 commit comments