Skip to content

Commit c16dafe

Browse files
committed
fixup! IBX-7579:Richtext: Rows are added to ezurl_object_link on every save: Changed unit test into integration test
1 parent 54e2918 commit c16dafe

File tree

3 files changed

+64
-24
lines changed

3 files changed

+64
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
namespace eZ\Publish\Core\FieldType\Tests\Integration\Url\UrlStorage;
8+
9+
use eZ\Publish\Core\FieldType\Tests\Integration\BaseCoreFieldTypeIntegrationTest;
10+
use eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway;
11+
12+
/**
13+
* Url Field Type external storage gateway tests.
14+
*/
15+
abstract class UrlStorageGatewayTest extends BaseCoreFieldTypeIntegrationTest
16+
{
17+
abstract protected function getGateway(): Gateway;
18+
19+
/**
20+
* @covers \eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway\DoctrineStorage::getUrlsFromUrlLink
21+
*/
22+
public function testGetUrlsFromUrlLink()
23+
{
24+
self::assertEquals(true, false, "force failure");
25+
$gateway = $this->getGateway();
26+
27+
$urlIds = [];
28+
$urlIds[] = $gateway->insertUrl('https://ibexa.co/example1');
29+
$urlIds[] = $gateway->insertUrl('https://ibexa.co/example2');
30+
$urlIds[] = $gateway->insertUrl('https://ibexa.co/example3');
31+
32+
$gateway->linkUrl($urlIds[0], 10, 1);
33+
$gateway->linkUrl($urlIds[1], 10, 1);
34+
$gateway->linkUrl($urlIds[1], 12, 2);
35+
$gateway->linkUrl($urlIds[2], 14, 1);
36+
37+
self::assertEquals(['https://ibexa.co/example1' => true, 'https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(10, 1), 'Did not get expected urlS for field 10');
38+
self::assertEquals(['https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(12, 2), 'Did not get expected url for field 12');
39+
self::assertEquals(['https://ibexa.co/example3' => true], $gateway->getUrlsFromUrlLink(14, 1), 'Did not get expected url for field 14');
40+
self::assertEquals([], $gateway->getUrlsFromUrlLink(15, 1), 'Expected no urls for field 15');
41+
}
42+
}

eZ/Publish/Core/FieldType/Tests/Url/Gateway/DoctrineStorageTest.php

+1-24
Original file line numberDiff line numberDiff line change
@@ -194,34 +194,11 @@ public function testUnlinkUrl()
194194
$this->assertEquals($expected, $result);
195195
}
196196

197-
/**
198-
* @covers \eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway\DoctrineStorage::getUrlsFromUrlLink
199-
*/
200-
public function testGetUrlsFromUrlLink()
201-
{
202-
$gateway = $this->getStorageGateway();
203-
204-
$urlIds = [];
205-
$urlIds[] = $gateway->insertUrl('https://ibexa.co/example1');
206-
$urlIds[] = $gateway->insertUrl('https://ibexa.co/example2');
207-
$urlIds[] = $gateway->insertUrl('https://ibexa.co/example3');
208-
209-
$gateway->linkUrl($urlIds[0], 10, 1);
210-
$gateway->linkUrl($urlIds[1], 10, 1);
211-
$gateway->linkUrl($urlIds[1], 12, 2);
212-
$gateway->linkUrl($urlIds[2], 14, 1);
213-
214-
self::assertEquals(['https://ibexa.co/example1' => true, 'https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(10, 1), 'Did not get expected urlS for field 10');
215-
self::assertEquals(['https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(12, 2), 'Did not get expected url for field 12');
216-
self::assertEquals(['https://ibexa.co/example3' => true], $gateway->getUrlsFromUrlLink(14, 1), 'Did not get expected url for field 14');
217-
self::assertEquals([], $gateway->getUrlsFromUrlLink(15, 1), 'Expected no urls for field 15');
218-
}
219-
220197
protected function getStorageGateway(): Gateway
221198
{
222199
if (!isset($this->storageGateway)) {
223200
$this->storageGateway = new DoctrineStorage($this->getDatabaseConnection());
224-
}
201+
}
225202

226203
return $this->storageGateway;
227204
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Tests\integration\Core\FieldType\Url\UrlStorage\Gateway;
10+
11+
use eZ\Publish\Core\FieldType\Tests\Integration\Url\UrlStorage\UrlStorageGatewayTest;
12+
use eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway as UrlStorageGateway;
13+
use eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway\DoctrineStorage;
14+
15+
final class UrlDoctrineStorageGatewayTest extends UrlStorageGatewayTest
16+
{
17+
protected function getGateway(): UrlStorageGateway
18+
{
19+
return new DoctrineStorage($this->getDatabaseConnection());
20+
}
21+
}

0 commit comments

Comments
 (0)