/** * @dataProvider providerForTestValidateError * * @param \eZ\Publish\API\Repository\Values\User\Limitation\NewObjectStateLimitation $limitation * @param int $errorCount */ public function testValidateError(NewObjectStateLimitation $limitation, $errorCount) { if (!empty($limitation->limitationValues)) { $this->getPersistenceMock()->expects($this->any())->method("objectStateHandler")->will($this->returnValue($this->objectStateHandlerMock)); foreach ($limitation->limitationValues as $key => $value) { $this->objectStateHandlerMock->expects($this->at($key))->method("load")->with($value)->will($this->throwException(new NotFoundException('contentType', $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); }