当前位置: 首页>>代码示例>>PHP>>正文


PHP FilterFormat::loadMultiple方法代码示例

本文整理汇总了PHP中Drupal\filter\Entity\FilterFormat::loadMultiple方法的典型用法代码示例。如果您正苦于以下问题:PHP FilterFormat::loadMultiple方法的具体用法?PHP FilterFormat::loadMultiple怎么用?PHP FilterFormat::loadMultiple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\filter\Entity\FilterFormat的用法示例。


在下文中一共展示了FilterFormat::loadMultiple方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testStandard

 /**
  * Tests Standard installation profile.
  */
 function testStandard()
 {
     $this->drupalGet('');
     $this->assertLink(t('Contact'));
     $this->clickLink(t('Contact'));
     $this->assertResponse(200);
     // Test anonymous user can access 'Main navigation' block.
     $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'post comments', 'skip comment approval', 'create article content', 'create page content'));
     $this->drupalLogin($this->adminUser);
     // Configure the block.
     $this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
     $this->drupalPostForm(NULL, array('region' => 'sidebar_first', 'id' => 'main_navigation'), t('Save block'));
     // Verify admin user can see the block.
     $this->drupalGet('');
     $this->assertText('Main navigation');
     // Verify we have role = aria on system_powered_by and help_block
     // blocks.
     $this->drupalGet('admin/structure/block');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-help'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
     $this->drupalGet('');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-powered'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');
     // Verify anonymous user can see the block.
     $this->drupalLogout();
     $this->assertText('Main navigation');
     // Ensure comments don't show in the front page RSS feed.
     // Create an article.
     $this->drupalCreateNode(array('type' => 'article', 'title' => 'Foobar', 'promote' => 1, 'status' => 1, 'body' => array(array('value' => 'Then she picked out two somebodies,<br />Sally and me', 'format' => 'basic_html'))));
     // Add a comment.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/1');
     $this->assertRaw('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
     $this->drupalPostForm(NULL, array('subject[0][value]' => 'Barfoo', 'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me'), t('Save'));
     // Fetch the feed.
     $this->drupalGet('rss.xml');
     $this->assertText('Foobar');
     $this->assertNoText('Then she picked out two somebodies, Sally and me');
     // Ensure block body exists.
     $this->drupalGet('block/add');
     $this->assertFieldByName('body[0][value]');
     // Now we have all configuration imported, test all of them for schema
     // conformance. Ensures all imported default configuration is valid when
     // standard profile modules are enabled.
     $names = $this->container->get('config.storage')->listAll();
     /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
     $typed_config = $this->container->get('config.typed');
     foreach ($names as $name) {
         $config = $this->config($name);
         $this->assertConfigSchema($typed_config, $name, $config->get());
     }
     // Ensure that configuration from the Standard profile is not reused when
     // enabling a module again since it contains configuration that can not be
     // installed. For example, editor.editor.basic_html is editor configuration
     // that depends on the ckeditor module. The ckeditor module can not be
     // installed before the editor module since it depends on the editor module.
     // The installer does not have this limitation since it ensures that all of
     // the install profiles dependencies are installed before creating the
     // editor configuration.
     foreach (FilterFormat::loadMultiple() as $filter) {
         // Ensure that editor can be uninstalled by removing use in filter
         // formats. It is necessary to prime the filter collection before removing
         // the filter.
         $filter->filters();
         $filter->removeFilter('editor_file_reference');
         $filter->save();
     }
     \Drupal::service('module_installer')->uninstall(array('editor', 'ckeditor'));
     $this->rebuildContainer();
     \Drupal::service('module_installer')->install(array('editor'));
     /** @var \Drupal\contact\ContactFormInterface $contact_form */
     $contact_form = ContactForm::load('feedback');
     $recipients = $contact_form->getRecipients();
     $this->assertEqual(['simpletest@example.com'], $recipients);
     $role = Role::create(['id' => 'admin_theme', 'label' => 'Admin theme']);
     $role->grantPermission('view the administration theme');
     $role->save();
     $this->adminUser->addRole($role->id());
     $this->adminUser->save();
     $this->drupalGet('node/add');
     $this->assertResponse(200);
     // Ensure that there are no pending updates after installation.
     $this->drupalLogin($this->rootUser);
     $this->drupalGet('update.php/selection');
     $this->assertText('No pending updates.');
     // Ensure that there are no pending entity updates after installation.
     $this->assertFalse($this->container->get('entity.definition_update_manager')->needsUpdates(), 'After installation, entity schema is up to date.');
     // Make sure the optional image styles are not installed.
     $this->drupalGet('admin/config/media/image-styles');
     $this->assertNoText('Max 325x325');
     $this->assertNoText('Max 650x650');
     $this->assertNoText('Max 1300x1300');
     $this->assertNoText('Max 2600x2600');
     // Make sure the optional image styles are installed after enabling
     // the responsive_image module.
     \Drupal::service('module_installer')->install(array('responsive_image'));
     $this->rebuildContainer();
//.........这里部分代码省略.........
开发者ID:ddrozdik,项目名称:dmaps,代码行数:101,代码来源:StandardTest.php

示例2: testInstallUninstall

 /**
  * Tests that a fixed set of modules can be installed and uninstalled.
  */
 public function testInstallUninstall()
 {
     // Get a list of modules to enable.
     $all_modules = system_rebuild_module_data();
     $all_modules = array_filter($all_modules, function ($module) {
         // Filter contrib, hidden, already enabled modules and modules in the
         // Testing package.
         if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
             return FALSE;
         }
         return TRUE;
     });
     // Install every module possible.
     \Drupal::service('module_installer')->install(array_keys($all_modules));
     $this->assertModules(array_keys($all_modules), TRUE);
     foreach ($all_modules as $module => $info) {
         $this->assertModuleConfig($module);
         $this->assertModuleTablesExist($module);
     }
     // Export active config to sync.
     $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync'));
     system_list_reset();
     $this->resetAll();
     // Delete every field on the site so all modules can be uninstalled. For
     // example, if a comment field exists then module becomes required and can
     // not be uninstalled.
     $field_storages = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple();
     \Drupal::entityManager()->getStorage('field_storage_config')->delete($field_storages);
     // Purge the data.
     field_purge_batch(1000);
     // Delete all terms.
     $terms = Term::loadMultiple();
     entity_delete_multiple('taxonomy_term', array_keys($terms));
     // Delete all filter formats.
     $filters = FilterFormat::loadMultiple();
     entity_delete_multiple('filter_format', array_keys($filters));
     // Delete any shortcuts so the shortcut module can be uninstalled.
     $shortcuts = Shortcut::loadMultiple();
     entity_delete_multiple('shortcut', array_keys($shortcuts));
     system_list_reset();
     $all_modules = system_rebuild_module_data();
     // Ensure that only core required modules and the install profile can not be uninstalled.
     $validation_reasons = \Drupal::service('module_installer')->validateUninstall(array_keys($all_modules));
     $this->assertEqual(['standard', 'system', 'user'], array_keys($validation_reasons));
     $modules_to_uninstall = array_filter($all_modules, function ($module) use($validation_reasons) {
         // Filter required and not enabled modules.
         if (!empty($module->info['required']) || $module->status == FALSE) {
             return FALSE;
         }
         return TRUE;
     });
     // Can not uninstall config and use admin/config/development/configuration!
     unset($modules_to_uninstall['config']);
     $this->assertTrue(isset($modules_to_uninstall['comment']), 'The comment module will be disabled');
     $this->assertTrue(isset($modules_to_uninstall['file']), 'The File module will be disabled');
     $this->assertTrue(isset($modules_to_uninstall['editor']), 'The Editor module will be disabled');
     // Uninstall all modules that can be uninstalled.
     \Drupal::service('module_installer')->uninstall(array_keys($modules_to_uninstall));
     $this->assertModules(array_keys($modules_to_uninstall), FALSE);
     foreach ($modules_to_uninstall as $module => $info) {
         $this->assertNoModuleConfig($module);
         $this->assertModuleTablesDoNotExist($module);
     }
     // Import the configuration thereby re-installing all the modules.
     $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all'));
     // Modules have been installed that have services.
     $this->rebuildContainer();
     // Check that there are no errors.
     $this->assertIdentical($this->configImporter()->getErrors(), array());
     // Check that all modules that were uninstalled are now reinstalled.
     $this->assertModules(array_keys($modules_to_uninstall), TRUE);
     foreach ($modules_to_uninstall as $module => $info) {
         $this->assertModuleConfig($module);
         $this->assertModuleTablesExist($module);
     }
     // Ensure that we have no configuration changes to import.
     $storage_comparer = new StorageComparer($this->container->get('config.storage.sync'), $this->container->get('config.storage'), $this->container->get('config.manager'));
     $this->assertIdentical($storage_comparer->createChangelist()->getChangelist(), $storage_comparer->getEmptyChangelist());
     // Now we have all configuration imported, test all of them for schema
     // conformance. Ensures all imported default configuration is valid when
     // all modules are enabled.
     $names = $this->container->get('config.storage')->listAll();
     /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
     $typed_config = $this->container->get('config.typed');
     foreach ($names as $name) {
         $config = $this->config($name);
         $this->assertConfigSchema($typed_config, $name, $config->get());
     }
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:92,代码来源:ConfigImportAllTest.php

示例3: testStandard

 /**
  * Tests Standard installation profile.
  */
 function testStandard()
 {
     $this->drupalGet('');
     $this->assertLink(t('Contact'));
     $this->clickLink(t('Contact'));
     $this->assertResponse(200);
     // Test anonymous user can access 'Main navigation' block.
     $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'post comments', 'skip comment approval', 'create article content', 'create page content'));
     $this->drupalLogin($this->adminUser);
     // Configure the block.
     $this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
     $this->drupalPostForm(NULL, array('region' => 'sidebar_first', 'id' => 'main_navigation'), t('Save block'));
     // Verify admin user can see the block.
     $this->drupalGet('');
     $this->assertText('Main navigation');
     // Verify we have role = aria on system_powered_by and help_block
     // blocks.
     $this->drupalGet('admin/structure/block');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-help'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
     $this->drupalGet('');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-powered'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');
     // Verify anonymous user can see the block.
     $this->drupalLogout();
     $this->assertText('Main navigation');
     // Ensure comments don't show in the front page RSS feed.
     // Create an article.
     $this->drupalCreateNode(array('type' => 'article', 'title' => 'Foobar', 'promote' => 1, 'status' => 1, 'body' => array(array('value' => 'Then she picked out two somebodies,<br />Sally and me', 'format' => 'basic_html'))));
     // Add a comment.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/1');
     $this->assertRaw('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
     $this->drupalPostForm(NULL, array('subject[0][value]' => 'Barfoo', 'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me'), t('Save'));
     // Fetch the feed.
     $this->drupalGet('rss.xml');
     $this->assertText('Foobar');
     $this->assertNoText('Then she picked out two somebodies, Sally and me');
     // Ensure block body exists.
     $this->drupalGet('block/add');
     $this->assertFieldByName('body[0][value]');
     // Now we have all configuration imported, test all of them for schema
     // conformance. Ensures all imported default configuration is valid when
     // standard profile modules are enabled.
     $names = $this->container->get('config.storage')->listAll();
     /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
     $typed_config = $this->container->get('config.typed');
     foreach ($names as $name) {
         $config = $this->config($name);
         $this->assertConfigSchema($typed_config, $name, $config->get());
     }
     // Ensure that configuration from the Standard profile is not reused when
     // enabling a module again since it contains configuration that can not be
     // installed. For example, editor.editor.basic_html is editor configuration
     // that depends on the ckeditor module. The ckeditor module can not be
     // installed before the editor module since it depends on the editor module.
     // The installer does not have this limitation since it ensures that all of
     // the install profiles dependencies are installed before creating the
     // editor configuration.
     foreach (FilterFormat::loadMultiple() as $filter) {
         // Ensure that editor can be uninstalled by removing use in filter
         // formats. It is necessary to prime the filter collection before removing
         // the filter.
         $filter->filters();
         $filter->removeFilter('editor_file_reference');
         $filter->save();
     }
     \Drupal::service('module_installer')->uninstall(array('editor', 'ckeditor'));
     $this->rebuildContainer();
     \Drupal::service('module_installer')->install(array('editor'));
     /** @var \Drupal\contact\ContactFormInterface $contact_form */
     $contact_form = ContactForm::load('feedback');
     $recipients = $contact_form->getRecipients();
     $this->assertEqual(['simpletest@example.com'], $recipients);
     $role = Role::create(['id' => 'admin_theme', 'label' => 'Admin theme']);
     $role->grantPermission('view the administration theme');
     $role->save();
     $this->adminUser->addRole($role->id());
     $this->adminUser->save();
     $this->drupalGet('node/add');
     $this->assertResponse(200);
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:85,代码来源:StandardTest.php


注:本文中的Drupal\filter\Entity\FilterFormat::loadMultiple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。