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

testApplyMultipleVersionsMultipleTranslations() public method

    public function testApplyMultipleVersionsMultipleTranslations()
    {
        $contentId = 42;
        $versionNumbers = array(1, 2);
        $content1 = $this->getContentFixture(1, array('eng-GB', 'ger-DE'));
        $content2 = $this->getContentFixture(2, array('eng-GB', 'ger-DE'));
        $action = $this->getMockedAction(array('insertField'));
        $this->getContentGatewayMock()->expects($this->once())->method('listVersionNumbers')->with($this->equalTo($contentId))->will($this->returnValue($versionNumbers));
        $this->getContentGatewayMock()->expects($this->once())->method('loadVersionedNameData')->with($this->equalTo(array(array('id' => $contentId, 'version' => 1), array('id' => $contentId, 'version' => 2))))->will($this->returnValue(array()));
        $this->getContentGatewayMock()->expects($this->at(2))->method('load')->with($contentId, 1)->will($this->returnValue(array()));
        $this->getContentMapperMock()->expects($this->at(0))->method('extractContentFromRows')->with(array(), array())->will($this->returnValue(array($content1)));
        $this->getContentGatewayMock()->expects($this->at(3))->method('load')->with($contentId, 2)->will($this->returnValue(array()));
        $this->getContentMapperMock()->expects($this->at(1))->method('extractContentFromRows')->with(array(), array())->will($this->returnValue(array($content2)));
        $action->expects($this->at(0))->method('insertField')->with($content1, $this->getFieldReference(null, 1, 'eng-GB'))->will($this->returnValue('fieldId1'));
        $action->expects($this->at(1))->method('insertField')->with($content1, $this->getFieldReference(null, 1, 'ger-DE'))->will($this->returnValue('fieldId2'));
        $action->expects($this->at(2))->method('insertField')->with($content2, $this->getFieldReference('fieldId1', 2, 'eng-GB'))->will($this->returnValue('fieldId1'));
        $action->expects($this->at(3))->method('insertField')->with($content2, $this->getFieldReference('fieldId2', 2, 'ger-DE'))->will($this->returnValue('fieldId2'));
        $action->apply($contentId);
    }