Skip to content

Commit

Permalink
Merge branch '6.13' into 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Mar 23, 2018
2 parents 9f8c871 + ea8b6fb commit bcff12b
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
Expand Up @@ -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;
}
96 changes: 96 additions & 0 deletions eZ/Publish/Core/SignalSlot/Tests/URLServiceTest.php
@@ -0,0 +1,96 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\Core\SignalSlot\Tests;

use eZ\Publish\API\Repository\URLService as APIURLService;
use eZ\Publish\API\Repository\Values\URL\SearchResult;
use eZ\Publish\API\Repository\Values\URL\URL;
use eZ\Publish\API\Repository\Values\URL\URLQuery;
use eZ\Publish\API\Repository\Values\URL\URLUpdateStruct;
use eZ\Publish\Core\SignalSlot\SignalDispatcher;
use eZ\Publish\Core\SignalSlot\Signal\URLService\UpdateUrlSignal;
use eZ\Publish\Core\SignalSlot\URLService;

class URLServiceTest extends ServiceTest
{
public function serviceProvider()
{
$url = $this->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,
]);
}
}
1 change: 1 addition & 0 deletions eZ/Publish/Core/SignalSlot/URLService.php
Expand Up @@ -90,6 +90,7 @@ public function updateUrl(URL $url, URLUpdateStruct $struct)
$this->signalDispatcher->emit(
new UpdateUrlSignal([
'urlId' => $returnValue->id,
'urlChanged' => $struct->url !== null,
])
);

Expand Down

0 comments on commit bcff12b

Please sign in to comment.