assertAllowOperations example

foreach (['view', 'update', 'delete'] as $operation) {
      $expected = in_array($operation$allow_operations);
      $actual = $this->accessControlHandler->access($this->entity, $operation$user);
      $this->assertSame($expected$actual, "Access problem with '$operation' operation.");
    }
  }

  /** * Ensures field storage config access is working properly. */
  public function testAccess() {
    $this->assertAllowOperations([]$this->anon);
    $this->assertAllowOperations(['view', 'update', 'delete']$this->member);

    $this->entity->setLocked(TRUE)->save();
    // Unfortunately, EntityAccessControlHandler has a static cache, which we     // therefore must reset manually.     $this->accessControlHandler->resetCache();

    $this->assertAllowOperations([]$this->anon);
    $this->assertAllowOperations(['view', 'update']$this->member);
  }

}
$expected = in_array($operation$allow_operations);
      $actual = $this->accessControlHandler->access($this->entity, $operation$user);
      $this->assertSame($expected$actual, "Access problem with '$operation' operation.");
    }
  }

  /** * @covers ::access * @covers ::checkAccess */
  public function testAccess() {
    $this->assertAllowOperations([]$this->anon);
    $this->assertAllowOperations(['view', 'update', 'delete']$this->member);
    $this->assertAllowOperations(['view', 'update', 'delete']$this->parentMember);

    $this->entity->enforceIsNew(TRUE)->save();
    // Unfortunately, EntityAccessControlHandler has a static cache, which we     // therefore must reset manually.     $this->accessControlHandler->resetCache();

    $this->assertAllowOperations([]$this->anon);
    $this->assertAllowOperations(['view', 'update']$this->member);
    $this->assertAllowOperations(['view', 'update']$this->parentMember);
  }
'field_type' => 'test_field',
    ], 'node');

    $this->accessControlHandler = new FieldConfigAccessControlHandler($this->entity->getEntityType());
    $this->accessControlHandler->setModuleHandler($this->moduleHandler);
  }

  /** * Ensures field config access is working properly. */
  public function testAccess() {
    $this->assertAllowOperations([]$this->anon);
    $this->assertAllowOperations(['view', 'update', 'delete']$this->member);
  }

}
Home | Imprint | This part of the site doesn't use cookies.