File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
namespace WikibaseSolutions \CypherDSL \Patterns ;
11
11
12
+ use WikibaseSolutions \CypherDSL \Expressions \Label ;
12
13
use WikibaseSolutions \CypherDSL \Expressions \Literals \Map ;
13
14
use WikibaseSolutions \CypherDSL \Traits \ErrorTrait ;
14
15
use WikibaseSolutions \CypherDSL \Traits \EscapeTrait ;
@@ -81,6 +82,16 @@ public function getLabels(): array
81
82
return $ this ->labels ;
82
83
}
83
84
85
+ /**
86
+ * Returns a label with the variable in this node.
87
+ *
88
+ * @param string ...$labels The labels to attach to the variable in this node
89
+ */
90
+ public function labeled (string ...$ labels ): Label
91
+ {
92
+ return new Label ($ this ->getVariable (), ...$ labels );
93
+ }
94
+
84
95
/**
85
96
* @inheritDoc
86
97
*/
Original file line number Diff line number Diff line change 11
11
12
12
use PHPUnit \Framework \TestCase ;
13
13
use TypeError ;
14
+ use WikibaseSolutions \CypherDSL \Expressions \Label ;
14
15
use WikibaseSolutions \CypherDSL \Expressions \Literals \Float_ ;
15
16
use WikibaseSolutions \CypherDSL \Expressions \Literals \Integer ;
16
17
use WikibaseSolutions \CypherDSL \Expressions \Literals \List_ ;
@@ -234,6 +235,22 @@ public function testRelationshipUni(): void
234
235
$ this ->assertSame ("(:City)-[:LIVES_IN]-(:City {city: 'Amsterdam'}) " , $ relationship ->toQuery ());
235
236
}
236
237
238
+ public function testLabeledSingleLabel (): void
239
+ {
240
+ $ node = new Node ();
241
+ $ labeled = $ node ->labeled ('German ' );
242
+
243
+ $ this ->assertEquals (new Label ($ node ->getVariable (), 'German ' ), $ labeled );
244
+ }
245
+
246
+ public function testLabeledMultipleLabels (): void
247
+ {
248
+ $ node = new Node ();
249
+ $ labeled = $ node ->labeled ('German ' , 'Swedish ' );
250
+
251
+ $ this ->assertEquals (new Label ($ node ->getVariable (), 'German ' , 'Swedish ' ), $ labeled );
252
+ }
253
+
237
254
public function provideOnlyLabelData (): array
238
255
{
239
256
return [
You can’t perform that action at this time.
0 commit comments