eZ\Publish\Core\Repository\Tests\Service\Mock\ContentTest::testCreateContentWithInvalidLanguage PHP Method

testCreateContentWithInvalidLanguage() public method

Test for the updateContent() method.
public testCreateContentWithInvalidLanguage ( $mainLanguageCode, $structFields )
    public function testCreateContentWithInvalidLanguage($mainLanguageCode, $structFields)
    {
        $repositoryMock = $this->getRepositoryMock();
        $mockedService = $this->getPartlyMockedContentService();
        /** @var \PHPUnit_Framework_MockObject_MockObject $languageHandlerMock */
        $languageHandlerMock = $this->getPersistenceMock()->contentLanguageHandler();
        $contentTypeServiceMock = $this->getContentTypeServiceMock();
        $domainMapperMock = $this->getDomainMapperMock();
        $contentType = new ContentType(array('id' => 123, 'fieldDefinitions' => array()));
        $contentCreateStruct = new ContentCreateStruct(array('fields' => $structFields, 'mainLanguageCode' => $mainLanguageCode, 'contentType' => $contentType, 'alwaysAvailable' => false, 'ownerId' => 169, 'sectionId' => 1));
        $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));
        }));
        $contentTypeServiceMock->expects($this->once())->method('loadContentType')->with($this->equalTo($contentType->id))->will($this->returnValue($contentType));
        $repositoryMock->expects($this->once())->method('getContentTypeService')->will($this->returnValue($contentTypeServiceMock));
        $that = $this;
        $repositoryMock->expects($this->once())->method('canUser')->with($this->equalTo('content'), $this->equalTo('create'), $this->isInstanceOf('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentCreateStruct'), $this->equalTo(array()))->will($this->returnCallback(function () use($that, $contentCreateStruct) {
            $that->assertEquals($contentCreateStruct, func_get_arg(2));
            return true;
        }));
        $domainMapperMock->expects($this->once())->method('getUniqueHash')->with($this->isInstanceOf('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentCreateStruct'))->will($this->returnCallback(function ($object) use($that, $contentCreateStruct) {
            $that->assertEquals($contentCreateStruct, $object);
            return 'hash';
        }));
        $mockedService->createContent($contentCreateStruct, array());
    }
ContentTest