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
f72f03bb
Unverified
Commit
f72f03bb
authored
5 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Issue
#3041778
by claudiu.cristea: Convert FilterEntityBundleTest into a kernel test"
This reverts commit
b12561bd
.
parent
98227b9d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/views/tests/src/Functional/Entity/FilterEntityBundleTest.php
+48
-24
48 additions, 24 deletions
...ws/tests/src/Functional/Entity/FilterEntityBundleTest.php
with
48 additions
and
24 deletions
core/modules/views/tests/src/
Kerne
l/Entity/FilterEntityBundleTest.php
→
core/modules/views/tests/src/
Functiona
l/Entity/FilterEntityBundleTest.php
+
48
−
24
View file @
f72f03bb
<?php
namespace
Drupal\Tests\views\
Kerne
l\Entity
;
namespace
Drupal\Tests\views\
Functiona
l\Entity
;
use
Drupal\node\Entity\Node
;
use
Drupal\
node\Entity\NodeTyp
e
;
use
Drupal\
Tests\views\Kernel\ViewsKernelTestBase
;
use
Drupal\
Tests\views\Functional\ViewTestBas
e
;
use
Drupal\
views\Tests\ViewTestData
;
use
Drupal\views\Views
;
/**
...
...
@@ -12,32 +12,49 @@
*
* @group views
*/
class
FilterEntityBundleTest
extends
View
sKernel
TestBase
{
class
FilterEntityBundleTest
extends
ViewTestBase
{
/**
* {@inheritdoc}
* Views used by this test.
*
* @var array
*/
public
static
$testViews
=
[
'test_entity_type_filter'
];
/**
* {@inheritdoc}
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
[
'node'
];
/**
* Tests the generic bundle filter.
* Entity bundle data.
*
* @var array
*/
public
function
testFilterEntity
()
{
$this
->
installEntitySchema
(
'user'
);
$this
->
installEntitySchema
(
'node'
);
NodeType
::
create
([
'type'
=>
'test_bundle'
])
->
save
();
NodeType
::
create
([
'type'
=>
'test_bundle_2'
])
->
save
();
protected
$entityBundles
;
/**
* An array of entities.
*
* @var array
*/
protected
$entities
=
[];
protected
function
setUp
(
$import_test_views
=
TRUE
)
{
parent
::
setUp
(
FALSE
);
$this
->
drupalCreateContentType
([
'type'
=>
'test_bundle'
]);
$this
->
drupalCreateContentType
([
'type'
=>
'test_bundle_2'
]);
ViewTestData
::
createTestViews
(
get_class
(
$this
),
[
'views_test_config'
]);
$
bundle_info
=
$this
->
container
->
get
(
'entity_type.bundle.info'
)
->
getBundleInfo
(
'node'
);
$
this
->
entityBundles
=
$this
->
container
->
get
(
'entity_type.bundle.info'
)
->
getBundleInfo
(
'node'
);
$entities
[
'count'
]
=
0
;
$
this
->
entities
[
'count'
]
=
0
;
foreach
(
$
bundle_info
as
$key
=>
$info
)
{
foreach
(
$
this
->
entityBundles
as
$key
=>
$info
)
{
for
(
$i
=
0
;
$i
<
5
;
$i
++
)
{
$entity
=
Node
::
create
([
'title'
=>
$this
->
randomString
(),
...
...
@@ -45,10 +62,16 @@ public function testFilterEntity() {
'type'
=>
$key
,
]);
$entity
->
save
();
$entities
[
$key
][
$entity
->
id
()]
=
$entity
;
$entities
[
'count'
]
++
;
$
this
->
entities
[
$key
][
$entity
->
id
()]
=
$entity
;
$
this
->
entities
[
'count'
]
++
;
}
}
}
/**
* Tests the generic bundle filter.
*/
public
function
testFilterEntity
()
{
$view
=
Views
::
getView
(
'test_entity_type_filter'
);
// Tests \Drupal\views\Plugin\views\filter\Bundle::calculateDependencies().
...
...
@@ -61,24 +84,25 @@ public function testFilterEntity() {
'node'
,
],
];
$this
->
assert
Same
(
$expected
,
$view
->
getDependencies
());
$this
->
assert
Identical
(
$expected
,
$view
->
getDependencies
());
$this
->
executeView
(
$view
);
// Test we have all the results, with all types selected.
$this
->
assert
Count
(
$
entities
[
'count'
]
,
$view
->
result
);
$this
->
assert
Equal
(
count
(
$view
->
result
),
$this
->
entities
[
'count'
]);
// Test the valueOptions of the filter handler.
$expected
=
[];
foreach
(
$bundle_info
as
$key
=>
$info
)
{
foreach
(
$this
->
entityBundles
as
$key
=>
$info
)
{
$expected
[
$key
]
=
$info
[
'label'
];
}
$this
->
assert
Same
(
$expected
,
$view
->
filter
[
'type'
]
->
getValueOptions
());
$this
->
assert
Identical
(
$view
->
filter
[
'type'
]
->
getValueOptions
()
,
$expected
);
$view
->
destroy
();
// Test each bundle type.
foreach
(
$
bundle_info
as
$key
=>
$info
)
{
foreach
(
$
this
->
entityBundles
as
$key
=>
$info
)
{
// Test each bundle type.
$view
->
initDisplay
();
$filters
=
$view
->
display_handler
->
getOption
(
'filters'
);
...
...
@@ -86,7 +110,7 @@ public function testFilterEntity() {
$view
->
display_handler
->
setOption
(
'filters'
,
$filters
);
$this
->
executeView
(
$view
);
$this
->
assert
Count
(
count
(
$entities
[
$key
])
,
$view
->
result
);
$this
->
assert
Equal
(
count
(
$view
->
result
),
count
(
$
this
->
entities
[
$key
]));
$view
->
destroy
();
}
...
...
@@ -98,7 +122,7 @@ public function testFilterEntity() {
$view
->
display_handler
->
setOption
(
'filters'
,
$filters
);
$this
->
executeView
(
$view
);
$this
->
assertE
mpty
(
$view
->
result
);
$this
->
assertE
qual
(
count
(
$view
->
result
)
,
0
)
;
}
}
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