You are here

protected function AgreementSubscriberTest::getAgreementHandlerStub in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/EventSubscriber/AgreementSubscriberTest.php \Drupal\Tests\agreement\Unit\EventSubscriber\AgreementSubscriberTest::getAgreementHandlerStub()

Get the mocked agreement handler.

Parameters

bool $willHaveAgreement: Whether an agreement object should be returned or not.

Return value

object The mocked agreement handler object.

1 call to AgreementSubscriberTest::getAgreementHandlerStub()
AgreementSubscriberTest::testCheckForRedirection in tests/src/Unit/EventSubscriber/AgreementSubscriberTest.php
Asserts that check for redirection method is functional.

File

tests/src/Unit/EventSubscriber/AgreementSubscriberTest.php, line 85

Class

AgreementSubscriberTest
Tests the agreement route subscriber.

Namespace

Drupal\Tests\agreement\Unit\EventSubscriber

Code

protected function getAgreementHandlerStub($willHaveAgreement = FALSE) {
  $agreement = FALSE;
  if ($willHaveAgreement) {
    $agreementProphet = $this
      ->prophesize('\\Drupal\\agreement\\Entity\\Agreement');
    $agreementProphet
      ->get('path')
      ->willReturn('test');
    $agreement = $agreementProphet
      ->reveal();
  }
  $handlerProphet = $this
    ->prophesize('\\Drupal\\agreement\\AgreementHandlerInterface');
  $handlerProphet
    ->getAgreementByUserAndPath(Argument::any(), Argument::any())
    ->willReturn($agreement);
  return $handlerProphet
    ->reveal();
}