eZ\Publish\Core\REST\Common\Tests\Output\FieldTypeSerializerTest::testSerializeValidatorConfigurationWithPostProcessing PHP Method

testSerializeValidatorConfigurationWithPostProcessing() public method

    public function testSerializeValidatorConfigurationWithPostProcessing()
    {
        $serializer = $this->getFieldTypeSerializer();
        $fieldTypeMock = $this->getFieldTypeMock();
        $processorMock = $this->getFieldTypeProcessorMock();
        $this->getFieldTypeProcessorRegistryMock()->expects($this->once())->method('hasProcessor')->with('myFancyFieldType')->will($this->returnValue(true));
        $this->getFieldTypeProcessorRegistryMock()->expects($this->once())->method('getProcessor')->with('myFancyFieldType')->will($this->returnCallback(function () use($processorMock) {
            return $processorMock;
        }));
        $processorMock->expects($this->once())->method('postProcessValidatorConfigurationHash')->with($this->equalTo(array('bar' => 'foo')))->will($this->returnValue(array('post-processed')));
        $fieldTypeMock = $this->getFieldTypeMock();
        $this->getFieldTypeServiceMock()->expects($this->once())->method('getFieldType')->with($this->equalTo('myFancyFieldType'))->will($this->returnCallback(function () use($fieldTypeMock) {
            return $fieldTypeMock;
        }));
        $this->getGeneratorMock()->expects($this->once())->method('generateFieldTypeHash')->with($this->equalTo('validatorConfiguration'), $this->equalTo(array('post-processed')));
        $this->getFieldTypeServiceMock()->expects($this->once())->method('getFieldType')->with($this->equalTo('myFancyFieldType'))->will($this->returnCallback(function () use($fieldTypeMock) {
            return $fieldTypeMock;
        }));
        $fieldTypeMock->expects($this->once())->method('validatorConfigurationToHash')->with($this->equalTo('validator-config'))->will($this->returnValue(array('bar' => 'foo')));
        $serializer->serializeValidatorConfiguration($this->getGeneratorMock(), 'myFancyFieldType', 'validator-config');
    }