1
+ <?php
2
+
3
+ namespace WikibaseSolutions \CypherDSL \Tests \Unit \Traits ;
4
+
5
+ use PHPUnit \Framework \TestCase ;
6
+ use WikibaseSolutions \CypherDSL \PropertyMap ;
7
+ use WikibaseSolutions \CypherDSL \Query ;
8
+ use WikibaseSolutions \CypherDSL \Traits \HasPropertiesTrait ;
9
+
10
+ class HasPropertiesTraitTest extends TestCase
11
+ {
12
+ private $ propertyTrait ;
13
+
14
+ public function setUp (): void
15
+ {
16
+ $ this ->propertyTrait = new class {
17
+ use HasPropertiesTrait {
18
+ initialiseProperties as public ;
19
+ }
20
+ };
21
+ }
22
+
23
+ public function testGetProperties (): void
24
+ {
25
+ self ::assertNull ($ this ->propertyTrait ->getProperties ());
26
+ }
27
+
28
+ public function testWithPropertiesArray (): void
29
+ {
30
+ $ this ->propertyTrait ->withProperties (['x ' => Query::literal ('y ' )]);
31
+
32
+ self ::assertEquals (
33
+ new PropertyMap (['x ' => Query::literal ('y ' )]),
34
+ $ this ->propertyTrait ->getProperties ()
35
+ );
36
+ }
37
+
38
+ public function testWithPropertiesMap (): void
39
+ {
40
+ $ this ->propertyTrait ->withProperties (new PropertyMap (['x ' => Query::literal ('y ' )]));
41
+
42
+ self ::assertEquals (
43
+ new PropertyMap (['x ' => Query::literal ('y ' )]),
44
+ $ this ->propertyTrait ->getProperties ()
45
+ );
46
+ }
47
+
48
+ public function testWithProperty (): void
49
+ {
50
+ $ this ->propertyTrait ->withProperty ('x ' , Query::literal ('y ' ));
51
+ $ this ->propertyTrait ->withProperty ('z ' , Query::literal ('z ' ));
52
+
53
+ self ::assertEquals (
54
+ new PropertyMap (['x ' => Query::literal ('y ' ), 'z ' => Query::literal ('z ' )]),
55
+ $ this ->propertyTrait ->getProperties ()
56
+ );
57
+ }
58
+
59
+ public function testInitialise (): void
60
+ {
61
+ $ this ->propertyTrait ->initialiseProperties ();
62
+
63
+ self ::assertEquals (new PropertyMap (), $ this ->propertyTrait ->getProperties ());
64
+ }
65
+ }
0 commit comments