本文整理汇总了PHP中Drupal\views\Tests\ViewUnitTestBase::setUp方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewUnitTestBase::setUp方法的具体用法?PHP ViewUnitTestBase::setUp怎么用?PHP ViewUnitTestBase::setUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Tests\ViewUnitTestBase
的用法示例。
在下文中一共展示了ViewUnitTestBase::setUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Setup the needed tables in order to make the drupal router working.
$this->installSchema('system', array('url_alias'));
$this->installSchema('menu_link', 'menu_links');
}
示例2: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
$this->storage = $this->container->get('entity.manager')->getStorage('entity_test');
}
示例3: setUp
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE)
{
parent::setUp($import_test_views);
$this->installEntitySchema('user');
$this->installEntitySchema('comment');
// Create the anonymous role.
$this->installConfig(['user']);
// Create an anonymous user.
$storage = \Drupal::entityManager()->getStorage('user');
// Insert a row for the anonymous user.
$storage->create(array('uid' => 0, 'status' => 0))->save();
$admin_role = Role::create(['id' => 'admin', 'permissions' => ['administer comments', 'access user profiles']]);
$admin_role->save();
/* @var \Drupal\user\RoleInterface $anonymous_role */
$anonymous_role = Role::load(Role::ANONYMOUS_ID);
$anonymous_role->grantPermission('access comments');
$anonymous_role->save();
$this->adminUser = User::create(['name' => $this->randomMachineName(), 'roles' => [$admin_role->id()]]);
$this->adminUser->save();
// Create some comments.
$comment = Comment::create(['subject' => 'My comment title', 'uid' => $this->adminUser->id(), 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'status' => 1]);
$comment->save();
$comment_anonymous = Comment::create(['subject' => 'Anonymous comment title', 'uid' => 0, 'name' => 'barry', 'mail' => 'test@example.com', 'homepage' => 'https://example.com', 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'created' => 123456, 'status' => 1]);
$comment_anonymous->save();
}
示例4: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->enableModules(array('system', 'dblog'));
$this->installSchema('dblog', array('watchdog'));
ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
}
示例5: setUp
protected function setUp()
{
parent::setUp();
$this->installConfig(array('language'));
// Create another language beside English.
ConfigurableLanguage::create(array('id' => 'xx-lolspeak', 'label' => 'Lolspeak'))->save();
}
示例6: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Install the necessary dependencies for node type creation to work.
$this->installEntitySchema('node');
$this->installConfig(array('field', 'node'));
}
示例7: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views'));
$field_storage = FieldStorageConfig::create(array('entity_type' => 'entity_test', 'field_name' => 'field_test', 'type' => 'entity_reference', 'settings' => array('target_type' => 'entity_test'), 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED));
$field_storage->save();
$field = FieldConfig::create(array('entity_type' => 'entity_test', 'field_name' => 'field_test', 'bundle' => 'entity_test', 'settings' => array('handler' => 'default', 'handler_settings' => array())));
$field->save();
// Create some test entities which link each other.
$entity_storage = \Drupal::entityManager()->getStorage('entity_test');
$referenced_entity = $entity_storage->create(array());
$referenced_entity->save();
$this->entities[$referenced_entity->id()] = $referenced_entity;
$entity = $entity_storage->create(array());
$entity->field_test->target_id = $referenced_entity->id();
$entity->save();
$this->assertEqual($entity->field_test[0]->entity->id(), $referenced_entity->id());
$this->entities[$entity->id()] = $entity;
$entity = $entity_storage->create(array());
$entity->field_test->target_id = $referenced_entity->id();
$entity->save();
$this->assertEqual($entity->field_test[0]->entity->id(), $referenced_entity->id());
$this->entities[$entity->id()] = $entity;
Views::viewsData()->clear();
}
示例8: setUp
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE)
{
parent::setUp($import_test_views);
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
$this->installEntitySchema('user');
}
示例9: setUp
protected function setUp()
{
parent::setUp();
$this->installConfig(array('language'));
$this->enableModules(array('views_ui'));
$this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', array());
}
示例10: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->installConfig(array('taxonomy'));
\Drupal::service('router.builder')->rebuild();
}
示例11: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Rebuild the router, otherwise we can't generate links.
$this->container->get('router.builder')->rebuild();
$this->installSchema('dblog', array('watchdog'));
ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
}
示例12: setUp
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE)
{
parent::setUp($import_test_views);
$this->installEntitySchema('node');
$this->installEntitySchema('taxonomy_term');
$this->installEntitySchema('user');
// Setup the current time properly.
\Drupal::request()->server->set('REQUEST_TIME', time());
}
示例13: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
$this->installEntitySchema('entity_test_mul');
$this->storage = $this->container->get('entity.manager')->getStorage('entity_test');
ConfigurableLanguage::createFromLangcode('it')->save();
}
示例14: setUp
protected function setUp()
{
parent::setUp();
ViewTestData::createTestViews(get_class($this), array('user_test_views'));
$this->installEntitySchema('user');
$entity_manager = $this->container->get('entity.manager');
$this->roleStorage = $entity_manager->getStorage('user_role');
$this->userStorage = $entity_manager->getStorage('user');
}
示例15: setUp
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('aggregator_item');
$this->installEntitySchema('aggregator_feed');
ViewTestData::createTestViews(get_class($this), array('aggregator_test_views'));
$this->itemStorage = $this->container->get('entity.manager')->getStorage('aggregator_item');
$this->feedStorage = $this->container->get('entity.manager')->getStorage('aggregator_feed');
}