eZ\Publish\Core\Persistence\Legacy\Tests\Content\Type\ContentTypeHandlerTest::testCopy PHP Метод

testCopy() публичный Метод

public testCopy ( )
    public function testCopy()
    {
        $gatewayMock = $this->getGatewayMock();
        $mapperMock = $this->getMapperMock();
        $mapperMock->expects($this->once())->method('createCreateStructFromType')->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type'))->will($this->returnValue(new CreateStruct(array('identifier' => 'testCopy'))));
        $handlerMock = $this->getMock('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\Type\\Handler', array('load', 'internalCreate', 'update'), array($gatewayMock, $mapperMock, $this->getUpdateHandlerMock()));
        $handlerMock->expects($this->once())->method('load')->with($this->equalTo(23, 0))->will($this->returnValue(new Type()));
        $handlerMock->expects($this->once())->method('internalCreate')->with($this->logicalAnd($this->attributeEqualTo('modifierId', 42), $this->attribute($this->greaterThanOrEqual(time()), 'modified'), $this->attributeEqualTo('creatorId', 42), $this->attribute($this->greaterThanOrEqual(time()), 'created'), $this->attribute($this->matchesRegularExpression('/^[a-f0-9]+$/'), 'identifier')))->will($this->returnValue(new Type(['id' => 24, 'identifier' => md5(uniqid(get_class($handlerMock), true)), 'status' => Type::STATUS_DEFINED])));
        $mapperMock->expects($this->once())->method('createUpdateStructFromType')->with($this->attribute($this->matchesRegularExpression('/^[a-f0-9]+$/'), 'identifier'))->will($this->returnValue(new UpdateStruct()));
        $handlerMock->expects($this->once())->method('update')->with($this->equalTo(24), $this->equalTo(Type::STATUS_DEFINED), $this->attribute($this->equalTo('copy_of_testCopy_24'), 'identifier'))->will($this->returnValue(new Type()));
        $res = $handlerMock->copy(42, 23, 0);
        $this->assertInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type', $res);
    }