public function testUpdateContentWithInvalidLanguage($initialLanguageCode, $structFields) { $repositoryMock = $this->getRepositoryMock(); $mockedService = $this->getPartlyMockedContentService(array('loadContent')); /** @var \PHPUnit_Framework_MockObject_MockObject $languageHandlerMock */ $languageHandlerMock = $this->getPersistenceMock()->contentLanguageHandler(); $versionInfo = new VersionInfo(array('contentInfo' => new ContentInfo(array('id' => 42, 'contentTypeId' => 24, 'mainLanguageCode' => 'eng-GB')), 'versionNo' => 7, 'languageCodes' => array('eng-GB'), 'status' => VersionInfo::STATUS_DRAFT)); $content = new Content(array('versionInfo' => $versionInfo, 'internalFields' => array())); $languageHandlerMock->expects($this->any())->method('loadByLanguageCode')->with($this->isType('string'))->will($this->returnCallback(function ($languageCode) { if ($languageCode === 'Klingon') { throw new NotFoundException('Language', 'Klingon'); } return new Language(array('id' => 4242)); })); $mockedService->expects($this->once())->method('loadContent')->with($this->equalTo(42), $this->equalTo(null), $this->equalTo(7))->will($this->returnValue($content)); $repositoryMock->expects($this->once())->method('canUser')->with($this->equalTo('content'), $this->equalTo('edit'), $this->equalTo($content))->will($this->returnValue(true)); $contentUpdateStruct = new ContentUpdateStruct(array('fields' => $structFields, 'initialLanguageCode' => $initialLanguageCode)); $mockedService->updateContent($content->versionInfo, $contentUpdateStruct); }