Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
be82cf3b
Commit
be82cf3b
authored
12 years ago
by
Daniel Wehner
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1778066
by dawehner: Fixed Test entity integration into fields.
parent
601c922f
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Drupal/views/Tests/Entity/FieldEntityTest.php
+62
-0
62 additions, 0 deletions
lib/Drupal/views/Tests/Entity/FieldEntityTest.php
tests/views_test_config/config/views.view.test_field_get_entity.yml
+63
-0
63 additions, 0 deletions
...s_test_config/config/views.view.test_field_get_entity.yml
with
125 additions
and
0 deletions
lib/Drupal/views/Tests/Entity/FieldEntityTest.php
0 → 100644
+
62
−
0
View file @
be82cf3b
<?php
/**
* @file
* Definition of Drupal\views\Tests\Entity\FieldEntityTest.
*/
namespace
Drupal\views\Tests\Entity
;
use
Drupal\views\Tests\ViewTestBase
;
/**
* Tests the field plugin base integration with the entity system.
*/
class
FieldEntityTest
extends
ViewTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'comment'
);
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Field: Entity Api Integration'
,
'description'
=>
'Tests the field plugin base integration with the entity system.'
,
'group'
=>
'Views Modules'
,
);
}
/**
* Tests the get_entity method.
*/
public
function
testGetEntity
()
{
// The view is a view of comments, their nodes and their authors, so there
// are three layers of entities.
$account
=
entity_create
(
'user'
,
array
(
'name'
=>
$this
->
randomName
(),
'bundle'
=>
'user'
));
$account
->
save
();
$node
=
entity_create
(
'node'
,
array
(
'uid'
=>
$account
->
id
(),
'type'
=>
'page'
));
$node
->
save
();
$comment
=
entity_create
(
'comment'
,
array
(
'uid'
=>
$account
->
id
(),
'nid'
=>
$node
->
id
(),
'node_type'
=>
'comment_node_page'
));
$comment
->
save
();
$view
=
views_get_view
(
'test_field_get_entity'
);
$this
->
executeView
(
$view
);
$row
=
$view
->
result
[
0
];
// Tests entities on the base level.
$entity
=
$view
->
field
[
'cid'
]
->
get_entity
(
$row
);
$this
->
assertEqual
(
$entity
->
id
(),
$comment
->
id
(),
'Make sure the right comment entity got loaded.'
);
// Tests entities as relationship on first level.
$entity
=
$view
->
field
[
'nid'
]
->
get_entity
(
$row
);
$this
->
assertEqual
(
$entity
->
id
(),
$node
->
id
(),
'Make sure the right node entity got loaded.'
);
// Tests entities as relationships on second level.
$entity
=
$view
->
field
[
'uid'
]
->
get_entity
(
$row
);
$this
->
assertEqual
(
$entity
->
id
(),
$account
->
id
(),
'Make sure the right user entity got loaded.'
);
}
}
This diff is collapsed.
Click to expand it.
tests/views_test_config/config/views.view.test_field_get_entity.yml
0 → 100644
+
63
−
0
View file @
be82cf3b
api_version
:
'
3.0'
base_table
:
comment
core
:
8.0-dev
description
:
'
'
disabled
:
'
0'
display
:
default
:
display_options
:
access
:
type
:
perm
cache
:
type
:
none
exposed_form
:
type
:
basic
fields
:
cid
:
field
:
cid
id
:
cid
table
:
comment
nid
:
field
:
nid
id
:
nid
table
:
node
relationship
:
nid
uid
:
field
:
uid
id
:
uid
table
:
users
relationship
:
uid
filter_groups
:
groups
:
{
}
operator
:
AND
filters
:
{
}
pager
:
type
:
full
query
:
type
:
views_query
relationships
:
nid
:
field
:
nid
id
:
nid
required
:
'
1'
table
:
comment
uid
:
admin_label
:
'
'
field
:
uid
group_type
:
group
id
:
uid
label
:
author
relationship
:
nid
required
:
'
0'
table
:
node
row_plugin
:
fields
sorts
:
{
}
style_plugin
:
default
display_plugin
:
default
display_title
:
Master
id
:
default
position
:
'
0'
human_name
:
test_field_get_entity
name
:
test_field_get_entity
tag
:
default
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment