File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -159,8 +159,16 @@ final public function getOldValue(string $columnName): mixed
159159 return $ this ->_initialColumns [$ columnName ] ?? null ;
160160 }
161161
162- final public function resetChangedColumns (): void
162+ /**
163+ * @param array<string, mixed>|null $values An associative array with column names as keys and
164+ * their respective values to reset, or null to reset all columns.
165+ */
166+ final public function resetChangedColumns (?array $ values = null ): void
163167 {
164- $ this ->_initialColumns = $ this ->toArray ();
168+ if ($ values ) {
169+ $ this ->_initialColumns = $ values + ($ this ->_initialColumns ?? []);
170+ } else {
171+ $ this ->_initialColumns = $ this ->toArray ();
172+ }
165173 }
166174}
Original file line number Diff line number Diff line change @@ -243,4 +243,18 @@ public function __construct(
243243 $ expected = str_replace ('Array ' , 'Composite\Entity\AbstractEntity@anonymous Object ' , $ expected );
244244 $ this ->assertEquals ($ expected , print_r ($ entity , true ));
245245 }
246+
247+ public function test_resetChangedColumns (): void
248+ {
249+ $ entity = new TestSubEntity ();
250+ $ this ->assertEquals ($ entity ->toArray (), $ entity ->getChangedColumns ());
251+
252+ $ entity ->resetChangedColumns ();
253+ $ this ->assertEquals ([], $ entity ->getChangedColumns ());
254+
255+ $ entity = new TestSubEntity ();
256+ $ entity ->resetChangedColumns (['str ' => $ entity ->str ]);
257+
258+ $ this ->assertEquals (['number ' => $ entity ->number ], $ entity ->getChangedColumns ());
259+ }
246260}
You can’t perform that action at this time.
0 commit comments