45 private $linkedEntities = [];
66 private $uniquenessData = [];
73 private $parentEntity;
86 public function __construct($name, $type, $data, $linkedEntities, $uniquenessData, $vars = [], $parentEntity =
null)
91 $this->linkedEntities = $linkedEntities;
92 if ($uniquenessData) {
93 $this->uniquenessData = $uniquenessData;
97 $this->parentEntity = $parentEntity;
142 ->debug(
"Fetching data field from entity", [
"entity" => $this->
getName(),
"field" => $name]);
145 if (!$this->isValidUniqueDataFormat($uniquenessFormat)) {
146 $exceptionMessage = sprintf(
"Invalid unique data format value: %s \n", $uniquenessFormat);
148 ->error($exceptionMessage, [
"entity" => $this->
getName(),
"field" => $name]);
152 $name_lower = strtolower($name);
154 if ($this->data !==
null && array_key_exists($name_lower, $this->data)) {
156 if (
null === $uniquenessData || $uniquenessFormat == self::NO_UNIQUE_PROCESS) {
157 return $this->data[$name_lower];
159 return $this->formatUniqueData($name_lower, $uniquenessData, $uniquenessFormat);
172 return $this->parentEntity;
184 private function formatUniqueData($name, $uniqueData, $uniqueDataFormat)
186 switch ($uniqueDataFormat) {
188 $this->checkUniquenessFunctionExists(self::SUITE_UNIQUE_FUNCTION, $uniqueDataFormat);
189 if ($uniqueData ==
'prefix') {
190 return msqs($this->
getName()) . $this->data[$name];
192 return $this->data[$name] .
msqs($this->
getName());
196 $this->checkUniquenessFunctionExists(self::CEST_UNIQUE_FUNCTION, $uniqueDataFormat);
197 if ($uniqueData ==
'prefix') {
198 return msq($this->
getName()) . $this->data[$name];
200 return $this->data[$name] .
msq($this->
getName());
204 if ($uniqueData ==
'prefix') {
205 return self::SUITE_UNIQUE_FUNCTION .
'("' . $this->
getName() .
'")' . $this->data[$name];
207 return $this->data[$name] . self::SUITE_UNIQUE_FUNCTION .
'("' . $this->
getName() .
'")';
211 if ($uniqueData ==
'prefix') {
212 return self::CEST_UNIQUE_FUNCTION .
'("' . $this->
getName() .
'")' . $this->data[$name];
214 return $this->data[$name] . self::CEST_UNIQUE_FUNCTION .
'("' . $this->
getName() .
'")';
231 private function checkUniquenessFunctionExists($function, $uniqueDataFormat)
234 $exceptionMessage = sprintf(
235 'Unique data format value: %s can only be used when running cests.\n',
239 throw new TestFrameworkException($exceptionMessage);
252 if (array_key_exists($key, $this->vars)) {
253 return $this->vars[$key];
270 foreach ($this->linkedEntities as $entityName =>
$entityType) {
272 $groupedArray[] = $entityName;
276 return $groupedArray;
286 return $this->linkedEntities;
307 $name = strtolower($dataName);
309 if (array_key_exists($name, $this->uniquenessData)) {
310 return $this->uniquenessData[$name];
323 return $this->uniquenessData;
332 private function isValidUniqueDataFormat($uniDataFormat)
337 self::NO_UNIQUE_PROCESS,
338 self::SUITE_UNIQUE_VALUE,
339 self::CEST_UNIQUE_VALUE,
340 self::SUITE_UNIQUE_NOTATION,
341 self::CEST_UNIQUE_NOTATION
const CEST_UNIQUE_NOTATION
getUniquenessDataByName($dataName)
const SUITE_UNIQUE_FUNCTION
const SUITE_UNIQUE_NOTATION
__construct($name, $type, $data, $linkedEntities, $uniquenessData, $vars=[], $parentEntity=null)
const CEST_UNIQUE_FUNCTION
getLinkedEntitiesOfType($type)
getDataByName($name, $uniquenessFormat)