diff --git a/eZ/Publish/Core/SignalSlot/Signal/URLService/UpdateUrlSignal.php b/eZ/Publish/Core/SignalSlot/Signal/URLService/UpdateUrlSignal.php index 6507b981bfc..9cc1dd9cb76 100644 --- a/eZ/Publish/Core/SignalSlot/Signal/URLService/UpdateUrlSignal.php +++ b/eZ/Publish/Core/SignalSlot/Signal/URLService/UpdateUrlSignal.php @@ -19,4 +19,13 @@ class UpdateUrlSignal extends Signal * @var int */ public $urlId; + + /** + * If URL address was changed. + * + * @var bool + * + * @since 6.13.2 + */ + public $urlChanged; } diff --git a/eZ/Publish/Core/SignalSlot/Tests/URLServiceTest.php b/eZ/Publish/Core/SignalSlot/Tests/URLServiceTest.php new file mode 100644 index 00000000000..639309dc0bf --- /dev/null +++ b/eZ/Publish/Core/SignalSlot/Tests/URLServiceTest.php @@ -0,0 +1,96 @@ +getApiUrl(12, 'http://ez.no'); + + return [ + [ + 'updateUrl', + [ + $url, + new URLUpdateStruct([ + 'url' => 'http://ezplatform.com', + ]), + ], + $this->getApiUrl(12, 'http://ezplatform.com', true), + 1, + UpdateUrlSignal::class, + ['urlId' => $url->id, 'urlChanged' => true], + ], + [ + 'updateUrl', + [ + $url, + new URLUpdateStruct([ + 'isValid' => false, + ]), + ], + $this->getApiUrl(12, 'http://ez.no', false), + 1, + UpdateUrlSignal::class, + ['urlId' => $url->id, 'urlChanged' => false], + ], + [ + 'createUpdateStruct', + [], + new URLUpdateStruct(), + 0, + ], + [ + 'findUrls', + [new URLQuery()], + new SearchResult(), + 0, + ], + [ + 'loadById', + [12], + $url, + 0, + ], + [ + 'loadByUrl', + ['http://ez.no'], + $url, + 0, + ], + ]; + } + + protected function getServiceMock() + { + return $this->createMock(APIURLService::class); + } + + protected function getSignalSlotService($innerService, SignalDispatcher $dispatcher) + { + return new URLService($innerService, $dispatcher); + } + + private function getApiUrl($id = null, $url = null, $isValid = false) + { + return new URL([ + 'id' => $id, + 'url' => $url, + 'isValid' => $isValid, + ]); + } +} diff --git a/eZ/Publish/Core/SignalSlot/URLService.php b/eZ/Publish/Core/SignalSlot/URLService.php index 3f912bdd19c..1298f218131 100644 --- a/eZ/Publish/Core/SignalSlot/URLService.php +++ b/eZ/Publish/Core/SignalSlot/URLService.php @@ -90,6 +90,7 @@ public function updateUrl(URL $url, URLUpdateStruct $struct) $this->signalDispatcher->emit( new UpdateUrlSignal([ 'urlId' => $returnValue->id, + 'urlChanged' => $struct->url !== null, ]) );