Esempio n. 1
0
 /**
  * @covers ::andIf
  * @covers ::orIf
  * @covers ::inheritCacheability
  *
  * @dataProvider andOrCacheabilityPropagationProvider
  */
 public function testAndOrCacheabilityPropagation(AccessResultInterface $first, $op, AccessResultInterface $second, $implements_cacheable_dependency_interface, $is_cacheable)
 {
     if ($op === 'OR') {
         $result = $first->orIf($second);
     } else {
         if ($op === 'AND') {
             $result = $first->andIf($second);
         } else {
             throw new \LogicException('Invalid operator specified');
         }
     }
     if ($implements_cacheable_dependency_interface) {
         $this->assertTrue($result instanceof CacheableDependencyInterface, 'Result is an instance of CacheableDependencyInterface.');
         if ($result instanceof CacheableDependencyInterface) {
             $this->assertSame($is_cacheable, $result->getCacheMaxAge() !== 0, 'getCacheMaxAge() matches expectations.');
         }
     } else {
         $this->assertFalse($result instanceof CacheableDependencyInterface, 'Result is not an instance of CacheableDependencyInterface.');
     }
 }
 /**
  * Sets an access check result.
  *
  * @param \Drupal\Core\Access\AccessResultInterface
  *
  * @return $this
  */
 public function setAccessResult(AccessResultInterface $access_result)
 {
     $this->accessResult = $this->accessResult->orIf($access_result);
     return $this;
 }