From c16dafe7704a259a862cab358655a5f8cff21921 Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Tue, 11 Jun 2024 14:57:59 +0200 Subject: [PATCH] fixup! IBX-7579:Richtext: Rows are added to ezurl_object_link on every save: Changed unit test into integration test --- .../Url/UrlStorage/UrlStorageGatewayTest.php | 42 +++++++++++++++++++ .../Tests/Url/Gateway/DoctrineStorageTest.php | 25 +---------- .../Gateway/UrlDoctrineStorageGatewayTest.php | 21 ++++++++++ 3 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 eZ/Publish/Core/FieldType/Tests/Integration/Url/UrlStorage/UrlStorageGatewayTest.php create mode 100644 tests/integration/Core/FieldType/Url/UrlStorage/Gateway/UrlDoctrineStorageGatewayTest.php diff --git a/eZ/Publish/Core/FieldType/Tests/Integration/Url/UrlStorage/UrlStorageGatewayTest.php b/eZ/Publish/Core/FieldType/Tests/Integration/Url/UrlStorage/UrlStorageGatewayTest.php new file mode 100644 index 0000000000..6deefd6951 --- /dev/null +++ b/eZ/Publish/Core/FieldType/Tests/Integration/Url/UrlStorage/UrlStorageGatewayTest.php @@ -0,0 +1,42 @@ +getGateway(); + + $urlIds = []; + $urlIds[] = $gateway->insertUrl('https://ibexa.co/example1'); + $urlIds[] = $gateway->insertUrl('https://ibexa.co/example2'); + $urlIds[] = $gateway->insertUrl('https://ibexa.co/example3'); + + $gateway->linkUrl($urlIds[0], 10, 1); + $gateway->linkUrl($urlIds[1], 10, 1); + $gateway->linkUrl($urlIds[1], 12, 2); + $gateway->linkUrl($urlIds[2], 14, 1); + + self::assertEquals(['https://ibexa.co/example1' => true, 'https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(10, 1), 'Did not get expected urlS for field 10'); + self::assertEquals(['https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(12, 2), 'Did not get expected url for field 12'); + self::assertEquals(['https://ibexa.co/example3' => true], $gateway->getUrlsFromUrlLink(14, 1), 'Did not get expected url for field 14'); + self::assertEquals([], $gateway->getUrlsFromUrlLink(15, 1), 'Expected no urls for field 15'); + } +} diff --git a/eZ/Publish/Core/FieldType/Tests/Url/Gateway/DoctrineStorageTest.php b/eZ/Publish/Core/FieldType/Tests/Url/Gateway/DoctrineStorageTest.php index 1a281224e2..376bc3b400 100644 --- a/eZ/Publish/Core/FieldType/Tests/Url/Gateway/DoctrineStorageTest.php +++ b/eZ/Publish/Core/FieldType/Tests/Url/Gateway/DoctrineStorageTest.php @@ -194,34 +194,11 @@ public function testUnlinkUrl() $this->assertEquals($expected, $result); } - /** - * @covers \eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway\DoctrineStorage::getUrlsFromUrlLink - */ - public function testGetUrlsFromUrlLink() - { - $gateway = $this->getStorageGateway(); - - $urlIds = []; - $urlIds[] = $gateway->insertUrl('https://ibexa.co/example1'); - $urlIds[] = $gateway->insertUrl('https://ibexa.co/example2'); - $urlIds[] = $gateway->insertUrl('https://ibexa.co/example3'); - - $gateway->linkUrl($urlIds[0], 10, 1); - $gateway->linkUrl($urlIds[1], 10, 1); - $gateway->linkUrl($urlIds[1], 12, 2); - $gateway->linkUrl($urlIds[2], 14, 1); - - self::assertEquals(['https://ibexa.co/example1' => true, 'https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(10, 1), 'Did not get expected urlS for field 10'); - self::assertEquals(['https://ibexa.co/example2' => true], $gateway->getUrlsFromUrlLink(12, 2), 'Did not get expected url for field 12'); - self::assertEquals(['https://ibexa.co/example3' => true], $gateway->getUrlsFromUrlLink(14, 1), 'Did not get expected url for field 14'); - self::assertEquals([], $gateway->getUrlsFromUrlLink(15, 1), 'Expected no urls for field 15'); - } - protected function getStorageGateway(): Gateway { if (!isset($this->storageGateway)) { $this->storageGateway = new DoctrineStorage($this->getDatabaseConnection()); - } + } return $this->storageGateway; } diff --git a/tests/integration/Core/FieldType/Url/UrlStorage/Gateway/UrlDoctrineStorageGatewayTest.php b/tests/integration/Core/FieldType/Url/UrlStorage/Gateway/UrlDoctrineStorageGatewayTest.php new file mode 100644 index 0000000000..16e72c251c --- /dev/null +++ b/tests/integration/Core/FieldType/Url/UrlStorage/Gateway/UrlDoctrineStorageGatewayTest.php @@ -0,0 +1,21 @@ +getDatabaseConnection()); + } +}