eZ\Publish\Core\Persistence\Legacy\Tests\Content\Type\ContentUpdater\Action\AddFieldTest::testInsertNewField PHP Method

testInsertNewField() public method

public testInsertNewField ( )
    public function testInsertNewField()
    {
        $versionInfo = new Content\VersionInfo();
        $content = new Content();
        $content->versionInfo = $versionInfo;
        $value = new Content\FieldValue();
        $field = new Field();
        $field->id = null;
        $field->value = $value;
        $this->getFieldValueConverterMock()->expects($this->once())->method('toStorageValue')->with($value, $this->isInstanceOf('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\StorageFieldValue'));
        $this->getContentGatewayMock()->expects($this->once())->method('insertNewField')->with($content, $field, $this->isInstanceOf('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\StorageFieldValue'))->will($this->returnValue(23));
        $this->getContentStorageHandlerMock()->expects($this->once())->method('storeFieldData')->with($versionInfo, $field)->will($this->returnValue(false));
        $this->getContentGatewayMock()->expects($this->never())->method('updateField');
        $action = $this->getMockedAction();
        $refAction = new ReflectionObject($action);
        $refMethod = $refAction->getMethod('insertField');
        $refMethod->setAccessible(true);
        $fieldId = $refMethod->invoke($action, $content, $field);
        $this->assertEquals(23, $fieldId);
        $this->assertEquals(23, $field->id);
    }