Skip to content

Commit f707fb2

Browse files
committed
docs: add test for rule instance count
1 parent 6815f3f commit f707fb2

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/system/Validation/ValidationTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,22 @@ public function testRunReturnsFalseWithNothingToDo(): void
240240
$this->assertFalse($this->validation->run([]));
241241
}
242242

243+
public function testRuleClassesInstantiatedOnce(): void
244+
{
245+
$this->validation->setRules([]);
246+
$this->validation->run([]);
247+
$count1 = count(
248+
$this->getPrivateProperty($this->validation, 'ruleSetInstances')
249+
);
250+
251+
$this->validation->run([]);
252+
$count2 = count(
253+
$this->getPrivateProperty($this->validation, 'ruleSetInstances')
254+
);
255+
256+
$this->assertSame($count1, $count2);
257+
}
258+
243259
public function testRunDoesTheBasics(): void
244260
{
245261
$data = ['foo' => 'notanumber'];

0 commit comments

Comments
 (0)