eZ\Publish\Core\FieldType\Tests\Url\UrlStorageTest::testStoreFieldDataWithExistingUrl PHP Method

testStoreFieldDataWithExistingUrl() public method

    public function testStoreFieldDataWithExistingUrl()
    {
        $versionInfo = new VersionInfo(array('versionNo' => 24));
        $fieldValue = new FieldValue(array('externalData' => 'http://ez.no'));
        $field = new Field(array('id' => 42, 'value' => $fieldValue));
        $gateway = $this->getGatewayMock();
        $gateway->expects($this->once())->method('getUrlIdMap')->with(array('http://ez.no'))->will($this->returnValue(array('http://ez.no' => 12)));
        $gateway->expects($this->once())->method('linkUrl')->with(12, 42, 24);
        $storage = $this->getPartlyMockedStorage(array('getGateway'));
        $storage->expects($this->once())->method('getGateway')->with($this->getContext())->will($this->returnValue($gateway));
        $result = $storage->storeFieldData($versionInfo, $field, $this->getContext());
        $this->assertTrue($result);
        $this->assertEquals(12, $field->value->data['urlId']);
    }