本文整理汇总了PHP中Drupal\views\Tests\ViewTestData类的典型用法代码示例。如果您正苦于以下问题:PHP ViewTestData类的具体用法?PHP ViewTestData怎么用?PHP ViewTestData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewTestData类的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() {
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);
}
示例5: viewsData
/**
* Returns the views data definition.
*/
protected function viewsData()
{
$data = ViewTestData::viewsData();
// Tweak the views data to have a base for testing.
unset($data['views_test_data']['id']['field']);
unset($data['views_test_data']['name']['argument']);
unset($data['views_test_data']['age']['filter']);
unset($data['views_test_data']['job']['sort']);
$data['views_test_data']['created']['area']['id'] = 'text';
$data['views_test_data']['age']['area']['id'] = 'text';
$data['views_test_data']['age']['area']['sub_type'] = 'header';
$data['views_test_data']['job']['area']['id'] = 'text';
$data['views_test_data']['job']['area']['sub_type'] = array('header', 'footer');
// Duplicate the example views test data for different weight, different title,
// and matching data.
$data['views_test_data_2'] = $data['views_test_data'];
$data['views_test_data_2']['table']['base']['weight'] = 50;
$data['views_test_data_3'] = $data['views_test_data'];
$data['views_test_data_3']['table']['base']['weight'] = -50;
$data['views_test_data_4'] = $data['views_test_data'];
$data['views_test_data_4']['table']['base']['title'] = 'A different title';
$data['views_test_data_5'] = $data['views_test_data'];
$data['views_test_data_5']['table']['base']['title'] = 'Z different title';
$data['views_test_data_6'] = $data['views_test_data'];
return $data;
}
示例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
protected function setUp($import_test_views = TRUE)
{
parent::setUp($import_test_views);
if ($import_test_views) {
ViewTestData::createTestViews(get_class($this), array('node_test_views'));
}
}
示例8: 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'));
}
示例9: 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'));
}
示例10: 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);
}
示例11: 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'));
}
示例12: 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']);
}
}
示例13: setUp
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('profile');
$this->installEntitySchema('profile_type');
ViewTestData::createTestViews(get_class($this), ['profile_test']);
}
示例14: 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'));
}
示例15: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Create and login user.
$this->privileged_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages'));
$this->drupalLogin($this->privileged_user);
ViewTestData::createTestViews(get_class($this), array('sharethis_test_views'));
}