本文整理汇总了PHP中Drupal\views\Tests\ViewTestData::createTestViews方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewTestData::createTestViews方法的具体用法?PHP ViewTestData::createTestViews怎么用?PHP ViewTestData::createTestViews使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Tests\ViewTestData
的用法示例。
在下文中一共展示了ViewTestData::createTestViews方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
parent::setUp();
// Add two new languages.
ConfigurableLanguage::createFromLangcode('fr')->save();
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up term names.
$this->termNames = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris');
// Create a vocabulary.
$this->vocabulary = Vocabulary::create(['name' => 'Views testing tags', 'vid' => 'views_testing_tags']);
$this->vocabulary->save();
// Add a translatable field to the vocabulary.
$field = FieldStorageConfig::create(array('field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'type' => 'text'));
$field->save();
FieldConfig::create(['field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'label' => 'Foo', 'bundle' => 'views_testing_tags'])->save();
// Create term with translations.
$taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
foreach (array('es', 'fr') as $langcode) {
$translation = $taxonomy->addTranslation($langcode, array('name' => $this->termNames[$langcode]));
$translation->description->value = $this->termNames[$langcode];
$translation->field_foo->value = $this->termNames[$langcode];
}
$taxonomy->save();
Views::viewsData()->clear();
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
$this->container->get('router.builder')->rebuild();
}
示例2: setUp
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE)
{
parent::setUp($import_test_views);
if ($import_test_views) {
ViewTestData::createTestViews(get_class($this), ['entity_module_test']);
}
}
示例3: 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();
}
示例4: setUp
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE)
{
parent::setUp(FALSE);
$this->drupalCreateContentType(array('type' => 'page'));
$this->addDefaultCommentField('node', 'page');
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
}
示例5: setUp
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
// Create a Content type and some test nodes with titles that start with
// different letters.
$this->createContentType(['type' => 'page']);
$titles = [
'Page One',
'Page Two',
'Another page',
];
foreach ($titles as $title) {
$this->createNode([
'title' => $title,
'language' => 'en',
]);
$this->createNode([
'title' => $title,
'language' => 'nl',
]);
}
// Create a user privileged enough to use exposed filters and view content.
$user = $this->drupalCreateUser([
'administer site configuration',
'access content',
'access content overview',
]);
$this->drupalLogin($user);
}
示例6: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Create users.
$this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
ViewTestData::createTestViews(get_class($this), array('book_test_views'));
}
示例7: 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'));
}
示例8: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp(FALSE);
// Create Page content type.
if ($this->profile != 'standard') {
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
ViewTestData::createTestViews(get_class($this), array('node_test_views'));
}
// Add two new languages.
ConfigurableLanguage::createFromLangcode('fr')->save();
ConfigurableLanguage::createFromLangcode('es')->save();
// Make the body field translatable. The title is already translatable by
// definition.
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$field_storage->setTranslatable(TRUE);
$field_storage->save();
// Set up node titles. They should not include the words "French",
// "English", or "Spanish", as there is a language field in the view
// that prints out those words.
$this->node_titles = array('es' => array('Primero nodo es', 'Segundo nodo es', 'Tercera nodo es'), 'en' => array('First node en', 'Second node en'), 'fr' => array('Premier nœud fr'));
// Create nodes with translations.
foreach ($this->node_titles['es'] as $index => $title) {
$node = $this->drupalCreateNode(array('title' => $title, 'langcode' => 'es', 'type' => 'page', 'promote' => 1));
foreach (array('en', 'fr') as $langcode) {
if (isset($this->node_titles[$langcode][$index])) {
$translation = $node->addTranslation($langcode, array('title' => $this->node_titles[$langcode][$index]));
$translation->body->value = $this->randomMachineName(32);
}
}
$node->save();
}
$this->container->get('router.builder')->rebuild();
$user = $this->drupalCreateUser(array('access content overview', 'access content'));
$this->drupalLogin($user);
}
示例9: setUp
protected function setUp()
{
parent::setUp();
// Ensure the page node type exists.
NodeType::create(['type' => 'page', 'name' => 'page'])->save();
ViewTestData::createTestViews(get_class($this), array('field_test_views'));
}
示例10: setUp
protected function setUp($import_test_views = TRUE)
{
parent::setUp($import_test_views);
if ($import_test_views) {
ViewTestData::createTestViews(get_class($this), ['multiversion_test_views']);
}
}
示例11: setUp
protected function setUp($import_test_views = TRUE)
{
parent::setUp();
if ($import_test_views) {
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
}
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('profile');
$this->installEntitySchema('profile_type');
ViewTestData::createTestViews(get_class($this), ['profile_test']);
}
示例13: 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'));
}
示例14: setUp
protected function setUp()
{
parent::setUp();
// Create the user profile field and instance.
entity_create('field_storage_config', array('entity_type' => 'user', 'field_name' => 'user_file', 'type' => 'file', 'translatable' => '0'))->save();
entity_create('field_config', array('label' => 'User File', 'description' => '', 'field_name' => 'user_file', 'entity_type' => 'user', 'bundle' => 'user', 'required' => 0))->save();
ViewTestData::createTestViews(get_class($this), array('file_test_views'));
}
示例15: setUp
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE)
{
parent::setUp($import_test_views);
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installConfig(['node', 'field']);
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}