コード例 #1
0
ファイル: TourCacheTagsTest.php プロジェクト: 318io/318-io
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Give anonymous users permission to view nodes, so that we can verify the
     // cache tags of cached versions of node pages.
     Role::load(RoleInterface::ANONYMOUS_ID)->grantPermission('access tour')->save();
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Give anonymous users permission to view test entities, so that we can
     // verify the cache tags of cached versions of test entity pages.
     $user_role = Role::load(RoleInterface::ANONYMOUS_ID);
     $user_role->grantPermission('view test entity');
     $user_role->save();
     // Create an entity.
     $this->entity = $this->createEntity();
     // If this is an entity with field UI enabled, then add a configurable
     // field. We will use this configurable field in later tests to ensure that
     // field configuration invalidate render cache entries.
     if ($this->entity->getEntityType()->get('field_ui_base_route')) {
         // Add field, so we can modify the field storage and field entities to
         // verify that changes to those indeed clear cache tags.
         entity_create('field_storage_config', array('field_name' => 'configurable_field', 'entity_type' => $this->entity->getEntityTypeId(), 'type' => 'test_field', 'settings' => array()))->save();
         entity_create('field_config', array('entity_type' => $this->entity->getEntityTypeId(), 'bundle' => $this->entity->bundle(), 'field_name' => 'configurable_field', 'label' => 'Configurable field', 'settings' => array()))->save();
         // Reload the entity now that a new field has been added to it.
         $storage = $this->container->get('entity.manager')->getStorage($this->entity->getEntityTypeId());
         $storage->resetCache();
         $this->entity = $storage->load($this->entity->id());
     }
     // Create a referencing and a non-referencing entity.
     list($this->referencingEntity, $this->nonReferencingEntity, ) = $this->createReferenceTestEntities($this->entity);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Give anonymous users permission to view test entities, so that we can
     // verify the cache tags of cached versions of test entity pages.
     $user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
     $user_role->grantPermission('view test entity');
     $user_role->save();
     // Create an entity.
     $this->entity = $this->createEntity();
     // If this is a fieldable entity, then add a configurable field. We will use
     // this configurable field in later tests to ensure that modifications to
     // field (instance) configuration invalidate render cache entries.
     if ($this->entity->getEntityType()->isFieldable()) {
         // Add field, so we can modify the Field and FieldInstance entities to
         // verify that changes to those indeed clear cache tags.
         entity_create('field_storage_config', array('name' => 'configurable_field', 'entity_type' => $this->entity->getEntityTypeId(), 'type' => 'test_field', 'settings' => array()))->save();
         entity_create('field_instance_config', array('entity_type' => $this->entity->getEntityTypeId(), 'bundle' => $this->entity->bundle(), 'field_name' => 'configurable_field', 'label' => 'Configurable field', 'settings' => array()))->save();
         // Reload the entity now that a new field has been added to it.
         $storage = $this->container->get('entity.manager')->getStorage($this->entity->getEntityTypeId());
         $storage->resetCache();
         $this->entity = $storage->load($this->entity->id());
     }
     // Create a referencing and a non-referencing entity.
     list($this->referencing_entity, $this->non_referencing_entity, ) = $this->createReferenceTestEntities($this->entity);
 }
コード例 #4
0
ファイル: UserPasswordResetTest.php プロジェクト: brstde/gap1
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->drupalPlaceBlock('system_menu_block:account');
     // Create a user.
     $account = $this->drupalCreateUser();
     // Activate user by logging in.
     $this->drupalLogin($account);
     $this->account = User::load($account->id());
     $this->drupalLogout();
     // Set the last login time that is used to generate the one-time link so
     // that it is definitely over a second ago.
     $account->login = REQUEST_TIME - mt_rand(10, 100000);
     db_update('users_field_data')->fields(array('login' => $account->getLastLoginTime()))->condition('uid', $account->id())->execute();
 }