eZ\Publish\Core\Limitation\Tests\NewObjectStateLimitationTypeTest::testValidateError PHP Method

testValidateError() public method

public testValidateError ( eZ\Publish\API\Repository\Values\User\Limitation\NewObjectStateLimitation $limitation, integer $errorCount )
$limitation eZ\Publish\API\Repository\Values\User\Limitation\NewObjectStateLimitation
$errorCount integer
    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);
    }