Commit 43049015 authored by legolasbo's avatar legolasbo Committed by jrockowitz

Issue #2847084 by legolasbo, kristiaanvandeneynde: Follow up: Add test coverage for #2843687

parent b55bc2c1
name: 'Block field module widget tests'
type: module
description: 'Support module for block field that provides some default configuration to test the field widget.'
package: Testing
core: 8.x
dependencies:
- block
- block_field
- field
- node
- user
- views
langcode: en
status: true
dependencies:
config:
- field.field.node.block_node.field_block
- node.type.block_node
module:
- block_field
id: node.block_node.default
targetEntityType: node
bundle: block_node
mode: default
content:
created:
type: datetime_timestamp
weight: 10
settings: { }
third_party_settings: { }
field_block:
weight: 31
settings:
plugin_id: ''
settings: { }
third_party_settings: { }
type: block_field_default
promote:
type: boolean_checkbox
settings:
display_label: true
weight: 15
third_party_settings: { }
sticky:
type: boolean_checkbox
settings:
display_label: true
weight: 16
third_party_settings: { }
title:
type: string_textfield
weight: -5
settings:
size: 60
placeholder: ''
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 5
settings:
match_operator: CONTAINS
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
langcode: en
status: true
dependencies:
config:
- field.field.node.block_node.field_block
- node.type.block_node
module:
- block_field
- user
id: node.block_node.default
targetEntityType: node
bundle: block_node
mode: default
content:
field_block:
weight: 101
label: above
settings: { }
third_party_settings: { }
type: block_field
links:
weight: 100
hidden:
langcode: true
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_block
- node.type.block_node
module:
- block_field
id: node.block_node.field_block
field_name: field_block
entity_type: node
bundle: block_node
label: Block
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: {}
field_type: block_field
langcode: en
status: true
dependencies:
module:
- block_field
- node
id: node.field_block
field_name: field_block
entity_type: node
type: block_field
settings: { }
module: block_field
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
langcode: en
status: true
name: 'Block node'
type: block_node
description: ''
help: ''
new_revision: false
preview_mode: 0
display_submitted: false
langcode: en
status: true
name: Item
type: item
description: ''
help: ''
new_revision: false
preview_mode: 1
display_submitted: true
langcode: en
status: true
dependencies:
config:
- node.type.item
module:
- node
- user
id: items
label: Items
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
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: Toepassen
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sorteren op'
expose_sort_order: true
sort_asc_label: Oplopend
sort_desc_label: Aflopend
pager:
type: some
options:
items_per_page: 1
offset: 0
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:
title:
id: title
table: node_field_data
field: title
entity_type: node
entity_field: title
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
exclude: 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_alter_empty: true
click_sort_column: value
type: string
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:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
item: item
entity_type: node
entity_field: type
plugin_id: bundle
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
title: Items
cache_metadata:
max-age: -1
contexts:
- 'user.node_grants:view'
- user.permissions
tags: { }
block_1:
display_plugin: block
id: block_1
display_title: Items
position: 1
display_options:
display_extenders: { }
block_description: items
cache_metadata:
max-age: -1
contexts:
- 'user.node_grants:view'
- user.permissions
tags: { }
<?php
namespace Drupal\Tests\block_field\Functional;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\node\Entity\Node;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\Entity\User;
/**
* Test the video embed field widget.
*
* @group block_field
*/
class WidgetTest extends BrowserTestBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public static $modules = [
'block_field_widget_test',
];
/** @var User */
private $adminUser;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->adminUser = $this->createAdminUser();
$this->drupalLogin($this->adminUser);
}
/**
* @test
*/
public function blockSettingsAreStoredCorrectly() {
$nodes = $this->createDummyNodes('item', 5);
$this->drupalPostForm('node/add/block_node', [
'title[0][value]' => 'Block field test',
'field_block[0][plugin_id]' => 'views_block:items-block_1',
], $this->t('Save and publish'));
$this->drupalGet('node/6/edit');
$this->submitForm([
'field_block[0][settings][override][items_per_page]' => 5,
], $this->t('Save and keep published'));
do {
$this->assertSession()->pageTextContains(array_pop($nodes)->getTitle());
}
while (count($nodes));
}
/**
* @return User|false
*/
private function createAdminUser() {
return $this->drupalCreateUser(array_keys($this->container->get('user.permissions')->getPermissions()));
}
/**
* @param string $contentType
* @param int $numberOfNodes
* @return Node[]
*/
private function createDummyNodes($contentType, $numberOfNodes) {
$this->assertGreaterThan(0, $numberOfNodes);
$nodes = [];
do {
$nodes[] = $this->createNode(['type' => $contentType]);
}
while (count($nodes) < $numberOfNodes);
return $nodes;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment