Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
a039a98a
Commit
a039a98a
authored
Feb 07, 2013
by
catch
Browse files
Issue
#1906794
by dawehner: Fixed Using a relationship in the UI fails completly.
parent
8b8eaa3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/modules/views/lib/Drupal/views/Tests/UI/HandlerTest.php
View file @
a039a98a
...
...
@@ -21,7 +21,7 @@ class HandlerTest extends UITestBase {
*
* @var array
*/
public
static
$testViews
=
array
(
'test_view'
);
public
static
$testViews
=
array
(
'test_view
_empty
'
);
public
static
function
getInfo
()
{
return
array
(
...
...
@@ -31,6 +31,45 @@ public static function getInfo() {
);
}
/**
* Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
*
* Adds a uid column to test the relationships.
*/
protected
function
schemaDefinition
()
{
$schema
=
parent
::
schemaDefinition
();
$schema
[
'views_test_data'
][
'fields'
][
'uid'
]
=
array
(
'description'
=>
"The
{
users
}
.uid of the author of the beatle entry."
,
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
,
'default'
=>
0
);
return
$schema
;
}
/**
* Overrides \Drupal\views\Tests\ViewTestBase::viewsData().
*
* Adds a relationship for the uid column.
*/
protected
function
viewsData
()
{
$data
=
parent
::
viewsData
();
$data
[
'views_test_data'
][
'uid'
]
=
array
(
'title'
=>
t
(
'UID'
),
'help'
=>
t
(
'The test data UID'
),
'relationship'
=>
array
(
'id'
=>
'standard'
,
'base'
=>
'users'
,
'base field'
=>
'uid'
)
);
return
$data
;
}
/**
* Tests UI CRUD.
*/
...
...
@@ -38,32 +77,70 @@ public function testUICRUD() {
$handler_types
=
ViewExecutable
::
viewsHandlerTypes
();
foreach
(
$handler_types
as
$type
=>
$type_info
)
{
// Test adding handlers.
$add_handler_url
=
"admin/structure/views/nojs/add-item/test_view/default/
$type
"
;
$add_handler_url
=
"admin/structure/views/nojs/add-item/test_view
_empty
/default/
$type
"
;
// Area handler types need to use a different handler.
if
(
in_array
(
$type
,
array
(
'header'
,
'footer'
,
'empty'
)))
{
$this
->
drupalPost
(
$add_handler_url
,
array
(
'name[views.area]'
=>
TRUE
),
t
(
'Add and configure @handler'
,
array
(
'@handler'
=>
$type_info
[
'ltitle'
])));
$edit_handler_url
=
"admin/structure/views/nojs/config-item/test_view/default/
$type
/area"
;
$id
=
'area'
;
$edit_handler_url
=
"admin/structure/views/nojs/config-item/test_view_empty/default/
$type
/
$id
"
;
}
elseif
(
$type
==
'relationship'
)
{
// @todo Add a views_test_data relationship handler to test.
continue
;
$this
->
drupalPost
(
$add_handler_url
,
array
(
'name[views_test_data.uid]'
=>
TRUE
),
t
(
'Add and configure @handler'
,
array
(
'@handler'
=>
$type_info
[
'ltitle'
])));
$id
=
'uid'
;
$edit_handler_url
=
"admin/structure/views/nojs/config-item/test_view_empty/default/
$type
/
$id
"
;
}
else
{
$this
->
drupalPost
(
$add_handler_url
,
array
(
'name[views_test_data.job]'
=>
TRUE
),
t
(
'Add and configure @handler'
,
array
(
'@handler'
=>
$type_info
[
'ltitle'
])));
$edit_handler_url
=
"admin/structure/views/nojs/config-item/test_view/default/
$type
/job"
;
$id
=
'job'
;
$edit_handler_url
=
"admin/structure/views/nojs/config-item/test_view_empty/default/
$type
/
$id
"
;
}
$this
->
assertUrl
(
$edit_handler_url
,
array
(),
'The user got redirected to the handler edit form.'
);
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Apply'
));
$this
->
assertUrl
(
'admin/structure/views/view/test_view/edit'
,
array
(),
'The user got redirected to the views edit form.'
);
$this
->
assertUrl
(
'admin/structure/views/view/test_view
_empty
/edit'
,
array
(),
'The user got redirected to the views edit form.'
);
$this
->
assertLinkByHref
(
$edit_handler_url
,
0
,
'The handler edit link appears in the UI.'
);
// Save the view and have a look whether the handler was added as expected.
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Save'
));
$views
=
$this
->
container
->
get
(
'plugin.manager.entity'
)
->
getStorageController
(
'view'
)
->
load
(
array
(
'test_view_empty'
));
$view
=
reset
(
$views
);
$display
=
$view
->
getDisplay
(
'default'
);
$this
->
assertTrue
(
isset
(
$display
[
'display_options'
][
$type_info
[
'plural'
]][
$id
]),
'Ensure the field was added to the view itself.'
);
// Remove the item and check that it's removed
$this
->
drupalPost
(
$edit_handler_url
,
array
(),
t
(
'Remove'
));
$this
->
assertNoLinkByHref
(
$edit_handler_url
,
0
,
'The handler edit link does not appears in the UI after removing.'
);
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Save'
));
$views
=
$this
->
container
->
get
(
'plugin.manager.entity'
)
->
getStorageController
(
'view'
)
->
load
(
array
(
'test_view_empty'
));
$view
=
reset
(
$views
);
$display
=
$view
->
getDisplay
(
'default'
);
$this
->
assertFalse
(
isset
(
$display
[
'display_options'
][
$type_info
[
'plural'
]][
$id
]),
'Ensure the field was removed from the view itself.'
);
}
// Test adding a field of the user table using the uid relationship.
$type_info
=
$handler_types
[
'relationship'
];
$add_handler_url
=
"admin/structure/views/nojs/add-item/test_view_empty/default/relationship"
;
$this
->
drupalPost
(
$add_handler_url
,
array
(
'name[views_test_data.uid]'
=>
TRUE
),
t
(
'Add and configure @handler'
,
array
(
'@handler'
=>
$type_info
[
'ltitle'
])));
$add_handler_url
=
"admin/structure/views/nojs/add-item/test_view_empty/default/field"
;
$type_info
=
$handler_types
[
'field'
];
$this
->
drupalPost
(
$add_handler_url
,
array
(
'name[users.signature]'
=>
TRUE
),
t
(
'Add and configure @handler'
,
array
(
'@handler'
=>
$type_info
[
'ltitle'
])));
$id
=
'signature'
;
$edit_handler_url
=
"admin/structure/views/nojs/config-item/test_view_empty/default/field/
$id
"
;
$this
->
assertUrl
(
$edit_handler_url
,
array
(),
'The user got redirected to the handler edit form.'
);
$this
->
assertFieldByName
(
'options[relationship]'
,
'uid'
,
'Ensure the relationship select is filled with the UID relationship.'
);
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Apply'
));
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Save'
));
$views
=
$this
->
container
->
get
(
'plugin.manager.entity'
)
->
getStorageController
(
'view'
)
->
load
(
array
(
'test_view_empty'
));
$view
=
reset
(
$views
);
$display
=
$view
->
getDisplay
(
'default'
);
$this
->
assertTrue
(
isset
(
$display
[
'display_options'
][
$type_info
[
'plural'
]][
$id
]),
'Ensure the field was added to the view itself.'
);
}
}
core/modules/views/tests/views_test_config/test_views/views.view.test_view_empty.yml
0 → 100644
View file @
a039a98a
base_table
:
views_test_data
core
:
'
8'
description
:
'
'
disabled
:
'
0'
display
:
default
:
display_options
:
defaults
:
fields
:
'
0'
pager
:
'
0'
pager_options
:
'
0'
sorts
:
'
0'
fields
:
id
:
field
:
id
id
:
id
relationship
:
none
table
:
views_test_data
plugin_id
:
numeric
pager
:
options
:
offset
:
'
0'
type
:
none
pager_options
:
{
}
display_plugin
:
default
display_title
:
Master
id
:
default
position
:
'
0'
human_name
:
'
'
id
:
test_view_empty
tag
:
'
'
core/modules/views/views_ui/admin.inc
View file @
a039a98a
...
...
@@ -1410,6 +1410,7 @@ function views_ui_config_item_form($form, &$form_state) {
),
);
$executable
=
$view
->
get
(
'executable'
);
$save_ui_cache
=
FALSE
;
if
(
!
$executable
->
setDisplay
(
$display_id
))
{
views_ajax_error
(
t
(
'Invalid display id @display'
,
array
(
'@display'
=>
$display_id
)));
}
...
...
@@ -1471,7 +1472,7 @@ function views_ui_config_item_form($form, &$form_state) {
// We want this relationship option to get saved even if the user
// skips submitting the form.
$executable
->
setItemOption
(
$display_id
,
$type
,
$id
,
'relationship'
,
$rel
);
views
_ui_cache
_set
(
$view
)
;
$save
_ui_cache
=
TRUE
;
}
$form
[
'options'
][
'relationship'
]
=
array
(
...
...
@@ -1518,6 +1519,10 @@ function views_ui_config_item_form($form, &$form_state) {
$form
[
'buttons'
][
'remove'
][
'#limit_validation_errors'
]
=
array
(
array
(
'override'
));
}
if
(
$save_ui_cache
)
{
views_ui_cache_set
(
$view
);
}
return
$form
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment