eZ\Publish\Core\Limitation\Tests\LocationLimitationTypeTest::testEvaluate PHP Метод

testEvaluate() публичный Метод

public testEvaluate ( eZ\Publish\API\Repository\Values\User\Limitation\LocationLimitation $limitation, eZ\Publish\API\Repository\Values\ValueObject $object, $targets, array $persistenceLocations, $expected )
$limitation eZ\Publish\API\Repository\Values\User\Limitation\LocationLimitation
$object eZ\Publish\API\Repository\Values\ValueObject
$persistenceLocations array
    public function testEvaluate(LocationLimitation $limitation, ValueObject $object, $targets, array $persistenceLocations, $expected)
    {
        // Need to create inline instead of depending on testConstruct() to get correct mock instance
        $limitationType = $this->testConstruct();
        $userMock = $this->getUserMock();
        $userMock->expects($this->never())->method($this->anything());
        $persistenceMock = $this->getPersistenceMock();
        if (empty($persistenceLocations) && $targets !== null) {
            $persistenceMock->expects($this->never())->method($this->anything());
        } else {
            $this->getPersistenceMock()->expects($this->once())->method('locationHandler')->will($this->returnValue($this->locationHandlerMock));
            $this->locationHandlerMock->expects($this->once())->method($object instanceof ContentInfo && $object->published ? 'loadLocationsByContent' : 'loadParentLocationsForDraftContent')->with($object->id)->will($this->returnValue($persistenceLocations));
        }
        $value = $limitationType->evaluate($limitation, $userMock, $object, $targets);
        self::assertInternalType('boolean', $value);
        self::assertEquals($expected, $value);
    }