File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
tests/system/Database/Live Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -1578,9 +1578,10 @@ public function errors(bool $forceDB = false)
1578
1578
1579
1579
return $ error ['message ' ] ?? null ;
1580
1580
}
1581
-
1581
+
1582
+ //--------------------------------------------------------------------
1583
+
1582
1584
/**
1583
- * Allows to set allowed fields.
1584
1585
* It could be used when you have to change default or override current allowed fields.
1585
1586
*
1586
1587
* @param array $allowedFields
@@ -1589,7 +1590,7 @@ public function errors(bool $forceDB = false)
1589
1590
*/
1590
1591
public function setAllowedFields (array $ allowedFields )
1591
1592
{
1592
- $ this ->$ allowedFields = $ allowedFields ;
1593
+ $ this ->allowedFields = $ allowedFields ;
1593
1594
}
1594
1595
1595
1596
//--------------------------------------------------------------------
Original file line number Diff line number Diff line change 1
- <?php namespace CodeIgniter \Database \Live ;
1
+ <?php
2
+
3
+ namespace CodeIgniter \Database \Live ;
2
4
3
5
use BadMethodCallException ;
4
6
use CodeIgniter \Config \Config ;
@@ -2579,4 +2581,27 @@ public function testcountAllResultsFalseWithDeletedFalseUseSoftDeletesFalse()
2579
2581
$ this ->assertFalse ($ this ->getPrivateProperty ($ model , 'tempUseSoftDeletes ' ));
2580
2582
}
2581
2583
2584
+ public function testSetAllowedFields ()
2585
+ {
2586
+ $ allowed1 = [
2587
+ 'id ' ,
2588
+ 'created_at ' ,
2589
+ ];
2590
+ $ allowed2 = [
2591
+ 'id ' ,
2592
+ 'updated_at ' ,
2593
+ ];
2594
+
2595
+ $ model = new class extends Model {
2596
+ protected $ allowedFields = [
2597
+ 'id ' ,
2598
+ 'created_at ' ,
2599
+ ];
2600
+ };
2601
+
2602
+ $ this ->assertSame ($ allowed1 , $ this ->getPrivateProperty ($ model , 'allowedFields ' ));
2603
+
2604
+ $ model ->setAllowedFields ($ allowed2 );
2605
+ $ this ->assertSame ($ allowed2 , $ this ->getPrivateProperty ($ model , 'allowedFields ' ));
2606
+ }
2582
2607
}
You can’t perform that action at this time.
0 commit comments