eZ\Publish\Core\Persistence\Legacy\Tests\Content\FieldHandlerTest::assertCreateNewFields PHP Method

assertCreateNewFields() protected method

protected assertCreateNewFields ( boolean $storageHandlerUpdatesFields = false )
$storageHandlerUpdatesFields boolean
    protected function assertCreateNewFields($storageHandlerUpdatesFields = false)
    {
        $contentGatewayMock = $this->getContentGatewayMock();
        $fieldTypeMock = $this->getFieldTypeMock();
        $storageHandlerMock = $this->getStorageHandlerMock();
        $fieldTypeMock->expects($this->exactly(3))->method('getEmptyValue')->will($this->returnValue(new FieldValue()));
        $contentGatewayMock->expects($this->exactly(6))->method('insertNewField')->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'), $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Field'), $this->isInstanceOf('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\StorageFieldValue'))->will($this->returnValue(42));
        $callNo = 0;
        $fieldValue = new FieldValue();
        foreach (array(1, 2, 3) as $fieldDefinitionId) {
            foreach (array('eng-US', 'eng-GB') as $languageCode) {
                $field = new Field(array('id' => 42, 'fieldDefinitionId' => $fieldDefinitionId, 'type' => 'some-type', 'versionNo' => 1, 'value' => $fieldValue, 'languageCode' => $languageCode));
                // This field is copied from main language
                if ($fieldDefinitionId == 2 && $languageCode == 'eng-US') {
                    $copyField = clone $field;
                    $originalField = clone $field;
                    $originalField->languageCode = 'eng-GB';
                    continue;
                }
                $storageHandlerMock->expects($this->at($callNo++))->method('storeFieldData')->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\VersionInfo'), $this->equalTo($field))->will($this->returnValue($storageHandlerUpdatesFields));
            }
        }
        /* @var $copyField */
        /* @var $originalField */
        $storageHandlerMock->expects($this->at($callNo))->method('copyFieldData')->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\VersionInfo'), $this->equalTo($copyField), $this->equalTo($originalField))->will($this->returnValue($storageHandlerUpdatesFields));
    }