-
Notifications
You must be signed in to change notification settings - Fork 16
Referencing a different entity type is broken in the complex widget #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
amitaibu
merged 12 commits into
amitaibu:8.x-1.x
from
ec-europa:OgComplexWidget-target_type
Mar 31, 2016
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
54feb51
$this->fieldDefinition->getTargetEntityTypeId() returns the type of t…
idimopoulos db7683c
More target_type fixes in OgComplex.
pfrenssen 316e85b
Fix failing test.
pfrenssen 030a930
The target entity type is defined in the field storage.
pfrenssen 58a7b55
Handler settings are defined on the field, not on the field storage.
pfrenssen 17f19ac
Update test. Target types are defined in field storage, not in the fi…
pfrenssen 812af86
Merge remote-tracking branch 'origin/8.x-1.x' into OgComplexWidget-ta…
pfrenssen 8d8f0b0
Add a test (WIP).
pfrenssen 143d6f6
Merge branch '8.x-1.x' into OgComplexWidget-target_type
pfrenssen 8607613
Correctly save the target type on field storage.
pfrenssen beb5bec
Test the Groups Audience field in addition to the Other Groups field.
pfrenssen 43fca11
Test that the group target type is correctly saved when creating a gr…
pfrenssen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ class BundleFormAlterTest extends BrowserTestBase { | |
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public static $modules = ['entity_test', 'node', 'og_ui']; | ||
| public static $modules = ['block_content', 'entity_test', 'node', 'og_ui']; | ||
|
|
||
| /** | ||
| * An administrator user. | ||
|
|
@@ -53,34 +53,42 @@ public function setUp() { | |
|
|
||
| $this->entityTypeManager = \Drupal::entityTypeManager(); | ||
|
|
||
| // Log in as an administrator that can manage content types. | ||
| $this->adminUser = $this->drupalCreateUser(array('bypass node access', 'administer content types')); | ||
| // Log in as an administrator that can manage blocks and content types. | ||
| $this->adminUser = $this->drupalCreateUser([ | ||
| 'administer blocks', | ||
| 'administer content types', | ||
| 'bypass node access', | ||
| ]); | ||
| $this->drupalLogin($this->adminUser); | ||
| } | ||
|
|
||
| /** | ||
| * Test that group and group content bundles can be created through the UI. | ||
| */ | ||
| public function testCreate() { | ||
| // Create a custom block and define it as a group type. We make sure the | ||
| // group and group content are of different entity types so we can test that | ||
| // the correct entity type is referenced. | ||
| $edit = [ | ||
| 'name' => 'school', | ||
| 'type' => 'school', | ||
| 'label' => 'school', | ||
| 'id' => 'school', | ||
| 'og_is_group' => 1, | ||
| ]; | ||
| $this->drupalGet('admin/structure/types/add'); | ||
| $this->submitForm($edit, t('Save content type')); | ||
| $this->drupalGet('admin/structure/block/block-content/types/add'); | ||
| $this->submitForm($edit, t('Save')); | ||
|
|
||
| $edit = [ | ||
| 'name' => 'class', | ||
| 'type' => 'class', | ||
| 'og_group_content_bundle' => 1, | ||
| 'og_target_type' => 'node', | ||
| 'og_target_type' => 'block_content', | ||
| 'og_target_bundles[]' => ['school'], | ||
| ]; | ||
| $this->drupalGet('admin/structure/types/add'); | ||
| $this->submitForm($edit, t('Save content type')); | ||
| $this->content = $this->drupalGet('admin/structure/types/manage/class'); | ||
| $this->assertOptionSelected('edit-og-target-bundles', 'school'); | ||
| $this->assertTargetType('block_content', 'The target type is set to the "Custom Block" entity type.'); | ||
| $this->assertTargetBundles(['school' => 'school'], 'The target bundles are set to the "school" bundle.'); | ||
|
|
||
| // Test that if the target bundles are unselected, the value for the target | ||
|
|
@@ -91,7 +99,7 @@ public function testCreate() { | |
| $edit = [ | ||
| 'name' => 'class', | ||
| 'og_group_content_bundle' => 1, | ||
| 'og_target_type' => 'node', | ||
| 'og_target_type' => 'block_content', | ||
| 'og_target_bundles[]' => [], | ||
| ]; | ||
| $this->drupalGet('admin/structure/types/manage/class'); | ||
|
|
@@ -127,7 +135,7 @@ public function testGroupContentAjax() { | |
| * | ||
| * @param array|NULL $expected | ||
| * The expected value for the target bundles. | ||
| * @param $message | ||
| * @param string $message | ||
| * The message to display with the assertion. | ||
| */ | ||
| protected function assertTargetBundles($expected, $message) { | ||
|
|
@@ -139,4 +147,21 @@ protected function assertTargetBundles($expected, $message) { | |
| $this->assertEquals($expected, $settings['target_bundles'], $message); | ||
| } | ||
|
|
||
| /** | ||
| * Checks whether the target entity type in the group content is as expected. | ||
| * | ||
| * @param string $expected | ||
| * The expected target entity type. | ||
| * @param string $message | ||
| * The message to display with the assertion. | ||
| */ | ||
| protected function assertTargetType($expected, $message) { | ||
| /** @var EntityFieldManagerInterface $entity_field_manager */ | ||
| $entity_field_manager = $this->container->get('entity_field.manager'); | ||
| $entity_field_manager->clearCachedFieldDefinitions(); | ||
| $field_definitions = $entity_field_manager->getFieldStorageDefinitions('node'); | ||
| $setting = $field_definitions['og_group_ref']->getSetting('target_type'); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually prefer to avoid hardcoding |
||
| $this->assertEquals($expected, $setting, $message); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, couldn't hold myself :)
where in the UI to you see the posibility to change the target type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see
I'll open a follow up issue