Skip to content

Commit 4af7a6c

Browse files
committed
Update tests
1 parent 171f1cd commit 4af7a6c

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

tests/Debug/ValidationCollectorTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,39 @@ public function testActivities() : void
155155
\array_keys($this->collector->getActivities()[0]) // @phpstan-ignore-line
156156
);
157157
}
158+
159+
public function testValidationCollectorInstance() : void
160+
{
161+
$validation = new Validation();
162+
self::assertNull($validation->getDebugCollector());
163+
$validation->setDebugCollector($this->collector);
164+
self::assertInstanceOf(
165+
ValidationCollector::class,
166+
$validation->getDebugCollector()
167+
);
168+
}
169+
170+
public function testSetErrorInDebugData() : void
171+
{
172+
$data = $this->collector->getData();
173+
self::assertEmpty($data);
174+
$this->collector->setErrorInDebugData('email', 'Email error.');
175+
$data = $this->collector->getData();
176+
self::assertCount(0, $data);
177+
$this->collector->addData([
178+
'start' => 1676932480,
179+
'end' => 1676932490,
180+
'validated' => false,
181+
'errors' => ['foo' => 'Foo error.'],
182+
'type' => 'all',
183+
]);
184+
$data = $this->collector->getData();
185+
self::assertCount(1, $data[0]['errors']);
186+
$this->collector->setErrorInDebugData('email', 'Email error.');
187+
$data = $this->collector->getData();
188+
self::assertCount(2, $data[0]['errors']);
189+
$this->collector->setErrorInDebugData('bar', 'Bar error.', 1);
190+
$data = $this->collector->getData();
191+
self::assertCount(1, $data[1]['errors']);
192+
}
158193
}

tests/ValidationMock.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,4 @@ public function replaceArgs(array $args, array $data) : array
3030
{
3131
return parent::replaceArgs($args, $data);
3232
}
33-
34-
public function setError(string $field, string $rule, array $params) : static
35-
{
36-
return parent::setError($field, $rule, $params);
37-
}
3833
}

0 commit comments

Comments
 (0)