public function testValidateError(SectionLimitation $limitation, $errorCount)
{
if (!empty($limitation->limitationValues)) {
$this->getPersistenceMock()->expects($this->any())->method('sectionHandler')->will($this->returnValue($this->sectionHandlerMock));
foreach ($limitation->limitationValues as $key => $value) {
$this->sectionHandlerMock->expects($this->at($key))->method('load')->with($value)->will($this->throwException(new NotFoundException('Section', $value)));
}
} else {
$this->getPersistenceMock()->expects($this->never())->method($this->anything());
}
// Need to create inline instead of depending on testConstruct() to get correct mock instance
$limitationType = $this->testConstruct();
$validationErrors = $limitationType->validate($limitation);
self::assertCount($errorCount, $validationErrors);
}