@@ -91,4 +91,44 @@ public function testAddIdentifierWithoutProperty(): void
91
91
$ this ->expectException (InvalidArgumentException::class);
92
92
$ trait ->addIdentifier ('someProperty ' );
93
93
}
94
+
95
+ public function testProperties (): void
96
+ {
97
+ $ trait = $ this ->getTrait ();
98
+ $ trait ->addProperty ('someProperty ' , 'some value ' );
99
+ $ this ->assertCount (1 , $ trait ->getProperties ());
100
+ $ this ->assertTrue ($ trait ->hasProperty ('someProperty ' ));
101
+ $ this ->assertFalse ($ trait ->hasProperty ('notExistingProperty ' ));
102
+ $ this ->assertSame ('some value ' , $ trait ->getProperty ('someProperty ' ));
103
+
104
+ $ trait ->addProperties ([
105
+ 'otherProperty ' => 'other value ' ,
106
+ 'anotherProperty ' => 'another value ' ,
107
+ ]);
108
+ $ this ->assertCount (3 , $ trait ->getProperties ());
109
+ $ trait ->removeProperty ('otherProperty ' );
110
+ $ this ->assertCount (2 , $ trait ->getProperties ());
111
+ $ trait ->removeProperties ();
112
+ $ this ->assertCount (0 , $ trait ->getProperties ());
113
+ }
114
+
115
+ public function testRemovePropertyWhichIsAlsoIdentifier (): void
116
+ {
117
+ $ trait = $ this ->getTrait ()
118
+ ->addProperty ('id ' , 123 )
119
+ ->addIdentifier ('id ' );
120
+ $ this ->expectExceptionMessage ("Unable to remove identifying property with name 'id' - remove identifier first " );
121
+ $ this ->expectException (InvalidArgumentException::class);
122
+ $ trait ->removeProperty ('id ' );
123
+ }
124
+
125
+ public function testRemovePropertiesWithExistingIdentifier (): void
126
+ {
127
+ $ trait = $ this ->getTrait ()
128
+ ->addProperty ('id ' , 123 )
129
+ ->addIdentifier ('id ' );
130
+ $ this ->expectExceptionMessage ("Unable to remove all properties because identifiers are still defined " );
131
+ $ this ->expectException (InvalidArgumentException::class);
132
+ $ trait ->removeProperties ();
133
+ }
94
134
}
0 commit comments