本文整理汇总了PHP中Drupal\simpletest\DrupalUnitTestBase类的典型用法代码示例。如果您正苦于以下问题:PHP DrupalUnitTestBase类的具体用法?PHP DrupalUnitTestBase怎么用?PHP DrupalUnitTestBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DrupalUnitTestBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->actionManager = $this->container->get('plugin.manager.action');
$this->installEntitySchema('user');
$this->installSchema('system', array('sequences'));
}
示例2: setUp
/**
* {@inheritdoc}
*/
function setUp()
{
parent::setUp();
$this->installSchema('system', array('url_alias', 'router'));
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
$this->installConfig(array('field', 'language'));
// Add English as a language.
$english = new Language(array('id' => 'en', 'name' => 'English'));
language_save($english);
// Add German as a language.
$german = new Language(array('id' => 'de', 'name' => 'Deutsch', 'weight' => -1));
language_save($german);
// Create the test text field.
entity_create('field_storage_config', array('name' => 'field_test_text', 'entity_type' => 'entity_test', 'type' => 'text'))->save();
entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test_text', 'bundle' => 'entity_test', 'translatable' => FALSE))->save();
// Create the test translatable field.
entity_create('field_storage_config', array('name' => 'field_test_translatable_text', 'entity_type' => 'entity_test', 'type' => 'text'))->save();
entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test_translatable_text', 'bundle' => 'entity_test', 'translatable' => TRUE))->save();
// Create the test entity reference field.
entity_create('field_storage_config', array('name' => 'field_test_entity_reference', 'entity_type' => 'entity_test', 'type' => 'entity_reference', 'settings' => array('target_type' => 'entity_test')))->save();
entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => 'field_test_entity_reference', 'bundle' => 'entity_test', 'translatable' => TRUE))->save();
$entity_manager = \Drupal::entityManager();
$link_manager = new LinkManager(new TypeLinkManager(new MemoryBackend('default')), new RelationLinkManager(new MemoryBackend('default'), $entity_manager));
$chain_resolver = new ChainEntityResolver(array(new UuidResolver($entity_manager), new TargetIdResolver()));
// Set up the mock serializer.
$normalizers = array(new ContentEntityNormalizer($link_manager, $entity_manager, \Drupal::moduleHandler()), new EntityReferenceItemNormalizer($link_manager, $chain_resolver), new FieldItemNormalizer(), new FieldNormalizer());
$encoders = array(new JsonEncoder());
$this->serializer = new Serializer($normalizers, $encoders);
}
示例3: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->container->get('module_handler')->loadInclude('user', 'install');
$this->installEntitySchema('user');
user_install();
}
示例4: setUp
protected function setUp()
{
parent::setUp();
// Ensure the global variable being asserted by this test does not exist;
// a previous test executed in this request/process might have set it.
unset($GLOBALS['hook_config_test']);
}
示例5: setUp
function setUp()
{
parent::setUp();
// Configure the theme system.
$this->installConfig(array('system', 'field'));
$this->installEntitySchema('entity_test');
// @todo Add helper methods for all of the following.
$this->entity_type = 'entity_test';
if (!isset($this->bundle)) {
$this->bundle = $this->entity_type;
}
$this->field_name = drupal_strtolower($this->randomName());
$this->field_type = 'text_long';
$this->field_settings = array();
$this->instance_settings = array('text_processing' => FALSE);
$this->formatter_type = 'string';
$this->formatter_settings = array();
$this->fieldStorage = entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => $this->entity_type, 'type' => $this->field_type, 'settings' => $this->field_settings));
$this->fieldStorage->save();
$this->instance = entity_create('field_instance_config', array('field_storage' => $this->fieldStorage, 'bundle' => $this->bundle, 'label' => $this->randomName(), 'settings' => $this->instance_settings));
$this->instance->save();
$this->view_mode = 'default';
$this->display = entity_get_display($this->entity_type, $this->bundle, $this->view_mode)->setComponent($this->field_name, array('type' => $this->formatter_type, 'settings' => $this->formatter_settings));
$this->display->save();
$this->langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
}
示例6: setUp
protected function setUp()
{
parent::setUp();
$this->installConfig(array('system'));
$this->installSchema('system', array('router'));
\Drupal::service('router.builder')->rebuild();
}
示例7: setUp
function setUp()
{
parent::setUp();
// There are dependencies in drupal_get_js() on the theme layer so we need
// to initialize it.
drupal_theme_initialize();
}
示例8: setUp
/**
* Set the default field storage backend for fields created during tests.
*/
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('user');
// Set default storage backend.
$this->installConfig(array('field'));
}
示例9: setUp
/**
* Sets the default field storage backend for fields created during tests.
*/
protected function setUp()
{
parent::setUp();
$this->fields = new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS);
$this->installEntitySchema('entity_test');
$this->installConfig(array('field', 'filter'));
}
示例10: setUp
public function setUp()
{
parent::setUp();
// Update the config snapshot. This allows the parent::setUp() to write
// configuration files.
\Drupal::service('config.manager')->createSnapshot(\Drupal::service('config.storage'), \Drupal::service('config.storage.snapshot'));
$this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging'));
}
示例11: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->installEntitySchema('user');
$this->installSchema('system', array('sequences'));
// Make sure that the default roles exist.
$this->installConfig(array('user'));
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->installConfig(array('language'));
// Setup Italian.
ConfigurableLanguage::createFromLangcode('it')->save();
$this->manager = $this->container->get('plugin.manager.condition');
}
示例13: setUp
protected function setUp()
{
parent::setUp();
$this->installConfig(array('system'));
$manager = $this->container->get('plugin.manager.filter');
$bag = new FilterBag($manager, array());
$this->filters = $bag->getAll();
}
示例14: checkRequirements
protected function checkRequirements()
{
// GD2 support is available.
if (!function_exists('imagegd2')) {
return array('Image manipulations for the GD toolkit cannot run because the GD toolkit is not available.');
}
return parent::checkRequirements();
}
示例15: tearDown
function tearDown()
{
// Restore configured value for JavaScript preprocessing.
$config = \Drupal::config('system.performance');
$config->set('js.preprocess', $this->preprocess_js);
$config->save();
parent::tearDown();
}