Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,8 @@
name: "Custom Block module tests"
type: module
description: "Support module for custom block related testing."
package: Testing
version: VERSION
core: 8.x
dependencies:
- block_content

View file

@ -0,0 +1,69 @@
<?php
/**
* @file
* A dummy module for testing custom block related hooks.
*
* This is a dummy module that implements custom block related hooks to test API
* interaction with the block_content module.
*/
use Drupal\block_content\Entity\BlockContent;
/**
* Implements hook_block_content_view().
*/
function block_content_test_block_content_view(array &$build, BlockContent $block_content, $view_mode) {
// Add extra content.
$build['extra_content'] = array(
'#markup' => '<blink>Yowser</blink>',
);
}
/**
* Implements hook_block_content_presave().
*/
function block_content_test_block_content_presave(BlockContent $block_content) {
if ($block_content->label() == 'testing_block_content_presave') {
$block_content->setInfo($block_content->label() . '_presave');
}
// Determine changes.
if (!empty($block_content->original) && $block_content->original->label() == 'test_changes') {
if ($block_content->original->label() != $block_content->label()) {
$block_content->setInfo($block_content->label() . '_presave');
// Drupal 1.0 release.
$block_content->changed = 979534800;
}
}
}
/**
* Implements hook_block_content_update().
*/
function block_content_test_block_content_update(BlockContent $block_content) {
// Determine changes on update.
if (!empty($block_content->original) && $block_content->original->label() == 'test_changes') {
if ($block_content->original->label() != $block_content->label()) {
$block_content->setInfo($block_content->label() . '_update');
}
}
}
/**
* Implements hook_block_content_insert().
*
* This tests saving a block_content on block_content insert.
*
* @see \Drupal\block_content\Tests\BlockContentSaveTest::testBlockContentSaveOnInsert()
*/
function block_content_test_block_content_insert(BlockContent $block_content) {
// Set the block_content title to the block_content ID and save.
if ($block_content->label() == 'new') {
$block_content->setInfo('BlockContent ' . $block_content->id());
$block_content->setNewRevision(FALSE);
$block_content->save();
}
if ($block_content->label() == 'fail_creation') {
throw new Exception('Test exception for rollback.');
}
}

View file

@ -0,0 +1,6 @@
block_content_test.block_content_view:
path: '/block-content/{block_content}'
defaults:
_entity_view: 'block_content'
requirements:
_entity_access: 'block_content.view'

View file

@ -0,0 +1,26 @@
langcode: en
status: true
dependencies:
module:
- block_content
theme:
- classy
id: foobargorilla
theme: classy
region: content
weight: null
provider: null
plugin: 'block_content:fb5e8434-3617-4a1d-a252-8273e95ec30e'
settings:
id: 'block_content:fb5e8434-3617-4a1d-a252-8273e95ec30e'
label: 'Foobar Gorilla'
provider: block_content
label_display: visible
status: true
info: ''
view_mode: default
visibility:
request_path:
id: request_path
pages: ''
negate: false

View file

@ -0,0 +1,9 @@
name: 'Block Content test views'
type: module
description: 'Provides default views for views block_content tests.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- block_content
- views

View file

@ -0,0 +1,234 @@
langcode: en
status: true
dependencies:
module:
- block_content
id: test_block_content_redirect_destination
label: 'Redirect destination'
module: views
description: ''
tag: ''
base_table: block_content_field_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: mini
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:
next:
style:
type: table
options:
grouping: { }
row_class: ''
default_row_class: true
override: true
sticky: false
caption: ''
summary: ''
description: ''
columns:
info: info
info:
info:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
default: '-1'
empty_table: false
row:
type: 'entity:block_content'
fields:
info:
table: block_content_field_data
field: info
id: info
entity_type: null
entity_field: info
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
operations:
id: operations
table: block_content
field: operations
relationship: none
group_type: group
admin_label: ''
label: 'Operations links'
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
destination: true
entity_type: block_content
plugin_id: entity_operations
filters: { }
sorts: { }
title: 'Redirect destination'
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
tags: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
display_extenders: { }
path: /admin/content/redirect_destination
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
tags: { }

View file

@ -0,0 +1,67 @@
langcode: en
status: true
dependencies:
module:
- block_content
id: test_block_content_revision_id
label: null
module: views
description: ''
tag: ''
base_table: block_content_field_revision
base_field: revision_id
core: '8'
display:
default:
display_options:
relationships:
id:
id: id
table: block_content_field_revision
field: id
required: true
plugin_id: standard
fields:
revision_id:
id: revision_id
table: block_content_field_revision
field: revision_id
plugin_id: field
entity_type: block_content
entity_field: revision_id
id_1:
id: id_1
table: block_content_field_revision
field: id
plugin_id: field
entity_type: block_content
entity_field: id
id:
id: id
table: block_content_field_data
field: id
relationship: id
plugin_id: field
entity_type: block_content
entity_field: id
arguments:
id:
id: id
table: block_content_field_revision
field: id
plugin_id: numeric
entity_type: block_content
entity_field: id
sorts:
revision_id:
id: revision_id
table: block_content_field_revision
field: revision_id
order: ASC
plugin_id: field
entity_type: block_content
entity_field: revision_id
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,70 @@
langcode: en
status: true
dependencies:
module:
- block_content
id: test_block_content_revision_revision_id
label: null
module: views
description: ''
tag: ''
base_table: block_content_field_revision
base_field: revision_id
core: '8'
display:
default:
display_options:
relationships:
revision_id:
id: revision_id
table: block_content_field_revision
field: revision_id
required: true
entity_type: block_content
entity_field: revision_id
plugin_id: standard
fields:
revision_id:
id: revision_id
table: block_content_field_revision
field: revision_id
plugin_id: field
entity_type: block_content
entity_field: revision_id
id_1:
id: id_1
table: block_content_field_revision
field: id
plugin_id: field
entity_type: block_content
entity_field: id
id:
id: id
table: block_content_field_data
field: id
relationship: revision_id
plugin_id: field
entity_type: block_content
entity_field: id
arguments:
id:
id: id
table: block_content_field_revision
field: id
plugin_id: block_content_id
entity_type: block_content
entity_field: id
sorts:
revision_id:
id: revision_id
table: block_content_field_revision
field: revision_id
order: ASC
plugin_id: field
entity_type: block_content
entity_field: revision_id
display_extenders: { }
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,192 @@
langcode: en
status: true
dependencies:
module:
- block_content
id: test_block_content_view
label: test_block_content_view
module: views
description: ''
tag: ''
base_table: block_content_field_data
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: null
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
row:
type: fields
fields:
id:
id: id
table: block_content_field_data
field: id
relationship: none
group_type: group
admin_label: ''
label: Id
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
plugin_id: field
entity_type: block_content
entity_field: id
sorts:
id:
id: id
table: block_content_field_data
field: id
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
entity_type: block_content
entity_field: id
plugin_id: standard
title: test_block_content_view
header: { }
footer: { }
empty: { }
relationships: { }
display_extenders: { }
arguments:
type:
id: type
table: block_content_field_data
field: type
relationship: none
group_type: group
admin_label: ''
default_action: 'not found'
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: fixed
default_argument_options:
argument: ''
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
glossary: false
limit: 0
case: none
path_case: none
transform_dash: false
break_phrase: false
entity_type: block_content
entity_field: type
plugin_id: string
page_1:
display_plugin: page
id: page_1
display_title: Page
position: null
display_options:
path: test-block_content-view
display_extenders: { }

View file

@ -0,0 +1,339 @@
langcode: en
status: true
dependencies:
module:
- block_content
id: test_field_filters
label: 'Test field filters'
module: views
description: ''
tag: ''
base_table: block_content_field_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: none
options:
items_per_page: 0
offset: 0
style:
type: default
row:
type: 'entity:block_content'
options:
relationship: none
view_mode: default
fields:
info:
id: info
table: block_content_field_data
field: info
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
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
entity_type: block_content
type: string
settings:
link_to_entity: true
entity_field: title
plugin_id: field
filters:
info:
id: info
table: block_content_field_data
field: info
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Paris
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: block_content
entity_field: info
sorts:
changed:
id: changed
table: block_content_field_data
field: changed
order: DESC
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
plugin_id: date
entity_type: block_content
entity_field: changed
title: 'Test field filters'
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
rendering_language: '***LANGUAGE_entity_translation***'
display_extenders: { }
page_bf:
display_plugin: page
id: page_bf
display_title: 'Body filter page'
position: 1
display_options:
path: test-body-filter
display_description: ''
title: 'Test body filters'
defaults:
title: false
filters: false
filter_groups: false
filters:
body_value:
id: body_value
table: block_content__body
field: body_value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Comida
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: block_content
entity_field: body
filter_groups:
operator: AND
groups:
1: AND
display_extenders: { }
page_bfp:
display_plugin: page
id: page_bfp
display_title: 'Body filter page Paris'
position: 1
display_options:
path: test-body-paris
display_description: ''
title: 'Test body filters'
defaults:
title: false
filters: false
filter_groups: false
filters:
body_value:
id: body_value
table: block_content__body
field: body_value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Paris
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: block_content
entity_field: body
filter_groups:
operator: AND
groups:
1: AND
display_extenders: { }
page_if:
display_plugin: page
id: page_if
display_title: 'Info filter page'
position: 1
display_options:
path: test-info-filter
display_description: ''
title: 'Test info filter'
defaults:
title: false
filters: false
filter_groups: false
filters:
info:
id: info
table: block_content_field_data
field: info
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Comida
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: block_content
entity_field: info
filter_groups:
operator: AND
groups:
1: AND
display_extenders: { }
page_ifp:
display_plugin: page
id: page_ifp
display_title: 'Info filter page Paris'
position: 1
display_options:
path: test-info-paris
display_description: ''
title: 'Test info filter'
defaults:
title: false
display_extenders: { }

View file

@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
module:
- block_content
id: test_field_type
label: ''
module: views
description: ''
tag: ''
base_table: block_content_field_data
base_field: id
core: '8'
display:
default:
display_options:
fields:
type:
field: type
id: type
table: block_content_field_data
plugin_id: field
entity_type: block_content
entity_field: type
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,63 @@
<?php
namespace Drupal\Tests\block_content\Kernel;
use Drupal\block_content\Entity\BlockContent;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Component\Plugin\PluginBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests that deleting a block clears the cached definitions.
*
* @group block_content
*/
class BlockContentDeletionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['block', 'block_content', 'system', 'user'];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->installSchema('system', ['sequence']);
$this->installEntitySchema('user');
$this->installEntitySchema('block_content');
}
/**
* Tests deleting a block_content updates the discovered block plugin.
*/
public function testDeletingBlockContentShouldClearPluginCache() {
// Create a block content type.
$block_content_type = BlockContentType::create([
'id' => 'spiffy',
'label' => 'Mucho spiffy',
'description' => "Provides a block type that increases your site's spiffiness by upto 11%",
]);
$block_content_type->save();
// And a block content entity.
$block_content = BlockContent::create([
'info' => 'Spiffy prototype',
'type' => 'spiffy',
]);
$block_content->save();
// Make sure the block content provides a derivative block plugin in the
// block repository.
/** @var \Drupal\Core\Block\BlockManagerInterface $block_manager */
$block_manager = $this->container->get('plugin.manager.block');
$plugin_id = 'block_content' . PluginBase::DERIVATIVE_SEPARATOR . $block_content->uuid();
$this->assertTrue($block_manager->hasDefinition($plugin_id));
// Now delete the block content entity.
$block_content->delete();
// The plugin should no longer exist.
$this->assertFalse($block_manager->hasDefinition($plugin_id));
}
}

View file

@ -0,0 +1,53 @@
<?php
namespace Drupal\Tests\block_content\Kernel\Migrate;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldConfigInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Attaches a body field to the custom block type.
*
* @group block_content
*/
class MigrateBlockContentBodyFieldTest extends MigrateDrupal7TestBase {
public static $modules = array('block', 'block_content', 'filter', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
$this->executeMigrations([
'block_content_type',
'block_content_body_field',
]);
}
/**
* Tests the block content body field migration.
*/
public function testBlockContentBodyFieldMigration() {
/** @var \Drupal\field\FieldStorageConfigInterface $storage */
$storage = FieldStorageConfig::load('block_content.body');
$this->assertTrue($storage instanceof FieldStorageConfigInterface);
$this->assertIdentical('block_content', $storage->getTargetEntityTypeId());
$this->assertIdentical(['basic'], array_values($storage->getBundles()));
$this->assertIdentical('body', $storage->getName());
/** @var \Drupal\field\FieldConfigInterface $field */
$field = FieldConfig::load('block_content.basic.body');
$this->assertTrue($field instanceof FieldConfigInterface);
$this->assertIdentical('block_content', $field->getTargetEntityTypeId());
$this->assertIdentical('basic', $field->getTargetBundle());
$this->assertIdentical('body', $field->getName());
$this->assertIdentical('Body', $field->getLabel());
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace Drupal\Tests\block_content\Kernel\Migrate;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\migrate\MigrateException;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
use Drupal\migrate_drupal\Tests\StubTestTrait;
/**
* Test stub creation for block_content entities.
*
* @group block_content
*/
class MigrateBlockContentStubTest extends MigrateDrupalTestBase {
use StubTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['block_content'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('block_content');
}
/**
* Tests creation of block content stubs with no block_content_type available.
*/
public function testStubFailure() {
$message = 'Expected MigrateException thrown when no bundles exist.';
try {
$this->createStub('block_content');
$this->fail($message);
}
catch (MigrateException $e) {
$this->pass($message);
$this->assertEqual('Stubbing failed, no bundles available for entity type: block_content', $e->getMessage());
}
}
/**
* Tests creation of block content stubs when there is a block_content_type.
*/
public function testStubSuccess() {
BlockContentType::create([
'id' => 'test_block_content_type',
'label' => 'Test block content type',
])->save();
$this->performStubTest('block_content');
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace Drupal\Tests\block_content\Kernel\Migrate;
use Drupal\block_content\BlockContentTypeInterface;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests migration of the basic block content type.
*
* @group block_content
*/
class MigrateBlockContentTypeTest extends MigrateDrupal7TestBase {
public static $modules = array('block', 'block_content', 'filter', 'text');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
$this->executeMigration('block_content_type');
}
/**
* Tests the block content type migration.
*/
public function testBlockContentTypeMigration() {
/** @var \Drupal\block_content\BlockContentTypeInterface $entity */
$entity = BlockContentType::load('basic');
$this->assertTrue($entity instanceof BlockContentTypeInterface);
$this->assertIdentical('Basic', $entity->label());
}
}

View file

@ -0,0 +1,56 @@
<?php
namespace Drupal\Tests\block_content\Kernel\Migrate\d6;
use Drupal\block_content\Entity\BlockContent;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade custom blocks.
*
* @group migrate_drupal_6
*/
class MigrateBlockContentTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['block', 'block_content'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
$this->executeMigrations([
'd6_filter_format',
'block_content_type',
'block_content_body_field',
'd6_custom_block',
]);
}
/**
* Tests the Drupal 6 custom block to Drupal 8 migration.
*/
public function testBlockMigration() {
/** @var BlockContent $block */
$block = BlockContent::load(1);
$this->assertIdentical('My block 1', $block->label());
$this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
$this->assertIdentical('en', $block->language()->getId());
$this->assertIdentical('<h3>My first custom block body</h3>', $block->body->value);
$this->assertIdentical('full_html', $block->body->format);
$block = BlockContent::load(2);
$this->assertIdentical('My block 2', $block->label());
$this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
$this->assertIdentical('en', $block->language()->getId());
$this->assertIdentical('<h3>My second custom block body</h3>', $block->body->value);
$this->assertIdentical('full_html', $block->body->format);
}
}

View file

@ -0,0 +1,52 @@
<?php
namespace Drupal\Tests\block_content\Kernel\Migrate\d7;
use Drupal\block_content\BlockContentInterface;
use Drupal\block_content\Entity\BlockContent;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests migration of custom blocks.
*
* @group block_content
*/
class MigrateCustomBlockTest extends MigrateDrupal7TestBase {
public static $modules = array(
'block_content',
'filter',
'text',
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(static::$modules);
$this->installEntitySchema('block_content');
$this->executeMigrations([
'd7_filter_format',
'block_content_type',
'block_content_body_field',
'd7_custom_block',
]);
}
/**
* Tests migration of custom blocks from Drupal 7 to Drupal 8.
*/
public function testCustomBlockMigration() {
$block = BlockContent::load(1);
$this->assertTrue($block instanceof BlockContentInterface);
/** @var \Drupal\block_content\BlockContentInterface $block */
$this->assertIdentical('Limerick', $block->label());
$expected_body = "A fellow jumped off a high wall\r\nAnd had a most terrible fall\r\nHe went back to bed\r\nWith a bump on his head\r\nThat's why you don't jump off a wall";
$this->assertIdentical($expected_body, $block->body->value);
$this->assertIdentical('filtered_html', $block->body->format);
}
}

View file

@ -0,0 +1,46 @@
<?php
namespace Drupal\Tests\block_content\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests D6 block boxes source plugin.
*
* @covers \Drupal\block_content\Plugin\migrate\source\d6\Box
* @group block_content
*/
class BoxTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['block_content', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
$tests[0]['source_data']['boxes'] = [
[
'bid' => 1,
'body' => '<p>I made some custom content.</p>',
'info' => 'Static Block',
'format' => 1,
],
[
'bid' => 2,
'body' => '<p>I made some more custom content.</p>',
'info' => 'Test Content',
'format' => 1,
],
];
// The expected results are identical to the source data.
$tests[0]['expected_data'] = $tests[0]['source_data']['boxes'];
return $tests;
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\block_content\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests d7_block_custom source plugin.
*
* @covers \Drupal\block_content\Plugin\migrate\source\d7\BlockCustom
* @group block_content
*/
class BlockCustomTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['block_content', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
$tests[0]['source_data']['block_custom'] = [
[
'bid' => '1',
'body' => "I don't feel creative enough to write anything clever here.",
'info' => 'Meh',
'format' => 'filtered_html',
],
];
// The expected results are identical to the source data.
$tests[0]['expected_data'] = $tests[0]['source_data']['block_custom'];
return $tests;
}
}

View file

@ -0,0 +1,80 @@
<?php
namespace Drupal\Tests\block_content\Unit\Menu;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Tests existence of block_content local tasks.
*
* @group block_content
*/
class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
$this->directoryList = array(
'block' => 'core/modules/block',
'block_content' => 'core/modules/block_content',
);
parent::setUp();
$config_factory = $this->getConfigFactoryStub(array('system.theme' => array(
'default' => 'test_c',
)));
$themes = array();
$themes['test_a'] = (object) array(
'status' => 0,
);
$themes['test_b'] = (object) array(
'status' => 1,
'info' => array(
'name' => 'test_b',
),
);
$themes['test_c'] = (object) array(
'status' => 1,
'info' => array(
'name' => 'test_c',
),
);
$theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler->expects($this->any())
->method('listInfo')
->will($this->returnValue($themes));
$container = new ContainerBuilder();
$container->set('config.factory', $config_factory);
$container->set('theme_handler', $theme_handler);
\Drupal::setContainer($container);
}
/**
* Checks block_content listing local tasks.
*
* @dataProvider getBlockContentListingRoutes
*/
public function testBlockContentListLocalTasks($route) {
$this->assertLocalTasks($route, array(
0 => array(
'block.admin_display',
'entity.block_content.collection',
),
1 => array(
'block_content.list_sub',
'entity.block_content_type.collection',
),
));
}
/**
* Provides a list of routes to test.
*/
public function getBlockContentListingRoutes() {
return array(
array('entity.block_content.collection', 'entity.block_content_type.collection'),
);
}
}