View source
<?php
namespace Drupal\ds\Tests;
use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\field_ui\Tests\FieldUiTestTrait;
use Drupal\simpletest\WebTestBase;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\taxonomy\Tests\TaxonomyTestTrait;
abstract class FastTestBase extends WebTestBase {
use DsTestTrait;
use EntityReferenceTestTrait;
use FieldUiTestTrait;
use TaxonomyTestTrait;
public static $modules = array(
'node',
'user',
'field_ui',
'rdf',
'quickedit',
'taxonomy',
'block',
'ds',
'ds_extras',
'ds_test',
'ds_switch_view_mode',
'layout_plugin',
'field_group',
);
protected $fieldLabel;
protected $fieldNameInput;
protected $fieldName;
protected $vocabulary;
protected $adminUser;
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('system_breadcrumb_block');
$this
->drupalPlaceBlock('local_tasks_block');
$this->adminUser = $this
->drupalCreateUser(array(
'access content',
'access in-place editing',
'admin classes',
'admin display suite',
'admin fields',
'administer nodes',
'view all revisions',
'administer content types',
'administer node fields',
'administer node form display',
'administer node display',
'administer taxonomy',
'administer taxonomy_term fields',
'administer taxonomy_term display',
'administer users',
'administer permissions',
'administer account settings',
'administer user display',
'administer software updates',
'access site in maintenance mode',
'administer site configuration',
'bypass node access',
'ds switch view mode',
));
$this
->drupalLogin($this->adminUser);
$this->fieldLabel = $this
->randomMachineName(8);
$this->fieldNameInput = strtolower($this
->randomMachineName(8));
$this->fieldName = 'field_' . $this->fieldNameInput;
$this
->drupalCreateContentType(array(
'type' => 'article',
'name' => 'Article',
'revision' => TRUE,
));
$this
->drupalCreateContentType(array(
'type' => 'page',
'name' => 'Page',
'revision' => TRUE,
));
$this->vocabulary = Vocabulary::create(array(
'name' => 'Tags',
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
$this->vocabulary
->save();
$term1 = Term::create(array(
'name' => 'Tag 1',
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
$term1
->save();
$term2 = Term::create(array(
'name' => 'Tag 2',
'vid' => 'tags',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
));
$term2
->save();
$handler_settings = array(
'target_bundles' => array(
$this->vocabulary
->id() => $this->vocabulary
->id(),
),
'auto_create' => TRUE,
);
$this
->createEntityReferenceField('node', 'article', 'field_' . $this->vocabulary
->id(), 'Tags', 'taxonomy_term', 'default', $handler_settings, 10);
entity_get_form_display('node', 'article', 'default')
->setComponent('field_' . $this->vocabulary
->id())
->save();
}
protected function assertTrimEqual($first, $second, $message = '', $group = 'Other') {
$first = (string) $first;
$second = (string) $second;
return $this
->assertEqual(trim($first), trim($second), $message, $group);
}
}