Commit 91d73306 authored by fenstrat's avatar fenstrat Committed by fenstrat

Issue #2967988 by fenstrat: Fix failing BTB tests

parent e0dda679
......@@ -8,6 +8,7 @@ dependencies:
- block_field
- field
- node
- path
- user
- views
......@@ -6,6 +6,7 @@ dependencies:
- node.type.block_node
module:
- block_field
- path
id: node.block_node.default
targetEntityType: node
bundle: block_node
......@@ -16,6 +17,7 @@ content:
weight: 10
settings: { }
third_party_settings: { }
region: content
field_block:
weight: 31
settings:
......@@ -23,18 +25,34 @@ content:
settings: { }
third_party_settings: { }
type: block_field_default
region: content
path:
type: path
weight: 30
region: content
settings: { }
third_party_settings: { }
promote:
type: boolean_checkbox
settings:
display_label: true
weight: 15
third_party_settings: { }
region: content
status:
type: boolean_checkbox
settings:
display_label: true
weight: 120
region: content
third_party_settings: { }
sticky:
type: boolean_checkbox
settings:
display_label: true
weight: 16
third_party_settings: { }
region: content
title:
type: string_textfield
weight: -5
......@@ -42,6 +60,7 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
region: content
uid:
type: entity_reference_autocomplete
weight: 5
......@@ -50,4 +69,5 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
region: content
hidden: { }
......@@ -18,7 +18,8 @@ content:
settings: { }
third_party_settings: { }
type: block_field
region: content
links:
weight: 100
hidden:
langcode: true
region: content
hidden: { }
......@@ -16,5 +16,6 @@ required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: {}
settings:
plugin_ids: { }
field_type: block_field
langcode: en
status: true
dependencies: { }
name: 'Block node'
type: block_node
description: ''
......
langcode: en
status: true
dependencies: { }
name: Item
type: item
description: ''
......
......@@ -160,6 +160,8 @@ display:
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- 'user.node_grants:view'
- user.permissions
tags: { }
......@@ -174,6 +176,8 @@ display:
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- 'user.node_grants:view'
- user.permissions
tags: { }
......@@ -3,12 +3,10 @@
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.
* Test the block field widget.
*
* @group block_field
*/
......@@ -23,7 +21,11 @@ class WidgetTest extends BrowserTestBase {
'block_field_widget_test',
];
/** @var User */
/**
* The admin user.
*
* @var \Drupal\user\UserInterface
*/
private $adminUser;
/**
......@@ -37,47 +39,54 @@ class WidgetTest extends BrowserTestBase {
}
/**
* @test
* Test block settings are stored correctly.
*/
public function blockSettingsAreStoredCorrectly() {
$nodes = $this->createDummyNodes('item', 5);
public function testBlockSettingsAreStoredCorrectly() {
$items = $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->t('Save'));
$this->drupalGet('node/6/edit');
$node = $this->drupalGetNodeByTitle('Block field test');
$this->drupalGet($node->toUrl('edit-form'));
$this->submitForm([
'field_block[0][settings][override][items_per_page]' => 5,
], $this->t('Save and keep published'));
], $this->t('Save'));
do {
$this->assertSession()->pageTextContains(array_pop($nodes)->getTitle());
foreach ($items as $item) {
$this->assertSession()->pageTextContains($item->getTitle());
}
while (count($nodes));
}
/**
* @return User|false
* Create an admin user.
*
* @return \Drupal\user\UserInterface
* A user with all permissions.
*/
private function createAdminUser() {
return $this->drupalCreateUser(array_keys($this->container->get('user.permissions')->getPermissions()));
}
/**
* @param string $contentType
* Create dummy nodes.
*
* @param string $bundle
* The bundle type to create.
* @param int $numberOfNodes
* @return Node[]
* The number of nodes to create.
*
* @return array
* And array of created nodes.
*/
private function createDummyNodes($contentType, $numberOfNodes) {
$this->assertGreaterThan(0, $numberOfNodes);
private function createDummyNodes($bundle, $numberOfNodes) {
$nodes = [];
do {
$nodes[] = $this->createNode(['type' => $contentType]);
for ($i = 0; $i < $numberOfNodes; $i++) {
$nodes[] = $this->createNode(['type' => $bundle]);
}
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