Skip to content

Commit 4a59281

Browse files
Refactor
1 parent 9053ace commit 4a59281

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/Framework/TestSuite.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,22 @@ public function toString(): string
160160
*/
161161
public function addTest(Test $test, array $groups = []): void
162162
{
163+
if ($test instanceof self) {
164+
$this->tests[] = $test;
165+
166+
$this->clearCaches();
167+
168+
return;
169+
}
170+
171+
assert($test instanceof TestCase || $test instanceof PhptTestCase);
172+
163173
$class = new ReflectionClass($test);
164174

165175
if (!$class->isAbstract()) {
166176
$this->tests[] = $test;
167-
$this->clearCaches();
168177

169-
if ($test instanceof self && empty($groups)) {
170-
$groups = $test->groups();
171-
}
178+
$this->clearCaches();
172179

173180
if ($this->containsOnlyVirtualGroups($groups)) {
174181
$groups[] = 'default';
@@ -178,19 +185,15 @@ public function addTest(Test $test, array $groups = []): void
178185
$id = $test->valueObjectForEvents()->id();
179186

180187
$test->setGroups($groups);
181-
}
182-
183-
if ($test instanceof PhptTestCase) {
188+
} else {
184189
$id = $test->valueObjectForEvents()->id();
185190
}
186191

187-
if (isset($id)) {
188-
foreach ($groups as $group) {
189-
if (!isset($this->groups[$group])) {
190-
$this->groups[$group] = [$id];
191-
} else {
192-
$this->groups[$group][] = $id;
193-
}
192+
foreach ($groups as $group) {
193+
if (!isset($this->groups[$group])) {
194+
$this->groups[$group] = [$id];
195+
} else {
196+
$this->groups[$group][] = $id;
194197
}
195198
}
196199
}

0 commit comments

Comments
 (0)