eZ\Publish\Core\Persistence\Legacy\Tests\Content\Type\ContentTypeHandlerTest::testCreate PHP Method

testCreate() public method

public testCreate ( )
    public function testCreate()
    {
        $createStructFix = $this->getContentTypeCreateStructFixture();
        $createStructClone = clone $createStructFix;
        $mapperMock = $this->getMapperMock(array('toStorageFieldDefinition'));
        $gatewayMock = $this->getGatewayMock();
        $gatewayMock->expects($this->once())->method('insertType')->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type'))->will($this->returnValue(23));
        $gatewayMock->expects($this->once())->method('insertGroupAssignment')->with($this->equalTo(42), $this->equalTo(23), $this->equalTo(1));
        $gatewayMock->expects($this->exactly(2))->method('insertFieldDefinition')->with($this->equalTo(23), $this->equalTo(1), $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\FieldDefinition'), $this->isInstanceOf('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\StorageFieldDefinition'))->will($this->returnValue(42));
        $mapperMock->expects($this->exactly(2))->method('toStorageFieldDefinition')->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\FieldDefinition'), $this->isInstanceOf('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\StorageFieldDefinition'));
        $handler = $this->getHandler();
        $type = $handler->create($createStructFix);
        $this->assertInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type', $type, 'Incorrect type returned from create()');
        $this->assertEquals(23, $type->id, 'Incorrect ID for Type.');
        $this->assertEquals(42, $type->fieldDefinitions[0]->id, 'Field definition ID not set correctly');
        $this->assertEquals(42, $type->fieldDefinitions[1]->id, 'Field definition ID not set correctly');
        $this->assertEquals($createStructClone, $createStructFix, 'Create struct manipulated');
    }