@@ -88,6 +88,66 @@ public function testEntityException(): void
88
88
$ this ->assertArrayHasKey ('sampleTest ' , $ testErrors );
89
89
}
90
90
91
+ /**
92
+ * Basic test to check unique id is appended to input as prefix
93
+ *
94
+ * @return void
95
+ * @throws Exception
96
+ */
97
+ public function testUniqueIdAppendedToInputStringAsPrefix ()
98
+ {
99
+ $ actionObject = new ActionObject ('fakeAction ' , 'comment ' , [
100
+ 'userInput ' => '{{someEntity.entity}} '
101
+ ]);
102
+
103
+ $ testObject = new TestObject ('sampleTest ' , ['merge123 ' => $ actionObject ], [], [], 'filename ' );
104
+ $ testGeneratorObject = TestGenerator::getInstance ('' , ['sampleTest ' => $ testObject ]);
105
+
106
+ $ result = $ testGeneratorObject ->getUniqueIdForInput ('prefix ' , "foo " );
107
+
108
+ $ this ->assertMatchesRegularExpression ('/[A-Za-z0-9]+foo/ ' ,$ result );
109
+ }
110
+
111
+ /**
112
+ * Basic test to check unique id is appended to input as suffix
113
+ *
114
+ * @return void
115
+ * @throws Exception
116
+ */
117
+ public function testUniqueIdAppendedToInputStringAsSuffix ()
118
+ {
119
+ $ actionObject = new ActionObject ('fakeAction ' , 'comment ' , [
120
+ 'userInput ' => '{{someEntity.entity}} '
121
+ ]);
122
+
123
+ $ testObject = new TestObject ('sampleTest ' , ['merge123 ' => $ actionObject ], [], [], 'filename ' );
124
+ $ testGeneratorObject = TestGenerator::getInstance ('' , ['sampleTest ' => $ testObject ]);
125
+
126
+ $ result = $ testGeneratorObject ->getUniqueIdForInput ('suffix ' , "foo " );
127
+
128
+ $ this ->assertMatchesRegularExpression ('/foo[A-Za-z0-9]+/ ' ,$ result );
129
+ }
130
+
131
+ /**
132
+ * Basic test for wrong output for input
133
+ *
134
+ * @return void
135
+ * @throws Exception
136
+ */
137
+ public function testFailedRegexForUniqueAttribute ()
138
+ {
139
+ $ actionObject = new ActionObject ('fakeAction ' , 'comment ' , [
140
+ 'userInput ' => '{{someEntity.entity}} '
141
+ ]);
142
+
143
+ $ testObject = new TestObject ('sampleTest ' , ['merge123 ' => $ actionObject ], [], [], 'filename ' );
144
+ $ testGeneratorObject = TestGenerator::getInstance ('' , ['sampleTest ' => $ testObject ]);
145
+
146
+ $ result = $ testGeneratorObject ->getUniqueIdForInput ('suffix ' , "foo " );
147
+
148
+ $ this ->assertDoesNotMatchRegularExpression ('/bar[A-Za-z0-9]+/ ' ,$ result );
149
+ }
150
+
91
151
/**
92
152
* Tests that skipped tests do not have a fully generated body.
93
153
*
0 commit comments