function EntityPathAliasCreateTest::getMockEntity

Creates a mock entity.

Return value

\Drupal\Core\Entity\EntityInterface|\Prophecy\Prophecy\ProphecyInterface The mocked entity object.

2 calls to EntityPathAliasCreateTest::getMockEntity()
EntityPathAliasCreateTest::testActionExecutionWithSavedEntity in tests/src/Unit/Integration/RulesAction/EntityPathAliasCreateTest.php
Tests the action execution with a saved entity.
EntityPathAliasCreateTest::testActionExecutionWithUnsavedEntity in tests/src/Unit/Integration/RulesAction/EntityPathAliasCreateTest.php
Tests the action execution with an unsaved entity.

File

tests/src/Unit/Integration/RulesAction/EntityPathAliasCreateTest.php, line 123

Class

EntityPathAliasCreateTest
@coversDefaultClass \Drupal\rules\Plugin\RulesAction\EntityPathAliasCreate @group RulesAction

Namespace

Drupal\Tests\rules\Unit\Integration\RulesAction

Code

protected function getMockEntity() {
    $language = $this->languageManager
        ->reveal()
        ->getCurrentLanguage();
    $entity = $this->prophesizeEntity(EntityInterface::class);
    $entity->language()
        ->willReturn($language)
        ->shouldBeCalledTimes(1);
    $url = $this->prophesize(Url::class);
    $url->getInternalPath()
        ->willReturn('test/1')
        ->shouldBeCalledTimes(1);
    $entity->toUrl(Argument::any())
        ->willReturn($url->reveal())
        ->shouldBeCalledTimes(1);
    return $entity;
}