This repository was archived by the owner on Mar 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MichaelRubel \LoopFunctions \Tests ;
4
+
5
+ use Illuminate \Support \Collection ;
6
+ use MichaelRubel \LoopFunctions \Tests \Boilerplate \TestClass ;
7
+ use MichaelRubel \LoopFunctions \Traits \LoopFunctions ;
8
+
9
+ class DynamicPropertiesTest extends TestCase
10
+ {
11
+ use LoopFunctions;
12
+
13
+ public function __get (string $ name ): mixed
14
+ {
15
+ return $ this ->{$ name };
16
+ }
17
+
18
+ public function __set (string $ name , $ value ): void
19
+ {
20
+ $ this ->{$ name } = $ value ;
21
+ }
22
+
23
+ /** @test */
24
+ public function testCanUseDynamicProperties ()
25
+ {
26
+ config (['loop-functions.dynamic_properties ' => true ]);
27
+
28
+ $ array = [
29
+ 'test ' => true ,
30
+ ];
31
+
32
+ $ this ->propertiesFrom ($ array );
33
+
34
+ $ this ->assertTrue ($ this ->test );
35
+ }
36
+
37
+ /** @test */
38
+ public function testDynamicPropertiesDisabled ()
39
+ {
40
+ config (['loop-functions.dynamic_properties ' => false ]);
41
+
42
+ $ this ->expectException (\ErrorException::class);
43
+
44
+ $ array = [
45
+ 'test ' => true ,
46
+ ];
47
+
48
+ $ this ->propertiesFrom ($ array );
49
+
50
+ $ this ->assertFalse ($ this ->test );
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments