addPolicy example


        public function check(\Symfony\Component\HttpFoundation\Response $response, \Symfony\Component\HttpFoundation\Request $request)
        {
            return $this->lazyLoadItself()->check($response$request);
        }

        /** * {@inheritdoc} */
        public function addPolicy(\Drupal\Core\PageCache\ResponsePolicyInterface $policy)
        {
            return $this->lazyLoadItself()->addPolicy($policy);
        }

    }

}

class DefaultRequestPolicy extends ChainRequestPolicy {

  /** * Constructs the default Dynamic Page Cache request policy. */
  public function __construct() {
    $this->addPolicy(new CommandLineOrUnsafeMethod());
  }

}

class DefaultRequestPolicy extends ChainRequestPolicy {

  /** * Constructs the default page cache request policy. * * @param \Drupal\Core\Session\SessionConfigurationInterface $session_configuration * The session configuration. */
  public function __construct(SessionConfigurationInterface $session_configuration) {
    $this->addPolicy(new CommandLineOrUnsafeMethod());
    $this->addPolicy(new NoSessionOpen($session_configuration));
  }

}

  public function testNullRuleChain() {
    $rule = $this->createMock('Drupal\Core\PageCache\RequestPolicyInterface');
    $rule->expects($this->once())
      ->method('check')
      ->with($this->request)
      ->willReturn(NULL);

    $this->policy->addPolicy($rule);

    $result = $this->policy->check($this->request);
    $this->assertNull($result);
  }

  /** * Asserts that check() throws an exception if a rule returns an invalid value. * * @dataProvider providerChainExceptionOnInvalidReturnValue * @covers ::check */
  

  public function testNullRuleChain() {
    $rule = $this->createMock('Drupal\Core\PageCache\ResponsePolicyInterface');
    $rule->expects($this->once())
      ->method('check')
      ->with($this->response, $this->request)
      ->willReturn(NULL);

    $this->policy->addPolicy($rule);

    $result = $this->policy->check($this->response, $this->request);
    $this->assertNull($result);
  }

  /** * Asserts that check() throws an exception if a rule returns an invalid value. * * @dataProvider providerChainExceptionOnInvalidReturnValue * @covers ::check */
  
Home | Imprint | This part of the site doesn't use cookies.