53 if (!array_key_exists(self::SUITE_ROOT_TAG, $parsedSuiteData)) {
57 foreach ($parsedSuiteData[self::SUITE_ROOT_TAG] as $parsedSuite) {
58 if (!is_array($parsedSuite)) {
65 if ($parsedSuite[self::NAME] ==
'default') {
66 throw new XmlException(
"A Suite can not have the name \"default\"");
74 if (!empty($testGroupConflicts)) {
75 $testGroupConflictsFileNames =
"";
76 foreach ($testGroupConflicts as $test) {
77 $testGroupConflictsFileNames .= $test->getFilename() .
"\n";
79 $exceptionmessage =
"\"Suite names and Group names can not have the same value. \t\n" .
80 "Suite: \"{$suiteName}\" also exists as a group annotation in: \n{$testGroupConflictsFileNames}";
89 $includeTests = $this->extractTestObjectsFromSuiteRef($groupTestsToInclude);
90 $excludeTests = $this->extractTestObjectsFromSuiteRef($groupTestsToExclude);
95 $parsedSuite[self::NAME],
102 $parsedSuite[self::NAME],
108 if (count($suiteHooks) == 1) {
110 "Suites that contain hooks must contain both a 'before' and an 'after' hook. Suite: \"%s\"",
111 $parsedSuite[self::NAME]
115 $noHooks = count($suiteHooks) == 0 ||
117 empty($suiteHooks[
'before']->getActions()) &&
118 empty($suiteHooks[
'after']->getActions())
121 if ($noHooks && empty($includeTests) && empty($excludeTests)) {
123 "Suites must not be empty. Suite: \"%s\"",
124 $parsedSuite[self::NAME]
129 if (empty($includeTests)) {
135 $parsedSuite[self::NAME],
142 return $suiteObjects;
153 private function extractTestObjectsFromSuiteRef($suiteReferences)
155 $testObjectList = [];
156 foreach ($suiteReferences as $suiteRefName => $suiteRefData) {
157 if (!is_array($suiteRefData)) {
161 switch ($suiteRefData[self::NODE_NAME]) {
164 $testObjectList[$testObject->getName()] = $testObject;
167 $testObjectList = $testObjectList +
171 $testObjectList = array_merge($testObjectList, $this->extractModuleAndFiles(
172 $suiteRefData[self::NAME],
173 $suiteRefData[self::MODULE_TAG_FILE_ATTRIBUTE] ??
null 179 return $testObjectList;
190 private function extractModuleAndFiles($moduleName, $moduleFilePath)
192 if (empty($moduleFilePath)) {
193 return $this->resolveModulePathTestNames($moduleName);
196 return $this->resolveFilePathTestNames($moduleFilePath, $moduleName);
207 private function resolveFilePathTestNames($filename, $moduleName =
null)
209 $filepath = $filename;
210 if (!strstr($filepath, DIRECTORY_SEPARATOR)) {
211 $filepath = TESTS_MODULE_PATH .
212 DIRECTORY_SEPARATOR .
214 DIRECTORY_SEPARATOR .
216 DIRECTORY_SEPARATOR .
220 if (!file_exists($filepath)) {
221 throw new Exception(
"Could not find file ${filename}");
225 $xml = simplexml_load_file($filepath);
226 for (
$i = 0;
$i < $xml->count();
$i++) {
227 $testName = (string)$xml->test[
$i]->attributes()->name;
241 private function resolveModulePathTestNames($moduleName)
246 DIRECTORY_SEPARATOR .
248 DIRECTORY_SEPARATOR .
250 DIRECTORY_SEPARATOR .
254 foreach ($xmlFiles as $xmlFile) {
255 $testObjs = $this->resolveFilePathTestNames($xmlFile);
257 foreach ($testObjs as $testObj) {
258 $testObjects[$testObj->getName()] = $testObj;
static validateName($name, $type)