-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c3fc4f
commit 9a1e3a8
Showing
2 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
.../spec/Ivoz/Provider/Domain/Service/MediaRelaySet/SendTrunksRtpengineReloadRequestSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
namespace spec\Ivoz\Provider\Domain\Service\MediaRelaySet; | ||
|
||
use Ivoz\Core\Domain\Service\LifecycleEventHandlerInterface; | ||
use Ivoz\Kam\Domain\Service\TrunksClientInterface; | ||
use Ivoz\Provider\Domain\Model\MediaRelaySet\MediaRelaySet; | ||
use Ivoz\Provider\Domain\Model\MediaRelaySet\MediaRelaySetInterface; | ||
use Ivoz\Provider\Domain\Service\MediaRelaySet\MediaRelaySetEventHandlerInterface; | ||
use Ivoz\Provider\Domain\Service\MediaRelaySet\SendTrunksRtpengineReloadRequest; | ||
use PhpSpec\Exception\Example\FailureException; | ||
use PhpSpec\ObjectBehavior; | ||
use spec\HelperTrait; | ||
|
||
class SendTrunksRtpengineReloadRequestSpec extends ObjectBehavior | ||
{ | ||
use HelperTrait; | ||
|
||
protected $trunksCient; | ||
|
||
public function let() | ||
{ | ||
$this->trunksCient = $this->getTestDouble(TrunksClientInterface::class); | ||
|
||
$this->beConstructedWith( | ||
$this->trunksCient | ||
); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(SendTrunksRtpengineReloadRequest::class); | ||
} | ||
|
||
function it_should_be_on_commit_lifecycle_service() | ||
{ | ||
$this->shouldBeAnInstanceOf( | ||
MediaRelaySetEventHandlerInterface::class | ||
); | ||
|
||
$binding = SendTrunksRtpengineReloadRequest::getSubscribedEvents(); | ||
|
||
if ($binding != [LifecycleEventHandlerInterface::EVENT_ON_COMMIT => 300]) { | ||
throw new FailureException('On commit binding expected'); | ||
} | ||
} | ||
|
||
function it_sends_rtpengine_reload_request() | ||
{ | ||
$mediaRelaySet = $this->getTestDouble(MediaRelaySetInterface::class); | ||
$this->prepareExecution($mediaRelaySet); | ||
|
||
$this | ||
->trunksCient | ||
->reloadRtpengine() | ||
->will(function () { | ||
}) | ||
->shouldBeCalled(); | ||
|
||
$this->execute($mediaRelaySet->reveal()); | ||
} | ||
|
||
function it_requires_hasBeenDeleted_to_be_true() | ||
{ | ||
$mediaRelaySet = $this->getTestDouble(MediaRelaySetInterface::class); | ||
$this->prepareExecution($mediaRelaySet); | ||
|
||
$this | ||
->trunksCient | ||
->reloadRtpengine() | ||
->will(function () { | ||
}) | ||
->shouldBeCalled(); | ||
|
||
$this->execute($mediaRelaySet->reveal()); | ||
} | ||
|
||
private function prepareExecution($mediaRelaySet) | ||
{ | ||
$this->getterProphecy( | ||
$mediaRelaySet, | ||
[ | ||
'getId' => 1, | ||
'hasBeenDeleted' => true | ||
], | ||
false | ||
); | ||
|
||
$this->fluentSetterProphecy( | ||
$this->trunksCient, | ||
[ | ||
], | ||
false | ||
); | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
...y/spec/Ivoz/Provider/Domain/Service/MediaRelaySet/SendUsersRtpengineReloadRequestSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace spec\Ivoz\Provider\Domain\Service\MediaRelaySet; | ||
|
||
use Ivoz\Core\Domain\Service\LifecycleEventHandlerInterface; | ||
use Ivoz\Kam\Domain\Service\UsersClientInterface; | ||
use Ivoz\Provider\Domain\Model\MediaRelaySet\MediaRelaySetInterface; | ||
use Ivoz\Provider\Domain\Service\MediaRelaySet\MediaRelaySetEventHandlerInterface; | ||
use Ivoz\Provider\Domain\Service\MediaRelaySet\SendUsersRtpengineReloadRequest; | ||
use PhpSpec\Exception\Example\FailureException; | ||
use PhpSpec\ObjectBehavior; | ||
use spec\HelperTrait; | ||
|
||
class SendUsersRtpengineReloadRequestSpec extends ObjectBehavior | ||
{ | ||
use HelperTrait; | ||
|
||
protected $usersClient; | ||
|
||
public function let() | ||
{ | ||
$this->usersClient = $this->getTestDouble(UsersClientInterface::class); | ||
|
||
$this->beConstructedWith( | ||
$this->usersClient | ||
); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(SendUsersRtpengineReloadRequest::class); | ||
} | ||
|
||
function it_should_be_on_commit_lifecycle_service() | ||
{ | ||
$this->shouldBeAnInstanceOf( | ||
MediaRelaySetEventHandlerInterface::class | ||
); | ||
|
||
$binding = SendUsersRtpengineReloadRequest::getSubscribedEvents(); | ||
|
||
if ($binding != [LifecycleEventHandlerInterface::EVENT_ON_COMMIT => 300]) { | ||
throw new FailureException('On commit binding expected'); | ||
} | ||
} | ||
|
||
function it_sends_rtpengine_reload_request() | ||
{ | ||
$mediaRelaySet = $this->getTestDouble(MediaRelaySetInterface::class); | ||
$this->prepareExecution($mediaRelaySet); | ||
|
||
$this | ||
->usersClient | ||
->reloadRtpengine() | ||
->will(function () { | ||
}) | ||
->shouldBeCalled(); | ||
|
||
$this->execute($mediaRelaySet->reveal()); | ||
} | ||
|
||
function it_requires_hasBeenDeleted_to_be_true() | ||
{ | ||
$mediaRelaySet = $this->getTestDouble(MediaRelaySetInterface::class); | ||
$this->prepareExecution($mediaRelaySet); | ||
|
||
$this | ||
->usersClient | ||
->reloadRtpengine() | ||
->will(function () { | ||
}) | ||
->shouldBeCalled(); | ||
|
||
$this->execute($mediaRelaySet->reveal()); | ||
} | ||
|
||
private function prepareExecution($mediaRelaySet) | ||
{ | ||
$this->getterProphecy( | ||
$mediaRelaySet, | ||
[ | ||
'getId' => 1, | ||
'hasBeenDeleted' => true | ||
], | ||
false | ||
); | ||
|
||
$this->fluentSetterProphecy( | ||
$this->usersClient, | ||
[ | ||
], | ||
false | ||
); | ||
} | ||
} |