Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -0,0 +1,25 @@
uuid: b299258f-6fb5-47f8-b42f-473787d02e22
langcode: en
status: true
dependencies:
module:
- system
theme:
- bartik
id: bartik_branding
theme: bartik
region: header
weight: 0
provider: null
plugin: system_branding_block
settings:
id: system_branding_block
label: 'Site branding'
provider: system
label_display: '0'
cache:
max_age: -1
use_site_logo: true
use_site_name: true
use_site_slogan: true
visibility: { }

View file

@ -0,0 +1,17 @@
langcode: en
status: true
dependencies:
theme:
- bartik
id: bartik_page_title
theme: bartik
region: content
weight: -50
provider: null
plugin: page_title_block
settings:
id: page_title_block
label: 'Page title'
provider: core
label_display: '0'
visibility: { }

View file

@ -0,0 +1,19 @@
langcode: en
status: true
dependencies:
theme:
- seven
id: seven_secondary_local_tasks
theme: seven
region: pre_content
weight: 0
provider: null
plugin: local_tasks_block
settings:
id: local_tasks_block
label: 'Secondary tabs'
provider: core
label_display: '0'
primary: false
secondary: true
visibility: { }

View file

@ -0,0 +1,150 @@
<?php
/**
* @file
* Partial database to mimic the uninstallation of the block_content module.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
$connection->schema()->dropTable('block_content');
$connection->schema()->dropTable('block_content__body');
$connection->schema()->dropTable('block_content_field_data');
$connection->schema()->dropTable('block_content_field_revision');
$connection->schema()->dropTable('block_content_revision');
$connection->schema()->dropTable('block_content_revision__body');
$connection->update('config')
->condition('collection', '')
->condition('name', 'core.extension')
->fields(['data' => 'a:2:{s:6:"module";a:39:{s:5:"block";i:0;s:10:"breakpoint";i:0;s:8:"ckeditor";i:0;s:5:"color";i:0;s:7:"comment";i:0;s:6:"config";i:0;s:7:"contact";i:0;s:10:"contextual";i:0;s:8:"datetime";i:0;s:5:"dblog";i:0;s:6:"editor";i:0;s:16:"entity_reference";i:0;s:5:"field";i:0;s:8:"field_ui";i:0;s:4:"file";i:0;s:6:"filter";i:0;s:4:"help";i:0;s:7:"history";i:0;s:5:"image";i:0;s:4:"link";i:0;s:7:"menu_ui";i:0;s:4:"node";i:0;s:7:"options";i:0;s:10:"page_cache";i:0;s:4:"path";i:0;s:9:"quickedit";i:0;s:3:"rdf";i:0;s:6:"search";i:0;s:8:"shortcut";i:0;s:6:"system";i:0;s:8:"taxonomy";i:0;s:4:"text";i:0;s:7:"toolbar";i:0;s:4:"tour";i:0;s:4:"user";i:0;s:8:"views_ui";i:0;s:17:"menu_link_content";i:1;s:5:"views";i:10;s:8:"standard";i:1000;}s:5:"theme";a:3:{s:6:"classy";i:0;s:6:"bartik";i:0;s:5:"seven";i:0;}}'])
->execute();
$connection->delete('config')
->condition('name', 'block_content.type.basic')
->execute();
$connection->delete('config')
->condition('name', 'core.entity_form_display.block_content.basic.default')
->execute();
$connection->delete('config')
->condition('name', 'core.entity_view_display.block_content.basic.default')
->execute();
$connection->delete('config')
->condition('name', 'core.entity_view_mode.block_content.full')
->execute();
$connection->delete('config')
->condition('name', 'field.field.block_content.basic.body')
->execute();
$connection->delete('config')
->condition('name', 'field.storage.block_content.body')
->execute();
$connection->delete('config')
->condition('name', 'views.view.block_content')
->execute();
$connection->delete('key_value')
->condition('collection', 'config.entity.key_store.block_content_type')
->execute();
$connection->delete('key_value')
->condition('collection', 'config.entity.key_store.entity_form_display')
->condition('value', '%.block_content.%', 'LIKE')
->execute();
$connection->delete('key_value')
->condition('collection', 'config.entity.key_store.entity_view_display')
->condition('value', '%.block_content.%', 'LIKE')
->execute();
$connection->delete('key_value')
->condition('collection', 'config.entity.key_store.entity_view_mode')
->condition('value', '%.block_content.%', 'LIKE')
->execute();
$connection->delete('key_value')
->condition('collection', 'config.entity.key_store.field_config')
->condition('value', '%.block_content.%', 'LIKE')
->execute();
$connection->delete('key_value')
->condition('collection', 'config.entity.key_store.field_storage_config')
->condition('value', '%.block_content.%', 'LIKE')
->execute();
$connection->delete('key_value')
->condition('collection', 'config.entity.key_store.view')
->condition('value', '%.block_content"%', 'LIKE')
->execute();
$connection->update('key_value')
->condition('collection', 'entity.definitions.bundle_field_map')
->condition('name', 'block_content')
->fields(['value' => 'a:0:{}'])
->execute();
$connection->delete('key_value')
->condition('collection', 'entity.definitions.installed')
->condition('name', 'block_content.entity_type')
->execute();
$connection->delete('key_value')
->condition('collection', 'entity.definitions.installed')
->condition('name', 'block_content.field_storage_definitions')
->execute();
$connection->delete('key_value')
->condition('collection', 'entity.definitions.installed')
->condition('name', 'block_content_type.entity_type')
->execute();
$connection->delete('key_value')
->condition('collection', 'entity.storage_schema.sql')
->condition('name', 'block_content.entity_schema_data')
->execute();
$connection->delete('key_value')
->condition('collection', 'entity.storage_schema.sql')
->condition('name', 'block_content.field_schema_data.%', 'LIKE')
->execute();
$connection->update('key_value')
->condition('collection', 'state')
->condition('name', 'router.path_roots')
->fields(['value' => 'a:27:{i:0;s:5:"admin";i:1;s:14:"block-category";i:2;s:7:"comment";i:3;s:8:"comments";i:4;s:7:"contact";i:5;s:4:"user";i:6;s:10:"contextual";i:7;s:6:"editor";i:8;s:4:"file";i:9;s:6:"filter";i:10;s:7:"history";i:11;s:5:"sites";i:12;s:6:"system";i:13;s:4:"node";i:14;s:9:"quickedit";i:15;s:6:"search";i:16;s:4:"cron";i:17;s:12:"machine_name";i:18;s:0:"";i:19;s:9:"<current>";i:20;s:5:"batch";i:21;s:10:"update.php";i:22;s:29:"entity_reference_autocomplete";i:23;s:8:"taxonomy";i:24;s:7:"toolbar";i:25;s:7:"rss.xml";i:26;s:5:"views";}'])
->execute();
$connection->update('key_value')
->condition('collection', 'state')
->condition('name', 'routing.non_admin_routes')
->fields(['value' => 'a:79:{i:0;s:27:"block.category_autocomplete";i:1;s:24:"entity.comment.edit_form";i:2;s:15:"comment.approve";i:3;s:24:"entity.comment.canonical";i:4;s:26:"entity.comment.delete_form";i:5;s:13:"comment.reply";i:6;s:31:"comment.new_comments_node_links";i:7;s:21:"comment.node_redirect";i:8;s:17:"contact.site_page";i:9;s:22:"contact.site_page_form";i:10;s:24:"entity.user.contact_form";i:11;s:17:"contextual.render";i:12;s:17:"editor.filter_xss";i:13;s:31:"editor.field_untransformed_text";i:14;s:19:"editor.image_dialog";i:15;s:18:"editor.link_dialog";i:16;s:18:"file.ajax_progress";i:17;s:15:"filter.tips_all";i:18;s:11:"filter.tips";i:19;s:26:"history.get_last_node_view";i:20;s:17:"history.read_node";i:21;s:18:"image.style_public";i:22;s:19:"image.style_private";i:23;s:13:"node.add_page";i:24;s:8:"node.add";i:25;s:19:"entity.node.preview";i:26;s:27:"entity.node.version_history";i:27;s:20:"entity.node.revision";i:28;s:28:"node.revision_revert_confirm";i:29;s:28:"node.revision_delete_confirm";i:30;s:18:"quickedit.metadata";i:31;s:21:"quickedit.attachments";i:32;s:20:"quickedit.field_form";i:33;s:21:"quickedit.entity_save";i:34;s:11:"search.view";i:35;s:23:"search.view_node_search";i:36;s:23:"search.help_node_search";i:37;s:23:"search.view_user_search";i:38;s:23:"search.help_user_search";i:39;s:19:"shortcut.set_switch";i:40;s:11:"system.ajax";i:41;s:10:"system.401";i:42;s:10:"system.403";i:43;s:10:"system.404";i:44;s:11:"system.cron";i:45;s:33:"system.machine_name_transliterate";i:46;s:12:"system.files";i:47;s:28:"system.private_file_download";i:48;s:16:"system.temporary";i:49;s:7:"<front>";i:50;s:6:"<none>";i:51;s:9:"<current>";i:52;s:15:"system.timezone";i:53;s:22:"system.batch_page.html";i:54;s:22:"system.batch_page.json";i:55;s:16:"system.db_update";i:56;s:26:"system.entity_autocomplete";i:57;s:30:"entity.taxonomy_term.edit_form";i:58;s:32:"entity.taxonomy_term.delete_form";i:59;s:16:"toolbar.subtrees";i:60;s:13:"user.register";i:61;s:11:"user.logout";i:62;s:9:"user.pass";i:63;s:9:"user.page";i:64;s:10:"user.login";i:65;s:19:"user.cancel_confirm";i:66;s:10:"user.reset";i:67;s:21:"view.frontpage.feed_1";i:68;s:21:"view.frontpage.page_1";i:69;s:25:"view.taxonomy_term.feed_1";i:70;s:25:"view.taxonomy_term.page_1";i:71;s:10:"views.ajax";i:72;s:21:"entity.node.canonical";i:73;s:23:"entity.node.delete_form";i:74;s:21:"entity.node.edit_form";i:75;s:21:"entity.user.canonical";i:76;s:21:"entity.user.edit_form";i:77;s:23:"entity.user.cancel_form";i:78;s:30:"entity.taxonomy_term.canonical";}'])
->execute();
$connection->update('key_value')
->condition('collection', 'state')
->condition('name', 'views.view_route_names')
->fields(['value' => 'a:8:{s:24:"user_admin_people.page_1";s:22:"entity.user.collection";s:20:"taxonomy_term.page_1";s:30:"entity.taxonomy_term.canonical";s:14:"content.page_1";s:20:"system.admin_content";s:12:"files.page_1";s:17:"view.files.page_1";s:12:"files.page_2";s:17:"view.files.page_2";s:16:"frontpage.feed_1";s:21:"view.frontpage.feed_1";s:16:"frontpage.page_1";s:21:"view.frontpage.page_1";s:20:"taxonomy_term.feed_1";s:25:"view.taxonomy_term.feed_1";}'])
->execute();
$connection->delete('key_value')
->condition('collection', 'system.schema')
->condition('name', 'block_content')
->execute();
$connection->delete('router')
->condition('name', 'block_content.%', 'LIKE')
->execute();
$connection->delete('router')
->condition('name', 'entity.block_content.%', 'LIKE')
->execute();
$connection->delete('router')
->condition('name', 'entity.entity_form_display.block_content.%', 'LIKE')
->execute();
$connection->delete('router')
->condition('name', 'entity.entity_view_display.block_content.%', 'LIKE')
->execute();
$connection->delete('router')
->condition('name', 'entity.field_config.block_content_%', 'LIKE')
->execute();
$connection->delete('router')
->condition('name', 'field_ui.field_storage_config_add_block_content')
->execute();
$connection->delete('router')
->condition('name', 'view.block_content.page_1')
->execute();
$connection->delete('router')
->condition('name', 'entity.block_content_type.collection')
->execute();
$connection->delete('router')
->condition('name', 'entity.block_content_type.%', 'LIKE')
->execute();

View file

@ -0,0 +1,39 @@
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of editor_update_8001().
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Simulate an un-synchronized environment.
// Disable the 'basic_html' editor.
$data = $connection->select('config')
->fields('config', ['data'])
->condition('name', 'editor.editor.basic_html')
->execute()
->fetchField();
$data = unserialize($data);
$data['status'] = FALSE;
$connection->update('config')
->fields(['data' => serialize($data)])
->condition('name', 'editor.editor.basic_html')
->execute();
// Disable the 'full_html' text format.
$data = $connection->select('config')
->fields('config', ['data'])
->condition('name', 'filter.format.full_html')
->execute()
->fetchField();
$data = unserialize($data);
$data['status'] = FALSE;
$connection->update('config')
->fields(['data' => serialize($data)])
->condition('name', 'filter.format.full_html')
->execute();

View file

@ -0,0 +1,74 @@
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of https://www.drupal.org/node/2573667.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
$connection->insert('key_value')
->fields(array(
'collection',
'name',
'value',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.body',
'value' => 'a:2:{s:19:"block_content__body";a:4:{s:11:"description";s:42:"Data storage for block_content field body.";s:6:"fields";a:9:{s:6:"bundle";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:88:"The field instance bundle to which this row belongs, used when deleting a field instance";}s:7:"deleted";a:5:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;s:7:"default";i:0;s:11:"description";s:60:"A boolean indicating whether this data item has been deleted";}s:9:"entity_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:38:"The entity id this data is attached to";}s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:47:"The entity revision id this data is attached to";}s:8:"langcode";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:37:"The language code for this data item.";}s:5:"delta";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:67:"The sequence number for this data item, used for multi-value fields";}s:10:"body_value";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:1;}s:12:"body_summary";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}s:11:"body_format";a:3:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:255;s:8:"not null";b:0;}}s:11:"primary key";a:4:{i:0;s:9:"entity_id";i:1;s:7:"deleted";i:2;s:5:"delta";i:3;s:8:"langcode";}s:7:"indexes";a:3:{s:6:"bundle";a:1:{i:0;s:6:"bundle";}s:11:"revision_id";a:1:{i:0;s:11:"revision_id";}s:11:"body_format";a:1:{i:0;s:11:"body_format";}}}s:28:"block_content_revision__body";a:4:{s:11:"description";s:54:"Revision archive storage for block_content field body.";s:6:"fields";a:9:{s:6:"bundle";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:88:"The field instance bundle to which this row belongs, used when deleting a field instance";}s:7:"deleted";a:5:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;s:7:"default";i:0;s:11:"description";s:60:"A boolean indicating whether this data item has been deleted";}s:9:"entity_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:38:"The entity id this data is attached to";}s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:47:"The entity revision id this data is attached to";}s:8:"langcode";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:37:"The language code for this data item.";}s:5:"delta";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:67:"The sequence number for this data item, used for multi-value fields";}s:10:"body_value";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:1;}s:12:"body_summary";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}s:11:"body_format";a:3:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:255;s:8:"not null";b:0;}}s:11:"primary key";a:5:{i:0;s:9:"entity_id";i:1;s:11:"revision_id";i:2;s:7:"deleted";i:3;s:5:"delta";i:4;s:8:"langcode";}s:7:"indexes";a:3:{s:6:"bundle";a:1:{i:0;s:6:"bundle";}s:11:"revision_id";a:1:{i:0;s:11:"revision_id";}s:11:"body_format";a:1:{i:0;s:11:"body_format";}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.changed',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:7:"changed";a:2:{s:4:"type";s:3:"int";s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:7:"changed";a:2:{s:4:"type";s:3:"int";s:8:"not null";b:0;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.default_langcode',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:16:"default_langcode";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:16:"default_langcode";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.id',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.info',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:4:"info";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:255;s:6:"binary";b:0;s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:4:"info";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:255;s:6:"binary";b:0;s:8:"not null";b:0;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.langcode',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_id',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:0;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_log',
'value' => 'a:1:{s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:12:"revision_log";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_translation_affected',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:29:"revision_translation_affected";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:29:"revision_translation_affected";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:0;}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.type',
'value' => 'a:2:{s:13:"block_content";a:2:{s:6:"fields";a:1:{s:4:"type";a:4:{s:11:"description";s:28:"The ID of the target entity.";s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;}}s:7:"indexes";a:1:{s:36:"block_content_field__type__target_id";a:1:{i:0;s:4:"type";}}}s:24:"block_content_field_data";a:2:{s:6:"fields";a:1:{s:4:"type";a:4:{s:11:"description";s:28:"The ID of the target entity.";s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;}}s:7:"indexes";a:1:{s:36:"block_content_field__type__target_id";a:1:{i:0;s:4:"type";}}}}',
))
->values(array(
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.uuid',
'value' => 'a:1:{s:13:"block_content";a:2:{s:6:"fields";a:1:{s:4:"uuid";a:4:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:6:"binary";b:0;s:8:"not null";b:1;}}s:11:"unique keys";a:1:{s:32:"block_content_field__uuid__value";a:1:{i:0;s:4:"uuid";}}}}',
))
->execute();

View file

@ -0,0 +1,60 @@
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of https://www.drupal.org/node/2476947.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2476947.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')
->fields([
'collection',
'name',
'data',
])
->values([
'collection' => '',
'name' => 'block.block.' . $block_config['id'],
'data' => serialize($block_config),
])
->execute();
}
// Update the config entity query "index".
$existing_blocks = $connection->select('key_value')
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:bartik')
->execute()
->fetchField();
$existing_blocks = unserialize($existing_blocks);
$connection->update('key_value')
->fields([
'value' => serialize(array_merge($existing_blocks, ['block.block.bartik_page_title']))
])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:bartik')
->execute();
// Enable test theme.
$extensions = $connection->select('config')
->fields('config', ['data'])
->condition('name', 'core.extension')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$connection->update('config')
->fields([
'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]]))
])
->condition('name', 'core.extension')
->execute();

View file

@ -0,0 +1,46 @@
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of https://www.drupal.org/node/507488.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2569529.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')
->fields([
'collection',
'name',
'data',
])
->values([
'collection' => '',
'name' => 'block.block.' . $block_config['id'],
'data' => serialize($block_config),
])
->execute();
}
// Update the config entity query "index".
$existing_blocks = $connection->select('key_value')
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:seven')
->execute()
->fetchField();
$existing_blocks = unserialize($existing_blocks);
$connection->update('key_value')
->fields([
'value' => serialize(array_merge($existing_blocks, ['block.block.seven_secondary_local_tasks']))
])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:seven')
->execute();

View file

@ -0,0 +1,60 @@
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of https://www.drupal.org/node/2005546.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')
->fields([
'collection',
'name',
'data',
])
->values([
'collection' => '',
'name' => 'block.block.' . $block_config['id'],
'data' => serialize($block_config),
])
->execute();
}
// Update the config entity query "index".
$existing_blocks = $connection->select('key_value')
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:bartik')
->execute()
->fetchField();
$existing_blocks = unserialize($existing_blocks);
$connection->update('key_value')
->fields([
'value' => serialize(array_merge($existing_blocks, ['block.block.bartik_branding']))
])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:bartik')
->execute();
// Enable test theme.
$extensions = $connection->select('config')
->fields('config', ['data'])
->condition('name', 'core.extension')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$connection->update('config')
->fields([
'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]]))
])
->condition('name', 'core.extension')
->execute();

View file

@ -0,0 +1,25 @@
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of https://www.drupal.org/node/2575421.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Enable test_stable theme.
$extensions = $connection->select('config')
->fields('config', ['data'])
->condition('name', 'core.extension')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$connection->update('config')
->fields([
'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_stable' => 0]]))
])
->condition('name', 'core.extension')
->execute();

View file

@ -0,0 +1,40 @@
<?php
/**
* @file
* Partial database to mimic the installation of the update_test_post_update
* module.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Set the schema version.
$connection->merge('key_value')
->condition('collection', 'system.schema')
->condition('name', 'update_test_postupdate')
->fields([
'collection' => 'system.schema',
'name' => 'update_test_postupdate',
'value' => 'i:8000;',
])
->execute();
// Update core.extension.
$extensions = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'core.extension')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$extensions['module']['update_test_postupdate'] = 8000;
$connection->update('config')
->fields([
'data' => serialize($extensions),
])
->condition('collection', '')
->condition('name', 'core.extension')
->execute();

View file

@ -0,0 +1,39 @@
<?php
/**
* @file
* Partial database to mimic the installation of the update_test_failing module.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Set the schema version.
$connection->merge('key_value')
->condition('collection', 'system.schema')
->condition('name', 'update_test_failing')
->fields([
'collection' => 'system.schema',
'name' => 'update_test_failing',
'value' => 'i:8000;',
])
->execute();
// Update core.extension.
$extensions = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'core.extension')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$extensions['module']['update_test_failing'] = 8000;
$connection->update('config')
->fields([
'data' => serialize($extensions),
])
->condition('collection', '')
->condition('name', 'core.extension')
->execute();

View file

@ -0,0 +1,14 @@
<?php
$connection = Drupal\Core\Database\Database::getConnection();
$config = $connection;
$connection->merge('config')
->condition('name', 'system.cron')
->condition('collection', '')
->fields([
'name' => 'system.cron',
'collection' => '',
'data' => serialize(['threshold' => ['autorun' => 0]]),
])
->execute();

View file

@ -1,3 +1,5 @@
name: Accept header based routing test
core: 8.x
type: module
package: Testing
version: VERSION

View file

@ -40,6 +40,11 @@ class BatchTestMultiStepForm extends FormBase {
'#value' => 'Submit',
);
// This is a POST form with multiple steps that does not transition from one
// step to the next via POST requests, but via GET requests, because it uses
// Batch API to advance through the steps.
$form['#cache']['max-age'] = 0;
return $form;
}

View file

@ -22,7 +22,7 @@ class CacheTestController {
public function urlBubbling() {
$url = Url::fromRoute('<current>')->setAbsolute();
return [
'#markup' => SafeMarkup::format('This URL is early-rendered: !url. Yet, its bubbleable metadata should be bubbled.', ['!url' => $url->toString()])
'#markup' => 'This URL is early-rendered: ' . $url->toString() . '. Yet, its bubbleable metadata should be bubbled.',
];
}

View file

@ -19,7 +19,8 @@ class CommonTestController {
/**
* Returns links to the current page, with and without query strings.
*
* Using #type 'link' causes these links to be rendered with _l().
* Using #type 'link' causes these links to be rendered with the link
* generator.
*/
public function typeLinkActiveClass() {
return array(

View file

@ -72,7 +72,7 @@ class ConditionTestDualUserTest extends KernelTestBase {
'user2' => 'anonymous',
]);
$definition = new ContextDefinition('entity:user');
$contexts['anonymous'] = (new Context($definition))->setContextValue($this->anonymous);
$contexts['anonymous'] = new Context($definition, $this->anonymous);
\Drupal::service('context.handler')->applyContextMapping($condition, $contexts);
$this->assertTrue($condition->execute());
}
@ -89,8 +89,8 @@ class ConditionTestDualUserTest extends KernelTestBase {
'user2' => 'authenticated',
]);
$definition = new ContextDefinition('entity:user');
$contexts['anonymous'] = (new Context($definition))->setContextValue($this->anonymous);
$contexts['authenticated'] = (new Context($definition))->setContextValue($this->authenticated);
$contexts['anonymous'] = new Context($definition, $this->anonymous);
$contexts['authenticated'] = new Context($definition, $this->authenticated);
\Drupal::service('context.handler')->applyContextMapping($condition, $contexts);
$this->assertFalse($condition->execute());
}

View file

@ -10,6 +10,7 @@ namespace Drupal\condition_test\Tests;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\KernelTestBase;
/**
@ -58,6 +59,7 @@ class OptionalContextConditionTest extends KernelTestBase {
* Tests with both contexts mapped to the same user.
*/
protected function testContextAvailable() {
NodeType::create(['type' => 'example', 'name' => 'Example'])->save();
/** @var \Drupal\Core\Condition\ConditionPluginBase $condition */
$condition = \Drupal::service('plugin.manager.condition')
->createInstance('condition_test_optional_context')
@ -66,7 +68,7 @@ class OptionalContextConditionTest extends KernelTestBase {
]);
$definition = new ContextDefinition('entity:node');
$node = Node::create(['type' => 'example']);
$contexts['node'] = (new Context($definition))->setContextValue($node);
$contexts['node'] = new Context($definition, $node);
\Drupal::service('context.handler')->applyContextMapping($condition, $contexts);
$this->assertFalse($condition->execute());
}

View file

@ -290,5 +290,7 @@ function database_test_schema() {
'primary key' => array('id'),
);
$schema['TEST_UPPERCASE'] = $schema['test'];
return $schema;
}

View file

@ -7,6 +7,8 @@
namespace Drupal\display_variant_test\EventSubscriber;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Render\PageDisplayVariantSelectionEvent;
use Drupal\Core\Render\RenderEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@ -25,6 +27,10 @@ class TestPageDisplayVariantSubscriber implements EventSubscriberInterface {
public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $event) {
$event->setPluginId('display_variant_test');
$event->setPluginConfiguration(['required_configuration' => 'A very important, required value.']);
$event->addCacheTags(['custom_cache_tag']);
$context = new Context(new ContextDefinition('string', NULL, TRUE), 'Explicitly passed in context.');
$event->setContexts(['context' => $context]);
}
/**

View file

@ -7,8 +7,10 @@
namespace Drupal\display_variant_test\Plugin\DisplayVariant;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Display\VariantBase;
use Drupal\Core\Display\PageVariantInterface;
use Drupal\Core\Display\ContextAwareVariantInterface;
/**
* Provides a display variant that requires configuration.
@ -18,7 +20,7 @@ use Drupal\Core\Display\PageVariantInterface;
* admin_label = @Translation("Test display variant")
* )
*/
class TestDisplayVariant extends VariantBase implements PageVariantInterface {
class TestDisplayVariant extends VariantBase implements PageVariantInterface, ContextAwareVariantInterface {
/**
* The render array representing the main page content.
@ -27,6 +29,45 @@ class TestDisplayVariant extends VariantBase implements PageVariantInterface {
*/
protected $mainContent = [];
/**
* The page title: a string (plain title) or a render array (formatted title).
*
* @var string|array
*/
protected $title = '';
/**
* An array of collected contexts.
*
* This is only used on runtime, and is not stored.
*
* @var \Drupal\Component\Plugin\Context\ContextInterface[]
*/
protected $contexts = [];
/**
* Gets the contexts.
*
* @return \Drupal\Component\Plugin\Context\ContextInterface[]
* An array of set contexts, keyed by context name.
*/
public function getContexts() {
return $this->contexts;
}
/**
* Sets the contexts.
*
* @param \Drupal\Component\Plugin\Context\ContextInterface[] $contexts
* An array of contexts, keyed by context name.
*
* @return $this
*/
public function setContexts(array $contexts) {
$this->contexts = $contexts;
return $this;
}
/**
* {@inheritdoc}
*/
@ -35,6 +76,14 @@ class TestDisplayVariant extends VariantBase implements PageVariantInterface {
return $this;
}
/**
* {@inheritdoc}
*/
public function setTitle($title) {
$this->title = $title;
return $this;
}
/**
* {@inheritdoc}
*/
@ -44,10 +93,18 @@ class TestDisplayVariant extends VariantBase implements PageVariantInterface {
throw new \Exception('Required configuration is missing!');
}
$contexts = $this->getContexts();
if (!isset($contexts['context'])) {
throw new \Exception('Required context is missing!');
}
$build = [];
$build['content']['default'] = [
'#markup' => $config['required_configuration'],
'#markup' => $config['required_configuration'] . ' ' . $contexts['context']->getContextValue(),
];
CacheableMetadata::createFromObject($this)->applyTo($build);
return $build;
}

View file

@ -0,0 +1,125 @@
langcode: en
status: true
dependencies:
module:
- entity_reference_test
- node
- user
id: test_entity_reference
label: 'Entity reference'
module: entity_reference_test
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: '8'
display:
default:
display_plugin: default
id: default
display_title: Master
position: null
display_options:
access:
type: perm
cache:
type: tag
query:
type: views_query
exposed_form:
type: basic
pager:
type: full
style:
type: default
row:
type: fields
fields:
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: false
ellipsis: false
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: field
entity_type: node
entity_field: title
filters:
status:
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
plugin_id: date
entity_type: node
entity_field: created
entity_reference_1:
display_plugin: entity_reference
id: entity_reference_1
display_title: EntityReference
position: null
display_options:
style:
type: entity_reference
options:
grouping: { }
search_fields:
title: title
pager:
type: none
options:
offset: 0

View file

@ -0,0 +1,120 @@
langcode: en
status: true
dependencies:
module:
- entity_reference_test
- entity_test
id: test_entity_reference_entity_test
label: 'Entity reference'
module: views
description: ''
tag: ''
base_table: entity_test
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
cache:
type: tag
query:
type: views_query
exposed_form:
type: basic
pager:
type: full
style:
type: default
row:
type: fields
fields:
name:
table: entity_test
field: name
id: name
entity_type: null
entity_field: name
plugin_id: field
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings: { }
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
filters: { }
sorts: { }
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
entity_reference_1:
display_plugin: entity_reference
id: entity_reference_1
display_title: EntityReference
position: null
display_options:
display_extenders: { }
style:
type: entity_reference
options:
search_fields:
name: name

View file

@ -0,0 +1,11 @@
name: "Entity Reference Test"
type: module
description: "Support module for the Entity Reference tests."
core: 8.x
package: Testing
version: VERSION
dependencies:
- node
- user
- views
- entity_test

View file

@ -0,0 +1,42 @@
<?php
/**
* @file
* Helper module for the Entity Reference tests.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Implements hook_entity_base_field_info().
*/
function entity_reference_test_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = array();
if ($entity_type->id() === 'entity_test') {
$fields['user_role'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('User role'))
->setDescription(t('The role of the associated user.'))
->setSetting('target_type', 'user_role')
->setSetting('handler', 'default');
}
return $fields;
}
/**
* Implements hook_entity_base_field_info_alter().
*/
function entity_reference_test_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'entity_test') {
// Allow user_id field to use configurable widget.
$fields['user_id']
->setSetting('handler', 'default')
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => 0,
))
->setDisplayConfigurable('form', TRUE);
}
}

View file

@ -0,0 +1,8 @@
name: 'Entity reference test views'
type: module
description: 'Provides default views for views entity reference tests.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- views

View file

@ -0,0 +1,120 @@
langcode: en
status: true
dependencies:
module:
- entity_test
id: test_entity_reference_entity_test_mul_view
label: test_entity_reference_entity_test_mul_view
module: views
description: ''
tag: ''
base_table: entity_test_mul_property_data
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' Previous'
next: 'Next '
first: '« First'
last: 'Last »'
quantity: 9
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
id:
id: id
table: entity_test_mul_property_data
field: id
entity_type: entity_test_mul
entity_field: id
plugin_id: field
id_1:
id: id_1
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: field
relationship: field_data_test
filters: { }
sorts:
id:
id: id
table: entity_test_mul_property_data
field: id
entity_type: entity_test_mul
entity_field: id
plugin_id: standard
header: { }
footer: { }
empty: { }
relationships:
field_data_test:
id: field_data_test
table: entity_test_mul__field_data_test
field: field_data_test
plugin_id: standard
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- languages
- 'languages:language_interface'
max-age: 0

View file

@ -0,0 +1,121 @@
langcode: en
status: true
dependencies:
module:
- entity_test
id: test_entity_reference_entity_test_view
label: test_entity_reference_entity_test_view
module: views
description: ''
tag: ''
base_table: entity_test
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' Previous'
next: 'Next '
first: '« First'
last: 'Last »'
quantity: 9
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
id:
id: id
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: field
id_1:
id: id_1
table: entity_test_mul
field: id
entity_type: entity_test_mul
entity_field: id
plugin_id: field
relationship: field_test_data
filters: { }
sorts:
id:
id: id
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: standard
header: { }
footer: { }
empty: { }
relationships:
field_test_data:
id: field_test_data
table: entity_test__field_test_data
field: field_test_data
plugin_id: standard
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- entity_test_view_grants
- languages
- 'languages:language_interface'
max-age: 0

View file

@ -0,0 +1,130 @@
langcode: en
status: true
dependencies:
module:
- entity_test
id: test_entity_reference_reverse_entity_test_mul_view
label: test_entity_reference_reverse_entity_test_mul_view
module: views
description: ''
tag: ''
base_table: entity_test
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' Previous'
next: 'Next '
first: '« First'
last: 'Last »'
quantity: 9
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
id:
id: id
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: field
id_1:
id: id_1
table: entity_test_mul_property_data
field: id
entity_type: entity_test_mul
entity_field: id
plugin_id: field
relationship: reverse__entity_test_mul__field_data_test
filters: { }
sorts:
id:
id: id
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: standard
id_1:
id: id_1
table: entity_test_mul_property_data
field: id
entity_type: entity_test_mul
entity_field: id
plugin_id: standard
relationship: reverse__entity_test_mul__field_data_test
header: { }
footer: { }
empty: { }
relationships:
reverse__entity_test_mul__field_data_test:
id: reverse__entity_test_mul__field_data_test
table: entity_test
field: reverse__entity_test_mul__field_data_test
entity_type: entity_test
plugin_id: entity_reverse
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- entity_test_view_grants
- languages
- 'languages:language_interface'
max-age: 0

View file

@ -0,0 +1,129 @@
langcode: en
status: true
dependencies:
module:
- entity_test
id: test_entity_reference_reverse_entity_test_view
label: test_entity_reference_reverse_entity_test_view
module: views
description: ''
tag: ''
base_table: entity_test_mul_property_data
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' Previous'
next: 'Next '
first: '« First'
last: 'Last »'
quantity: 9
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
id:
id: id
table: entity_test_mul_property_data
field: id
entity_type: entity_test_mul
entity_field: id
plugin_id: field
id_1:
id: id_1
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: field
relationship: reverse__entity_test__field_test_data
filters: { }
sorts:
id:
id: id
table: entity_test_mul_property_data
field: id
entity_type: entity_test_mul
entity_field: id
plugin_id: standard
id_1:
id: id_1
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: standard
relationship: reverse__entity_test__field_test_data
header: { }
footer: { }
empty: { }
relationships:
reverse__entity_test__field_test_data:
id: reverse__entity_test__field_test_data
table: entity_test_mul_property_data
field: reverse__entity_test__field_test_data
entity_type: entity_test_mul
plugin_id: entity_reverse
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- languages
- 'languages:language_interface'
max-age: 0

View file

@ -7,4 +7,3 @@ core: 8.x
dependencies:
- field
- text
- entity_reference

View file

@ -170,26 +170,6 @@ function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity
\Drupal::entityManager()->onBundleCreate($bundle, $entity_type);
}
/**
* Renames a bundle for entity_test entities.
*
* @param string $bundle_old
* The machine-readable name of the bundle to rename.
* @param string $bundle_new
* The new machine-readable name of the bundle.
* @param string $entity_type
* (optional) The entity type for which the bundle is renamed. Defaults to
* 'entity_test'.
*/
function entity_test_rename_bundle($bundle_old, $bundle_new, $entity_type = 'entity_test') {
$bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
$bundles[$bundle_new] = $bundles[$bundle_old];
unset($bundles[$bundle_old]);
\Drupal::state()->set($entity_type . '.bundles', $bundles);
\Drupal::entityManager()->onBundleRename($bundle_old, $bundle_new, $entity_type);
}
/**
* Deletes a bundle for entity_test entities.
*
@ -641,7 +621,11 @@ function entity_test_entity_prepare_view($entity_type, array $entities, array $d
/**
* Implements hook_entity_access().
*/
function entity_test_entity_access(EntityInterface $entity, $operation, AccountInterface $account, $langcode) {
function entity_test_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
// Only apply to the 'entity_test' entities.
if ($entity->getEntityType()->getProvider() != 'entity_test') {
return AccessResult::neutral();
}
\Drupal::state()->set('entity_test_entity_access', TRUE);
// Attempt to allow access to entities with the title forbid_access,
@ -660,7 +644,7 @@ function entity_test_entity_access(EntityInterface $entity, $operation, AccountI
/**
* Implements hook_ENTITY_TYPE_access() for 'entity_test'.
*/
function entity_test_entity_test_access(EntityInterface $entity, $operation, AccountInterface $account, $langcode) {
function entity_test_entity_test_access(EntityInterface $entity, $operation, AccountInterface $account) {
\Drupal::state()->set('entity_test_entity_test_access', TRUE);
// No opinion.

View file

@ -46,12 +46,4 @@ class EntityTestConstraints extends EntityTest implements EntityChangedInterface
return $fields;
}
/**
* {@inheritdoc}
*/
public function getChangedTime() {
return $this->get('changed')->value;
}
}

View file

@ -72,12 +72,4 @@ class EntityTestMulChanged extends EntityTestMul implements EntityChangedInterfa
sleep(1);
parent::save();
}
/**
* {@inheritdoc}
*/
public function getChangedTime() {
return $this->get('changed')->value;
}
}

View file

@ -23,4 +23,11 @@ namespace Drupal\entity_test\Entity;
*/
class EntityTestNoLabel extends EntityTest {
/**
* @{inheritdoc}
*/
public function label() {
return $this->getName();
}
}

View file

@ -29,7 +29,9 @@ class EntityTestAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\entity_test\Entity\EntityTest $entity */
// Always forbid access to entities with the label 'forbid_access', used for
// \Drupal\system\Tests\Entity\EntityAccessHControlandlerTest::testDefaultEntityAccess().
if ($entity->label() == 'forbid_access') {
@ -37,7 +39,7 @@ class EntityTestAccessControlHandler extends EntityAccessControlHandler {
}
if ($operation === 'view') {
if ($langcode != LanguageInterface::LANGCODE_DEFAULT) {
if (!$entity->isDefaultTranslation()) {
return AccessResult::allowedIfHasPermission($account, 'view test entity translations');
}
return AccessResult::allowedIfHasPermission($account, 'view test entity');

View file

@ -20,8 +20,8 @@ class EntityTestViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$build = parent::getBuildDefaults($entity, $view_mode, $langcode);
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
unset($build['#theme']);
return $build;
}
@ -29,8 +29,8 @@ class EntityTestViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
$build[$id]['label'] = array(

View file

@ -9,7 +9,7 @@ namespace Drupal\entity_test\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\StringTranslation\TranslationWrapper;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\TypedDataInterface;
@ -39,9 +39,9 @@ class FieldTestItem extends FieldItemBase {
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
// This is called very early by the user entity roles field. Prevent
// early t() calls by using the TranslationWrapper.
// early t() calls by using the TranslatableMarkup.
$properties['value'] = DataDefinition::create('string')
->setLabel(new TranslationWrapper('Test value'))
->setLabel(new TranslatableMarkup('Test value'))
->setRequired(TRUE);
return $properties;

View file

@ -100,6 +100,14 @@ form_test.validate_required_no_title:
requirements:
_access: 'TRUE'
form_test.validate_without_csrf_token:
path: '/form-test/validate-no-token'
defaults:
_form: '\Drupal\form_test\Form\FormTestValidateNoToken'
_title: 'Form validation on forms with a disabled CSRF token'
requirements:
_access: 'TRUE'
form_test.validate_with_error_suppresion:
path: '/form-test/limit-validation-errors'
defaults:
@ -394,6 +402,14 @@ form_test.button_class:
requirements:
_access: 'TRUE'
form_test.details_form:
path: '/form_test/details-form'
defaults:
_form: '\Drupal\form_test\Form\FormTestDetailsForm'
_title: 'Form details form test'
requirements:
_access: 'TRUE'
form_test.description_display:
path: '/form_test/form-descriptions'
defaults:
@ -457,3 +473,10 @@ form_test.form_storage_page_cache:
_title: 'Form storage with page cache test'
requirements:
_access: 'TRUE'
form_test.get_form:
path: '/form-test/get-form'
defaults:
_form: '\Drupal\form_test\Form\FormTestGetForm'
requirements:
_access: 'TRUE'

View file

@ -36,8 +36,8 @@ class FormTestCheckboxesRadiosForm extends FormBase {
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => 'Bar',
'>' => 'Special Char',
'bar' => $this->t('<em>Bar - checkboxes</em>'),
'>' => "<em>Special Char</em><script>alert('checkboxes');</script>",
),
);
if ($customize) {
@ -60,8 +60,8 @@ class FormTestCheckboxesRadiosForm extends FormBase {
0 => 'Zero',
'foo' => 'Foo',
1 => 'One',
'bar' => 'Bar',
'>' => 'Special Char',
'bar' => '<em>Bar - radios</em>',
'>' => "<em>Special Char</em><script>alert('radios');</script>",
),
);
if ($customize) {

View file

@ -0,0 +1,51 @@
<?php
/**
* @file
* Contains \Drupal\form_test\Form\FormTestGroupContainerForm.
*/
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Builds a simple form to test the #group property on #type 'container'.
*/
class FormTestDetailsForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'form_test_details_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['meta'] = [
'#type' => 'details',
'#title' => 'Details element',
'#open' => TRUE,
];
$form['submit'] = ['#type' => 'submit', '#value' => 'Submit'];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_state->setErrorByName('meta', 'I am an error on the details element.');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}

View file

@ -0,0 +1,44 @@
<?php
/**
* @file
* Contains \Drupal\form_test\Form\FormTestGetForm.
*/
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Form to test whether GET forms have a CSRF token.
*/
class FormTestGetForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'form_test_get_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#method'] = 'get';
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
drupal_set_message('The form_test_get_form form has been submitted successfully.');
}
}

View file

@ -29,7 +29,7 @@ class FormTestSelectForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$base = array(
'#type' => 'select',
'#options' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
'#options' => array('one' => 'one', 'two' => 'two', 'three' => 'three', 'four' => '<strong>four</strong>'),
);
$form['select'] = $base + array(

View file

@ -0,0 +1,52 @@
<?php
/**
* @file
* Contains \Drupal\form_test\Form\FormTestTableForm.
*/
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormStateInterface;
class FormTestTableForm extends FormTestTableSelectFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return '_form_test_table_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['table'] = [
'#type' => 'table',
'#tableselect' => TRUE,
'#empty' => $this->t('Empty text.'),
];
$form['table']['row'] = [
'data' => [
'#title' => '<em>kitten</em>',
'#markup' => '<p>some text</p>',
],
];
$form['table']['another_row'] = [
'data' => [
'#title' => $this->t('my favourite fruit is <strong>@fruit</strong>', ['@fruit' => 'bananas']),
'#markup' => '<p>some more text</p>',
],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}

View file

@ -0,0 +1,44 @@
<?php
/**
* @file
* Contains \Drupal\form_test\Form\FormTestValidateNoToken.
*/
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Form to test the validation of forms with a disabled CSRF token.
*/
class FormTestValidateNoToken extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'form_test_validate_no_token';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#token'] = FALSE;
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
drupal_set_message('The form_test_validate_no_token form has been submitted successfully.');
}
}

View file

@ -33,12 +33,12 @@ class FormTestVerticalTabsForm extends FormBase {
for ($i = 1; $i <= $tab_count; $i++) {
$form['tab' . $i] = array(
'#type' => 'fieldset',
'#title' => t('Tab !num', array('!num' => $i)),
'#title' => t('Tab @num', array('@num' => $i)),
'#group' => 'vertical_tabs',
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
);
$form['tab' . $i]['field' . $i] = array(
'#title' => t('Field !num', array('!num' => $i)),
'#title' => t('Field @num', array('@num' => $i)),
'#type' => 'textfield',
);

View file

@ -4,9 +4,3 @@ httpkernel_test.empty:
_controller: '\Drupal\httpkernel_test\Controller\TestController::get'
requirements:
_access: 'TRUE'
httpkernel_test.teapot:
path: '/httpkernel-test/teapot'
defaults:
_controller: '\Drupal\httpkernel_test\Controller\TestController::teapot'
requirements:
_access: 'TRUE'

View file

@ -21,21 +21,4 @@ class TestController {
return new Response();
}
/**
* Test special header and status code rendering.
*
* @return array
* A render array using features of the 'http_header' directive.
*/
public function teapot() {
$render = [];
$render['#attached']['http_header'][] = ['X-Test-Teapot-Replace', 'This value gets replaced'];
$render['#attached']['http_header'][] = ['X-Test-Teapot-Replace', 'Teapot replaced', TRUE];
$render['#attached']['http_header'][] = ['X-Test-Teapot-No-Replace', 'This value is not replaced'];
$render['#attached']['http_header'][] = ['X-Test-Teapot-No-Replace', 'This one is added', FALSE];
$render['#attached']['http_header'][] = ['X-Test-Teapot', 'Teapot Mode Active'];
$render['#attached']['http_header'][] = ['Status', "418 I'm a teapot."];
return $render;
}
}

View file

@ -138,7 +138,7 @@ class TestToolkit extends ImageToolkitBase {
*/
public function parseFile() {
$this->logCall('parseFile', func_get_args());
$data = @getimagesize($this->getImage()->getSource());
$data = @getimagesize($this->getSource());
if ($data && in_array($data[2], static::supportedTypes())) {
$this->setType($data[2]);
$this->width = $data[0];

View file

@ -0,0 +1,6 @@
name: 'Link generation test support'
type: module
description: 'Test hooks fired in link generation.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,21 @@
<?php
/**
* @file
* Helper module for the link generation tests.
*/
/**
* Implements hook_link_alter().
*/
function link_generation_test_link_alter(&$variables) {
if (\Drupal::state()->get('link_generation_test_link_alter', FALSE)) {
// Add a text to the end of links.
if (\Drupal::state()->get('link_generation_test_link_alter_safe', FALSE)) {
$variables['text'] = t('@text <strong>Test!</strong>', ['@text' => $variables['text']]);
}
else {
$variables['text'] .= ' <strong>Test!</strong>';
}
}
}

View file

@ -83,3 +83,8 @@ menu_test.child:
menu_test.unsafe:
route_name: menu_test.menu_name_test
deriver: '\Drupal\menu_test\Plugin\Derivative\MenuLinkTestWithUnsafeTitle'
menu_test.access_check:
title: 'Test custom route access check'
route_name: menu_test.router_test_session
menu_name: account

View file

@ -5,6 +5,7 @@
* Module that implements various hooks for menu tests.
*/
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Url;
/**
@ -29,7 +30,7 @@ function menu_test_menu_links_discovered_alter(&$links) {
/**
* Implements hook_menu_local_tasks_alter().
*/
function menu_test_menu_local_tasks_alter(&$data, $route_name) {
function menu_test_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) {
if (in_array($route_name, array('menu_test.tasks_default'))) {
$data['tabs'][0]['foo'] = array(
'#theme' => 'menu_local_task',
@ -48,32 +49,7 @@ function menu_test_menu_local_tasks_alter(&$data, $route_name) {
'#weight' => 20,
);
}
}
/**
* Page callback: Tests the theme negotiation functionality.
*
* @param bool $inherited
* (optional) TRUE when the requested page is intended to inherit
* the theme of its parent.
*
* @return string
* A string describing the requested custom theme and actual theme being used
* for the current page request.
*
* @see menu_test_menu().
*
* @deprecated Use \Drupal\menu_test\Controller\MenuTestController::themePage()
*/
function menu_test_theme_page_callback($inherited = FALSE) {
$theme_key = \Drupal::theme()->getActiveTheme()->getName();
// Now we check what the theme negotiator service returns.
$active_theme = \Drupal::service('theme.negotiator')->determineActiveTheme(\Drupal::routeMatch());
$output = "Active theme: $active_theme. Actual theme: $theme_key.";
if ($inherited) {
$output .= ' Theme negotiation inheritance is being tested.';
}
return ['#markup' => $output];
$cacheability->addCacheTags(['kittens:dwarf-cat']);
}
/**

View file

@ -74,6 +74,15 @@ menu_test.router_test4:
requirements:
_access: 'TRUE'
menu_test.router_test_session:
path: '/menu_test_access_check_session'
defaults:
_controller: '\Drupal\menu_test\TestControllers::testSession'
options:
no_cache: TRUE
requirements:
_menu_test_session_access: 'TRUE'
menu_test.local_action1:
path: '/menu-test-local-action'
defaults:

View file

@ -3,3 +3,8 @@ services:
class: Drupal\menu_test\Theme\TestThemeNegotiator
tags:
- { name: theme_negotiator }
access_check.menu_test_session:
class: Drupal\menu_test\Access\AccessCheck
tags:
- { name: access_check, applies_to: _menu_test_session_access }

View file

@ -0,0 +1,33 @@
<?php
/**
* @file
* Contains \Drupal\menu_test\Access\AccessCheck.
*/
namespace Drupal\menu_test\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
/**
* Checks access based on the 'menu_test' key in session.
*/
class AccessCheck implements AccessInterface {
/**
* Check to see if user accessed this page.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access() {
if (!isset($_SESSION['menu_test'])) {
$result = AccessResult::allowed();
}
else {
$result = AccessResult::allowedIf($_SESSION['menu_test'] < 2);
}
return $result->setCacheMaxAge(0);
}
}

View file

@ -7,10 +7,64 @@
namespace Drupal\menu_test\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeManagerInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Controller routines for menu_test routes.
*/
class MenuTestController {
class MenuTestController extends ControllerBase {
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
/**
* The theme negotiator.
*
* @var \Drupal\Core\Theme\ThemeNegotiatorInterface
*/
protected $themeNegotiator;
/**
* The active route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Constructs the MenuTestController object.
*
* @param \Drupal\menu_test\Controller\ThemeManagerInterface $theme_manager
* The theme manager.
* @param \Drupal\menu_test\Controller\ThemeNegotiatorInterface $theme_negotiator
* The theme negotiator.
* @param \Drupal\menu_test\Controller\RouteMatchInterface $route_match
* The current route match.
*/
public function __construct(ThemeManagerInterface $theme_manager, ThemeNegotiatorInterface $theme_negotiator, RouteMatchInterface $route_match) {
$this->themeManager = $theme_manager;
$this->themeNegotiator = $theme_negotiator;
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('theme.manager'),
$container->get('theme.negotiator'),
$container->get('current_route_match')
);
}
/**
* Some known placeholder content which can be used for testing.
@ -40,10 +94,27 @@ class MenuTestController {
}
/**
* @todo Remove menu_test_theme_page_callback().
* Page callback: Tests the theme negotiation functionality.
*
* @param bool $inherited
* TRUE when the requested page is intended to inherit
* the theme of its parent.
*
* @return string
* A string describing the requested custom theme and actual
* theme being used
* for the current page request.
*/
public function themePage($inherited) {
return menu_test_theme_page_callback($inherited);
$theme_key = $this->themeManager->getActiveTheme()->getName();
// Now we check what the theme negotiator service returns.
$active_theme = $this->themeNegotiator
->determineActiveTheme($this->routeMatch);
$output = "Active theme: $active_theme. Actual theme: $theme_key.";
if ($inherited) {
$output .= ' Theme negotiation inheritance is being tested.';
}
return ['#markup' => $output];
}
/**

View file

@ -21,4 +21,11 @@ class TestTasksSettingsSub1 extends LocalTaskDefault {
return $this->t('Dynamic title for @class', array('@class' => 'TestTasksSettingsSub1'));
}
/**
* {@inheritdoc}
*/
function getCacheTags() {
return ['kittens:ragdoll'];
}
}

View file

@ -36,6 +36,17 @@ class TestControllers {
return ['#markup' => 'test2'];
}
/**
* Prints out test data.
*/
public function testSession() {
if (!isset($_SESSION['menu_test'])) {
$_SESSION['menu_test'] = 0;
}
$_SESSION['menu_test']++;
return ['#markup' => SafeMarkup::format('Session menu_test is @count', ['@count' => $_SESSION['menu_test']])];
}
/**
* Prints out test data.
*/

View file

@ -1,7 +1,7 @@
<?php
/**
* Implements hook_altered_test_hook()
* Implements hook_altered_test_hook().
*
* @see module_test_module_implements_alter()
*/

View file

@ -47,7 +47,7 @@ function module_test_system_info_alter(&$info, Extension $file, $type) {
}
}
if ($file->getName() == 'seven' && $type == 'theme') {
$info['regions']['test_region'] = t('Test region');
$info['regions']['test_region'] = 'Test region';
}
}

View file

@ -0,0 +1,7 @@
<?php
/**
* Test post update function.
*/
function module_test_post_update_test() {
}

View file

@ -25,6 +25,8 @@ class TestControllers {
}
public function testEntityLanguage(NodeInterface $node) {
return ['#markup' => $node->label()];
$build = ['#markup' => $node->label()];
\Drupal::service('renderer')->addCacheableDependency($build, $node);
return $build;
}
}

View file

@ -78,7 +78,7 @@ class MockBlockManager extends PluginManagerBase {
'label' => t('User name'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
'context' => array(
'user' => new ContextDefinition('entity:user', t('User')),
'user' => $this->createContextDefinition('entity:user', t('User')),
),
));
@ -87,7 +87,7 @@ class MockBlockManager extends PluginManagerBase {
'label' => t('User name optional'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockUserNameBlock',
'context' => array(
'user' => new ContextDefinition('entity:user', t('User'), FALSE),
'user' => $this->createContextDefinition('entity:user', t('User'), FALSE),
),
));
@ -102,8 +102,8 @@ class MockBlockManager extends PluginManagerBase {
'label' => t('Complex context'),
'class' => 'Drupal\plugin_test\Plugin\plugin_test\mock_block\MockComplexContextBlock',
'context' => array(
'user' => new ContextDefinition('entity:user', t('User')),
'node' => new ContextDefinition('entity:node', t('Node')),
'user' => $this->createContextDefinition('entity:user', t('User')),
'node' => $this->createContextDefinition('entity:node', t('Node')),
),
));
@ -118,4 +118,24 @@ class MockBlockManager extends PluginManagerBase {
// specified), so we provide it the discovery object.
$this->factory = new ReflectionFactory($this->discovery);
}
/**
* Creates a new context definition with a label that is cast to string.
*
* @param string $data_type
* The required data type.
* @param mixed string|null $label
* The label of this context definition for the UI.
* @param bool $required
* Whether the context definition is required.
*
* @return \Drupal\Core\Plugin\Context\ContextDefinition
*/
protected function createContextDefinition($data_type, $label, $required = TRUE) {
// We cast the label to string for testing purposes only, as it may be
// a TranslatableMarkup and we will do assertEqual() checks on arrays that
// include ContextDefinition objects, and var_export() has problems
// printing TranslatableMarkup objects.
return new ContextDefinition($data_type, (string) $label, $required);
}
}

View file

@ -0,0 +1,8 @@
name: 'Rendering #attached test'
type: module
description: 'Support module for HtmlResponseAttachmentsTest.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- block

View file

@ -0,0 +1,27 @@
render_attached.teapot:
path: '/render_attached_test/teapot'
defaults:
_controller: '\Drupal\render_attached_test\Controller\RenderAttachedTestController::teapotHeaderStatus'
requirements:
_access: 'TRUE'
render_attached.header:
path: '/render_attached_test/header'
defaults:
_controller: '\Drupal\render_attached_test\Controller\RenderAttachedTestController::header'
requirements:
_access: 'TRUE'
render_attached.head:
path: '/render_attached_test/head'
defaults:
_controller: '\Drupal\render_attached_test\Controller\RenderAttachedTestController::head'
requirements:
_access: 'TRUE'
render_attached.feed_single:
path: '/render_attached_test/feed'
defaults:
_controller: '\Drupal\render_attached_test\Controller\RenderAttachedTestController::feed'
requirements:
_access: 'TRUE'

View file

@ -0,0 +1,77 @@
<?php
/**
* @file
* Contains \Drupal\render_attached_test\Controller\TestController.
*/
namespace Drupal\render_attached_test\Controller;
/**
* Controller for various permutations of #attached in the render array.
*/
class RenderAttachedTestController {
/**
* Test special header and status code rendering.
*
* @return array
* A render array using features of the 'http_header' directive.
*/
public function teapotHeaderStatus() {
$render = [];
$render['#attached']['http_header'][] = ['Status', "418 I'm a teapot."];
return $render;
}
/**
* Test attached HTML head rendering.
*
* @return array
* A render array using the 'http_head' directive.
*/
public function header() {
$render = [];
$render['#attached']['http_header'][] = ['X-Test-Teapot-Replace', 'This value gets replaced'];
$render['#attached']['http_header'][] = ['X-Test-Teapot-Replace', 'Teapot replaced', TRUE];
$render['#attached']['http_header'][] = ['X-Test-Teapot-No-Replace', 'This value is not replaced'];
$render['#attached']['http_header'][] = ['X-Test-Teapot-No-Replace', 'This one is added', FALSE];
$render['#attached']['http_header'][] = ['X-Test-Teapot', 'Teapot Mode Active'];
return $render;
}
/**
* Test attached HTML head rendering.
*
* @return array
* A render array using the 'html_head' directive.
*/
public function head() {
$head = [
[
'#tag' => 'meta',
'#attributes' => [
'test-attribute' => 'testvalue',
],
],
'test_head_attribute',
];
$render = [];
$render['#attached']['html_head'][] = $head;
return $render;
}
/**
* Test attached feed rendering.
*
* @return array
* A render array using the 'feed' directive.
*/
public function feed() {
$render = [];
$render['#attached']['feed'][] = ['test://url', 'Your RSS feed.'];
return $render;
}
}

View file

@ -0,0 +1,50 @@
<?php
/**
* @file
* Contains \Drupal\render_attached_test\Plugin\Block\DrupalProcessAttachedBlock.
*/
namespace Drupal\render_attached_test\Plugin\Block;
use Drupal\render_attached_test\Controller\RenderAttachedTestController;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Render\BubbleableMetadata;
/**
* A block we can use to test caching of #attached headers.
*
* @Block(
* id = "attached_rendering_block",
* admin_label = @Translation("AttachedRenderingBlock")
* )
*
* @see \Drupal\system\Tests\Render\HtmlResponseAttachmentsTest
*/
class AttachedRenderingBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
// Grab test attachment fixtures from
// Drupal\render_attached_test\Controller\RenderAttachedTestController.
$controller = new RenderAttachedTestController();
$attached = BubbleableMetadata::mergeAttachments($controller->feed(), $controller->head());
$attached = BubbleableMetadata::mergeAttachments($attached, $controller->header());
$attached = BubbleableMetadata::mergeAttachments($attached, $controller->teapotHeaderStatus());
// Return some arbitrary markup so the block doesn't disappear.
$attached['#markup'] = 'Markup from attached_rendering_block.';
return $attached;
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
}

View file

@ -7,9 +7,9 @@
namespace Drupal\system_test\Controller;
use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
/**
* Defines a controller to respond the page cache accept header test.
@ -26,10 +26,10 @@ class PageCacheAcceptHeaderController {
*/
public function content(Request $request) {
if ($request->getRequestFormat() === 'json') {
return new JsonResponse(array('content' => 'oh hai this is json'));
return new CacheableJsonResponse(['content' => 'oh hai this is json']);
}
else {
return new Response("<p>oh hai this is html.</p>");
return new CacheableResponse("<p>oh hai this is html.</p>");
}
}
}

View file

@ -8,9 +8,10 @@
namespace Drupal\system_test\Controller;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\CacheableResponse;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Render\SafeString;
use Drupal\Core\Render\Markup;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;
@ -114,18 +115,18 @@ class SystemTestController extends ControllerBase {
drupal_set_message('Duplicated message', 'status', TRUE);
drupal_set_message('Duplicated message', 'status', TRUE);
// Add a SafeString message.
drupal_set_message(SafeString::create('SafeString with <em>markup!</em>'));
// Test duplicate SafeString messages.
drupal_set_message(SafeString::create('SafeString with <em>markup!</em>'));
// Ensure that multiple SafeString messages work.
drupal_set_message(SafeString::create('SafeString2 with <em>markup!</em>'));
// Add a Markup message.
drupal_set_message(Markup::create('Markup with <em>markup!</em>'));
// Test duplicate Markup messages.
drupal_set_message(Markup::create('Markup with <em>markup!</em>'));
// Ensure that multiple Markup messages work.
drupal_set_message(Markup::create('Markup2 with <em>markup!</em>'));
// Test mixing of types.
drupal_set_message(SafeString::create('Non duplicate SafeString / string.'));
drupal_set_message('Non duplicate SafeString / string.');
drupal_set_message(SafeString::create('Duplicate SafeString / string.'), 'status', TRUE);
drupal_set_message('Duplicate SafeString / string.', 'status', TRUE);
drupal_set_message(Markup::create('Non duplicate Markup / string.'));
drupal_set_message('Non duplicate Markup / string.');
drupal_set_message(Markup::create('Duplicate Markup / string.'), 'status', TRUE);
drupal_set_message('Duplicate Markup / string.', 'status', TRUE);
// Test auto-escape of non safe strings.
drupal_set_message('<em>This<span>markup will be</span> escaped</em>.');
@ -259,13 +260,28 @@ class SystemTestController extends ControllerBase {
*/
public function setHeader(Request $request) {
$query = $request->query->all();
$response = new Response();
$response = new CacheableResponse();
$response->headers->set($query['name'], $query['value']);
$response->getCacheableMetadata()->addCacheContexts(['url.query_args:name', 'url.query_args:value']);
$response->setContent($this->t('The following header was set: %name: %value', array('%name' => $query['name'], '%value' => $query['value'])));
return $response;
}
/**
* A simple page callback that uses a plain Symfony response object.
*/
public function respondWithReponse(Request $request) {
return new Response('test');
}
/**
* A simple page callback that uses a CacheableResponse object.
*/
public function respondWithCacheableReponse(Request $request) {
return new CacheableResponse('test');
}
/**
* A simple page callback which adds a register shutdown function.
*/

View file

@ -129,3 +129,17 @@ system_test.permission_dependent_route_access:
_controller: '\Drupal\system_test\Controller\SystemTestController::mainContentFallback'
requirements:
_permission: 'pet llamas'
system_test.respond_response:
path: '/system-test/respond-reponse'
defaults:
_controller: '\Drupal\system_test\Controller\SystemTestController::respondWithReponse'
requirements:
_access: 'TRUE'
system_test.respond_cacheable_response:
path: '/system-test/respond-cacheable-reponse'
defaults:
_controller: '\Drupal\system_test\Controller\SystemTestController::respondWithCacheableReponse'
requirements:
_access: 'TRUE'

View file

@ -13,10 +13,18 @@ namespace Drupal\test_page_test\Controller;
class TestPageTestController {
/**
* @todo Remove test_page_test_page().
* Returns a test page and sets the title.
*/
public function testPage() {
return test_page_test_page();
return [
'#title' => t('Test page'),
'#markup' => t('Test page text.'),
'#attached' => [
'drupalSettings' => [
'test-setting' => 'azAZ09();.,\\\/-_{}',
],
],
];
}
}

View file

@ -1,15 +0,0 @@
<?php
/**
* Page callback: Returns a test page and sets the title.
*
* @deprecated Use \Drupal\test_page_test\Controller\TestPageTestController::testPage()
*/
function test_page_test_page() {
$attached['drupalSettings']['test-setting'] = 'azAZ09();.,\\\/-_{}';
return array(
'#title' => t('Test page'),
'#markup' => t('Test page text.'),
'#attached' => $attached,
);
}

View file

@ -81,6 +81,12 @@ function theme_test_page_bottom(array &$page_bottom) {
$page_bottom['theme_test_page_bottom'] = array('#markup' => 'theme test page bottom markup');
}
/**
* Implements template_preprocess_HOOK() for theme_test_function_suggestions theme functions.
*/
function template_preprocess_theme_test_function_suggestions(&$variables) {
}
/**
* Theme function for testing _theme('theme_test_foo').
*/

View file

@ -0,0 +1,26 @@
<?php
/**
* @file
* Contains \Drupal\twig_theme_test\ExampleRenderable.
*/
namespace Drupal\twig_theme_test;
use Drupal\Core\Render\RenderableInterface;
/**
* Provides an example implementation of the RenderableInterface.
*/
class ExampleRenderable implements RenderableInterface {
/**
* {@inheritdoc}
*/
public function toRenderable() {
return [
'#markup' => 'Example markup',
];
}
}

View file

@ -99,4 +99,14 @@ class TwigThemeTestController {
return array('#theme' => 'twig_registry_loader_test');
}
/**
* Controller for testing a renderable inside a template.
*/
public function renderable() {
return [
'#theme' => 'twig_theme_test_renderable',
'#renderable' => new ExampleRenderable()
];
}
}

View file

@ -0,0 +1 @@
<div>{{ renderable }}</div>

View file

@ -47,11 +47,6 @@
Escaped: {{ string }}
{% endtrans %}
</div>
<div>
{% trans %}
Pass-through: {{ string|passthrough }}
{% endtrans %}
</div>
<div>
{% trans %}
Placeholder: {{ string|placeholder }}
@ -63,7 +58,7 @@
{% set count = token|length %}
<div>
{% trans %}
This {{ token.name }} has a length of: {{ count }}. It contains: {{ token.numbers|placeholder }} and {{ token.bad_text }}. Lets pass the bad text through: {{ token.bad_text|passthrough }}.
This {{ token.name }} has a length of: {{ count }}. It contains: {{ token.numbers|placeholder }} and {{ token.bad_text }}.
{% endtrans %}
</div>

View file

@ -62,6 +62,12 @@ function twig_theme_test_theme($existing, $type, $theme, $path) {
'variables' => array(),
'template' => 'twig_theme_test.attach_library',
);
$items['twig_theme_test_renderable'] = array(
'variables' => array(
'renderable' => NULL,
),
'template' => 'twig_theme_test.renderable',
);
return $items;
}

View file

@ -62,3 +62,10 @@ twig_theme_test_registry_loader:
no_cache: TRUE
requirements:
_access: 'TRUE'
twig_theme_test_renderable:
path: '/twig-theme-test/renderable'
defaults:
_controller: '\Drupal\twig_theme_test\TwigThemeTestController::renderable'
requirements:
_access: 'TRUE'

View file

@ -1,6 +0,0 @@
name: 'Update order test'
type: module
description: 'Support module for update testing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -1,53 +0,0 @@
<?php
/**
* @file
* Update hooks for the update_order_test module.
*/
use Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface;
/**
* Only declare the update hooks once the test is running.
*
* @see \Drupal\system\Tests\Entity\Update\SqlContentEntityStorageSchemaIndexTest
*/
if (\Drupal::state()->get('update_order_test', FALSE)) {
/**
* Runs before entity schema updates.
*/
function update_order_test_update_8001() {
// Store whether the node__default_langcode index exists when this hook is
// invoked.
\Drupal::state()->set('update_order_test_update_8001', db_index_exists('node_field_data', 'node__default_langcode'));
}
/**
* Runs before entity schema updates.
*/
function update_order_test_update_8002() {
// Check and store whether the update_order_test field exists when this
// hook is first invoked.
\Drupal::state()->set('update_order_test_update_8002_update_order_test_before', db_field_exists('node_field_data', 'update_order_test'));
// Attempt to apply the update for the update_order_test field and then
// check and store again whether it exists.
if (\Drupal::service('entity.definition_update_manager')->applyFieldUpdate(EntityDefinitionUpdateManagerInterface::DEFINITION_CREATED, 'node', 'update_order_test')) {
\Drupal::state()->set('update_order_test_update_8002_update_order_test_after', db_field_exists('node_field_data', 'update_order_test'));
}
// Attempt to apply all node entity type updates.
if (\Drupal::service('entity.definition_update_manager')->applyEntityUpdate(EntityDefinitionUpdateManagerInterface::DEFINITION_UPDATED, 'node')) {
// Node updates have now run. Check and store whether the updated node
// indices now exist.
\Drupal::state()->set('update_order_test_update_8002_node__default_langcode', db_index_exists('node_field_data', 'node__default_langcode'));
\Drupal::state()->set('update_order_test_update_8002_node__id__default_langcode__langcode', db_index_exists('node_field_data', 'node__id__default_langcode__langcode'));
// User updates have not yet run. Check and store whether the updated
// user indices now exist.
\Drupal::state()->set('update_order_test_update_8002_user__id__default_langcode__langcode', db_index_exists('users_field_data', 'user__id__default_langcode__langcode'));
}
}
}

View file

@ -1,27 +0,0 @@
<?php
/**
* @file
* Hooks for the update_order_test module.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Only declare the new entity base field once the test is running.
*/
if (\Drupal::state()->get('update_order_test', FALSE)) {
/**
* Implements hook_entity_base_field_info().
*/
function update_order_test_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'node') {
$fields['update_order_test'] = BaseFieldDefinition::create('integer')
->setLabel(t('Update order test'));
return $fields;
}
}
}

View file

@ -0,0 +1,6 @@
name: 'Update test failing'
type: module
description: 'Support module for update testing when an update hook is failing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,22 @@
<?php
/**
* @file
* Contains a failing update hook for testing the update system.
*/
use Drupal\Core\Utility\UpdateException;
/**
* This update will fail.
*/
function update_test_failing_update_8001() {
throw new UpdateException('This update hook is failing.');
}
/**
* A further update.
*/
function update_test_failing_update_8002() {
// This hook won't ever run.
}

View file

@ -0,0 +1,10 @@
<?php
/**
* First update, should not be run since this module's update hooks fail.
*/
function update_test_failing_post_update_first() {
$execution = \Drupal::state()->get('post_update_test_execution', []);
$execution[] = __FUNCTION__;
\Drupal::state()->set('post_update_test_execution', $execution);
}

View file

@ -0,0 +1,5 @@
core: 8.x
name: Update test after
type: module
package: Testing
version: VERSION

View file

@ -0,0 +1,7 @@
<?php
/**
* Normal update_N() function.
*/
function update_test_postupdate_update_8001() {
}

View file

@ -0,0 +1,45 @@
<?php
/**
* First update.
*/
function update_test_postupdate_post_update_first() {
$execution = \Drupal::state()->get('post_update_test_execution', []);
$execution[] = __FUNCTION__;
\Drupal::state()->set('post_update_test_execution', $execution);
return 'First update';
}
/**
* Second update.
*/
function update_test_postupdate_post_update_second() {
$execution = \Drupal::state()->get('post_update_test_execution', []);
$execution[] = __FUNCTION__;
\Drupal::state()->set('post_update_test_execution', $execution);
return 'Second update';
}
/**
* Test1 update.
*/
function update_test_postupdate_post_update_test1() {
$execution = \Drupal::state()->get('post_update_test_execution', []);
$execution[] = __FUNCTION__;
\Drupal::state()->set('post_update_test_execution', $execution);
return 'Test1 update';
}
/**
* Test0 update.
*/
function update_test_postupdate_post_update_test0() {
$execution = \Drupal::state()->get('post_update_test_execution', []);
$execution[] = __FUNCTION__;
\Drupal::state()->set('post_update_test_execution', $execution);
return 'Test0 update';
}

View file

@ -27,9 +27,7 @@ class PathProcessor implements InboundPathProcessorInterface {
}
// Rewrite community/ to forum/.
if ($path == '/community' || strpos($path, '/community/') === 0) {
$path = '/forum' . substr($path, 9);
}
$path = preg_replace('@^/community(.*)@', '/forum$1', $path);
if ($path == '/url-alter-test/bar') {
$path = '/url-alter-test/foo';

View file

@ -31,9 +31,7 @@ class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathPr
}
// Rewrite community/ to forum/.
if ($path == '/community' || strpos($path, '/community/') === 0) {
$path = '/forum' . substr($path, 10);
}
$path = preg_replace('@^/community(.*)@', '/forum$1', $path);
if ($path == '/url-alter-test/bar') {
$path = '/url-alter-test/foo';
@ -57,10 +55,7 @@ class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathPr
}
// Rewrite forum/ to community/.
if ($path == '/forum' || strpos($path, '/forum/') === 0) {
$path = '/community' . substr($path, 5);
}
return $path;
return preg_replace('@^/forum(.*)@', '/community$1', $path);
}
}

View file

@ -0,0 +1,205 @@
<?php
/**
* @file
* Contains \Drupal\Tests\system\Kernel\Entity\EntityReferenceSelectionReferenceableTest.
*/
namespace Drupal\Tests\system\Kernel\Entity;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\NodeType;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests entity reference selection plugins.
*
* @group entity_reference
*/
class EntityReferenceSelectionReferenceableTest extends KernelTestBase {
use EntityReferenceTestTrait;
/**
* Bundle of 'entity_test_no_label' entity.
*
* @var string
*/
protected $bundle;
/**
* Labels to be tested.
*
* @var array
*/
protected static $labels = ['abc', 'Xyz_', 'xyabz_', 'foo_', 'bar_', 'baz_', 'șz_', NULL, '<strong>'];
/**
* The selection handler.
*
* @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface.
*/
protected $selectionHandler;
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'user', 'field', 'entity_reference', 'node', 'entity_test'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('entity_test_no_label');
/** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
$storage = $this->container->get('entity.manager')
->getStorage('entity_test_no_label');
// Create a new node-type.
NodeType::create([
'type' => $node_type = Unicode::strtolower($this->randomMachineName()),
'name' => $this->randomString(),
])->save();
// Create an entity reference field targeting 'entity_test_no_label'
// entities.
$field_name = Unicode::strtolower($this->randomMachineName());
$this->createEntityReferenceField('node', $node_type, $field_name, $this->randomString(), 'entity_test_no_label');
$field_config = FieldConfig::loadByName('node', $node_type, $field_name);
$this->selectionHandler = $this->container->get('plugin.manager.entity_reference_selection')->getSelectionHandler($field_config);
// Generate a bundle name to be used with 'entity_test_no_label'.
$this->bundle = Unicode::strtolower($this->randomMachineName());
// Create 6 entities to be referenced by the field.
foreach (static::$labels as $name) {
$storage->create([
'id' => Unicode::strtolower($this->randomMachineName()),
'name' => $name,
'type' => $this->bundle,
])->save();
}
}
/**
* Tests values returned by SelectionInterface::getReferenceableEntities()
* when the target entity type has no 'label' key.
*
* @param mixed $match
* The input text to be checked.
* @param string $match_operator
* The matching operator.
* @param int $limit
* The limit of returning records.
* @param int $count_limited
* The expected number of limited entities to be retrieved.
* @param array $items
* Array of entity labels expected to be returned.
* @param int $count_all
* The total number (unlimited) of entities to be retrieved.
*
* @dataProvider providerTestCases
*/
public function testReferenceablesWithNoLabelKey($match, $match_operator, $limit, $count_limited, array $items, $count_all) {
// Test ::getReferenceableEntities().
$referenceables = $this->selectionHandler->getReferenceableEntities($match, $match_operator, $limit);
// Number of returned items.
if (empty($count_limited)) {
$this->assertTrue(empty($referenceables[$this->bundle]));
}
else {
$this->assertSame(count($referenceables[$this->bundle]), $count_limited);
}
// Test returned items.
foreach ($items as $item) {
// SelectionInterface::getReferenceableEntities() always return escaped
// entity labels.
// @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::getReferenceableEntities()
$item = is_string($item) ? Html::escape($item) : $item;
$this->assertTrue(array_search($item, $referenceables[$this->bundle]) !== FALSE);
}
// Test ::countReferenceableEntities().
$count_referenceables = $this->selectionHandler->countReferenceableEntities($match, $match_operator);
$this->assertSame($count_referenceables, $count_all);
}
/**
* Provides test cases for ::testReferenceablesWithNoLabelKey() test.
*
* @return array[]
*/
public function providerTestCases() {
return [
// All referenceables, no limit. Expecting 9 items.
[NULL, 'CONTAINS', 0, 9, static::$labels, 9],
// Referenceables containing 'w', no limit. Expecting no item.
['w', 'CONTAINS', 0, 0, [], 0],
// Referenceables starting with 'w', no limit. Expecting no item.
['w', 'STARTS_WITH', 0, 0, [], 0],
// Referenceables containing 'ab', no limit. Expecting 2 items ('abc',
// 'xyabz').
['ab', 'CONTAINS', 0, 2, ['abc', 'xyabz_'], 2],
// Referenceables starting with 'A', no limit. Expecting 1 item ('abc').
['A', 'STARTS_WITH', 0, 1, ['abc'], 1],
// Referenceables containing '_', limited to 3. Expecting 3 limited items
// ('Xyz_', 'xyabz_', 'foo_') and 5 total.
['_', 'CONTAINS', 3, 3, ['Xyz_', 'xyabz_', 'foo_'], 6],
// Referenceables ending with with 'z_', limited to 3. Expecting 3 limited
// items ('Xyz_', 'xyabz_', 'baz_') and 4 total.
['z_', 'ENDS_WITH', 3, 3, ['Xyz_', 'xyabz_', 'baz_'], 4],
// Referenceables identical with 'xyabz_', no limit. Expecting 1 item
// ('xyabz_').
['xyabz_', '=', 0, 1, ['xyabz_'], 1],
// Referenceables greater than 'foo', no limit. Expecting 4 items ('Xyz_',
// 'xyabz_', 'foo_', 'șz_').
['foo', '>', 0, 4, ['Xyz_', 'xyabz_', 'foo_', 'șz_'], 4],
// Referenceables greater or identical with 'baz_', no limit. Expecting 5
// items ('Xyz_', 'xyabz_', 'foo_', 'baz_', 'șz_').
['baz_', '>=', 0, 5, ['Xyz_', 'xyabz_', 'foo_', 'baz_', 'șz_'], 5],
// Referenceables less than 'foo', no limit. Expecting 5 items ('abc',
// 'bar_', 'baz_', NULL, '<strong>').
['foo', '<', 0, 5, ['abc', 'bar_', 'baz_', NULL, '<strong>'], 5],
// Referenceables less or identical with 'baz_', no limit. Expecting 5
// items ('abc', 'bar_', 'baz_', NULL, '<strong>').
['baz_', '<=', 0, 5, ['abc', 'bar_', 'baz_', NULL, '<strong>'], 5],
// Referenceables not identical with 'baz_', no limit. Expecting 7 items
// ('abc', 'Xyz_', 'xyabz_', 'foo_', 'bar_', 'șz_', NULL, '<strong>').
['baz_', '<>', 0, 8, ['abc', 'Xyz_', 'xyabz_', 'foo_', 'bar_', 'șz_', NULL, '<strong>'], 8],
// Referenceables in ('bar_', 'baz_'), no limit. Expecting 2 items
// ('bar_', 'baz_')
[['bar_', 'baz_'], 'IN', 0, 2, ['bar_', 'baz_'], 2],
// Referenceables not in ('bar_', 'baz_'), no limit. Expecting 6 items
// ('abc', 'Xyz_', 'xyabz_', 'foo_', 'șz_', NULL, '<strong>')
[['bar_', 'baz_'], 'NOT IN', 0, 7, ['abc', 'Xyz_', 'xyabz_', 'foo_', 'șz_', NULL, '<strong>'], 7],
// Referenceables not null, no limit. Expecting 9 items ('abc', 'Xyz_',
// 'xyabz_', 'foo_', 'bar_', 'baz_', 'șz_', NULL, '<strong>').
//
// Note: Even we set the name as NULL, when retrieving the label from the
// entity we'll get an empty string, meaning that this match operator
// will return TRUE every time.
[NULL, 'IS NOT NULL', 0, 9, static::$labels, 9],
// Referenceables null, no limit. Expecting 9 items ('abc', 'Xyz_',
// 'xyabz_', 'foo_', 'bar_', 'baz_', 'șz_', NULL, '<strong>').
//
// Note: Even we set the name as NULL, when retrieving the label from the
// entity we'll get an empty string, meaning that this match operator
// will return FALSE every time.
[NULL, 'IS NULL', 0, 9, static::$labels, 9],
// Referenceables containing '<strong>' markup, no limit. Expecting 1 item
// ('<strong>').
['<strong>', 'CONTAINS', 0, 1, ['<strong>'], 1],
// Test an unsupported operator. We expect no items.
['abc', '*unsupported*', 0, 0, [], 0],
];
}
}

View file

@ -7,6 +7,7 @@
namespace Drupal\Tests\system\Kernel\Extension;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use \Drupal\Core\Extension\ModuleUninstallValidatorException;
use Drupal\KernelTests\KernelTestBase;
@ -18,6 +19,11 @@ use Drupal\KernelTests\KernelTestBase;
*/
class ModuleHandlerTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* {@inheritdoc}
*/
@ -48,7 +54,7 @@ class ModuleHandlerTest extends KernelTestBase {
* The basic functionality of retrieving enabled modules.
*/
function testModuleList() {
$module_list = array();
$module_list = ['system'];
$this->assertModuleList($module_list, 'Initial');

View file

@ -0,0 +1,137 @@
<?php
/**
* @file
* Contains \Drupal\Tests\system\Kernel\Scripts\DbCommandBaseTest.
*/
namespace Drupal\Tests\system\Kernel\Scripts;
use Drupal\Core\Command\DbCommandBase;
use Drupal\Core\Database\Database;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tester\CommandTester;
/**
* Test that the DbToolsApplication works correctly.
*
* The way console application's run it is impossible to test. For now we only
* test that we are registering the correct commands.
*
* @group console
*/
class DbCommandBaseTest extends KernelTestBase {
/**
* Test specifying a database key.
*/
public function testSpecifyDatabaseKey() {
$command = new DbCommandBaseTester();
$command_tester = new CommandTester($command);
Database::addConnectionInfo('magic_db', 'default', Database::getConnectionInfo('default')['default']);
$command_tester->execute([
'--database' => 'magic_db'
]);
$this->assertEquals('magic_db', $command->getDatabaseConnection($command_tester->getInput())->getKey(),
'Special db key is returned');
}
/**
* Invalid database names will throw a useful exception.
*
* @expectedException \Drupal\Core\Database\ConnectionNotDefinedException
*/
public function testSpecifyDatabaseDoesNotExist() {
$command = new DbCommandBaseTester();
$command_tester = new CommandTester($command);
$command_tester->execute([
'--database' => 'dne'
]);
$command->getDatabaseConnection($command_tester->getInput());
}
/**
* Test supplying database connection as a url.
*/
public function testSpecifyDbUrl() {
$connection_info = Database::getConnectionInfo('default')['default'];
$command = new DbCommandBaseTester();
$command_tester = new CommandTester($command);
$command_tester->execute([
'-db-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database']
]);
$this->assertEquals('db-tools', $command->getDatabaseConnection($command_tester->getInput())->getKey());
Database::removeConnection('db-tools');
$command_tester->execute([
'--database-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database']
]);
$this->assertEquals('db-tools', $command->getDatabaseConnection($command_tester->getInput())->getKey());
}
/**
* Test specifying a prefix for different connections.
*/
public function testPrefix() {
if (Database::getConnection()->driver() == 'sqlite') {
$this->markTestSkipped('SQLITE modifies the prefixes so we cannot effectively test it');
}
Database::addConnectionInfo('magic_db', 'default', Database::getConnectionInfo('default')['default']);
$command = new DbCommandBaseTester();
$command_tester = new CommandTester($command);
$command_tester->execute([
'--database' => 'magic_db',
'--prefix' => 'extra',
]);
$this->assertEquals('extra', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
$connection_info = Database::getConnectionInfo('default')['default'];
$command_tester->execute([
'-db-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database'],
'--prefix' => 'extra2',
]);
$this->assertEquals('extra2', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
// This breaks simpletest cleanup.
// $command_tester->execute([
// '--prefix' => 'notsimpletest',
// ]);
// $this->assertEquals('notsimpletest', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
}
}
/**
* Concrete command implementation for testing base features.
*/
class DbCommandBaseTester extends DbCommandBase {
/**
* {@inheritdoc}
*/
public function configure() {
parent::configure();
$this->setName('test');
}
/**
* {@inheritdoc}
*/
public function getDatabaseConnection(InputInterface $input) {
return parent::getDatabaseConnection($input);
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
// Empty implementation for testing.
}
}

View file

@ -0,0 +1,88 @@
<?php
/**
* @file
* Contains \Drupal\Tests\system\Kernel\Scripts\DbDumpCommandTest.
*/
namespace Drupal\Tests\system\Kernel\Scripts;
use Drupal\Core\Command\DbDumpCommand;
use Drupal\Core\Database\Database;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\Console\Tester\CommandTester;
/**
* Test that the DbDumpCommand works correctly.
*
* @group console
*/
class DbDumpCommandTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
// Determine what database backend is running, and set the skip flag.
if (Database::getConnection()->databaseType() !== 'mysql') {
$this->markTestSkipped("Skipping test since the DbDumpCommand is currently only compatible with MySQL");
}
$this->installSchema('system', 'router');
/** @var \Drupal\Core\Database\Connection $connection */
$connection = $this->container->get('database');
$connection->insert('router')->fields(['name', 'path', 'pattern_outline'])->values(['test', 'test', 'test'])->execute();
}
/**
* Test the command directly.
*/
public function testDbDumpCommand() {
$command = new DbDumpCommand();
$command_tester = new CommandTester($command);
$command_tester->execute([]);
// Assert that insert exists and that some expected fields exist.
$output = $command_tester->getDisplay();
$this->assertContains("createTable('router", $output, 'Table router found');
$this->assertContains("insert('router", $output, 'Insert found');
$this->assertContains("'name' => 'test", $output, 'Insert name field found');
$this->assertContains("'path' => 'test", $output, 'Insert path field found');
$this->assertContains("'pattern_outline' => 'test", $output, 'Insert pattern_outline field found');
}
/**
* Test schema only option.
*/
public function testSchemaOnly() {
$command = new DbDumpCommand();
$command_tester = new CommandTester($command);
$command_tester->execute(['--schema-only' => 'router']);
// Assert that insert statement doesn't exist for schema only table.
$output = $command_tester->getDisplay();
$this->assertContains("createTable('router", $output, 'Table router found');
$this->assertNotContains("insert('router", $output, 'Insert not found');
$this->assertNotContains("'name' => 'test", $output, 'Insert name field not found');
$this->assertNotContains("'path' => 'test", $output, 'Insert path field not found');
$this->assertNotContains("'pattern_outline' => 'test", $output, 'Insert pattern_outline field not found');
// Assert that insert statement doesn't exist for wildcard schema only match.
$command_tester->execute(['--schema-only' => 'route.*']);
$output = $command_tester->getDisplay();
$this->assertContains("createTable('router", $output, 'Table router found');
$this->assertNotContains("insert('router", $output, 'Insert not found');
$this->assertNotContains("'name' => 'test", $output, 'Insert name field not found');
$this->assertNotContains("'path' => 'test", $output, 'Insert path field not found');
$this->assertNotContains("'pattern_outline' => 'test", $output, 'Insert pattern_outline field not found');
}
}

View file

@ -0,0 +1,82 @@
<?php
/**
* @file
* Contains \Drupal\Tests\system\Kernel\Scripts\DbImportCommandTest.
*/
namespace Drupal\Tests\system\Kernel\Scripts;
use Drupal\Core\Command\DbImportCommand;
use Drupal\Core\Database\Database;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\Console\Tester\CommandTester;
/**
* Test that the DbImportCommand works correctly.
*
* @group console
*/
class DbImportCommandTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'config', 'dblog', 'menu_link_content', 'link', 'block_content', 'file', 'user'];
/**
* Tables that should be part of the exported script.
*
* @var array
*/
protected $tables = [
'block_content',
'block_content_field_data',
'block_content_field_revision',
'block_content_revision',
'cachetags',
'config',
'cache_discovery',
'cache_bootstrap',
'file_managed',
'key_value_expire',
'menu_link_content',
'menu_link_content_data',
'semaphore',
'sessions',
'url_alias',
'user__roles',
'users',
'users_field_data',
'watchdog',
];
/**
* Test the command directly.
*
* @requires extension pdo_sqlite
*/
public function testDbImportCommand() {
$connection_info = array(
'driver' => 'sqlite',
'database' => ':memory:',
);
Database::addConnectionInfo($this->databasePrefix, 'default', $connection_info);
$command = new DbImportCommand();
$command_tester = new CommandTester($command);
$command_tester->execute([
'script' => __DIR__ . '/../../../fixtures/update/drupal-8.bare.standard.php.gz',
'--database' => $this->databasePrefix,
]);
// The tables should now exist.
$connection = Database::getConnection('default', $this->databasePrefix);
foreach ($this->tables as $table) {
$this->assertTrue($connection
->schema()
->tableExists($table), strtr('Table @table created by the database script.', ['@table' => $table]));
}
}
}

Some files were not shown because too many files have changed in this diff Show more