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

testSerializeFieldValue() public method

    public function testSerializeFieldValue()
    {
        $serializer = $this->getFieldTypeSerializer();
        $this->getGeneratorMock()->expects($this->once())->method('generateFieldTypeHash')->with($this->equalTo('fieldValue'), $this->equalTo(array(23, 42)));
        $this->getContentTypeMock()->expects($this->once())->method('getFieldDefinition')->with($this->equalTo('some-field'))->will($this->returnValue(new FieldDefinition(array('fieldTypeIdentifier' => 'myFancyFieldType'))));
        $fieldTypeMock = $this->getFieldTypeMock();
        $this->getFieldTypeServiceMock()->expects($this->once())->method('getFieldType')->with($this->equalTo('myFancyFieldType'))->will($this->returnCallback(function () use($fieldTypeMock) {
            return $fieldTypeMock;
        }));
        $fieldTypeMock->expects($this->once())->method('toHash')->with($this->equalTo('my-field-value'))->will($this->returnValue(array(23, 42)));
        $serializer->serializeFieldValue($this->getGeneratorMock(), $this->getContentTypeMock(), new Field(array('fieldDefIdentifier' => 'some-field', 'value' => 'my-field-value')));
    }