Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ui_patterns
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
ui_patterns
Commits
a2bb992e
Commit
a2bb992e
authored
4 months ago
by
Mikael Meulle
Browse files
Options
Downloads
Plain Diff
Merge branch '3467653-2.0.0-beta2-blocks-tests' into '2.0.x'
Resolve
#3467653
"2.0.0 beta2 blocks tests" See merge request
!302
parents
507b19c7
aedfdc12
No related branches found
No related tags found
No related merge requests found
Pipeline
#372371
passed
4 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/ui_patterns_blocks/tests/Kernel/SourcesDeriverTest.php
+78
-0
78 additions, 0 deletions
...es/ui_patterns_blocks/tests/Kernel/SourcesDeriverTest.php
with
78 additions
and
0 deletions
modules/ui_patterns_blocks/tests/Kernel/SourcesDeriverTest.php
0 → 100644
+
78
−
0
View file @
a2bb992e
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\Tests\ui_patterns_blocks\Kernel
;
use
Drupal\Tests\ui_patterns
\Kernel\SourcePluginsTestBase
;
use
Drupal\ui_patterns_blocks
\Plugin\Block\ComponentBlock
;
use
Drupal\ui_patterns_blocks
\Plugin\Block\EntityComponentBlock
;
/**
* Tests UI patterns block plugin deriver.
*
* @group ui_patterns_blocks
*/
class
SourcesDeriverTest
extends
SourcePluginsTestBase
{
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'ui_patterns'
,
'ui_patterns_test'
,
'ui_patterns_blocks'
];
/**
* {@inheritdoc}
*/
protected
$strictConfigSchema
=
FALSE
;
/**
* The layout plugin manager.
*
* @var \Drupal\Core\Block\BlockManagerInterface
*/
protected
$blockManager
;
/**
* The component plugin manager.
*
* @var \Drupal\Core\Theme\ComponentPluginManager
*/
protected
$componentManager
;
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
blockManager
=
$this
->
container
->
get
(
'plugin.manager.block'
);
$this
->
componentManager
=
$this
->
container
->
get
(
'plugin.manager.sdc'
);
}
/**
* Tests creating fields of all types on a content type.
*/
public
function
testDerivedPluginPerComponent
()
{
/* @phpstan-ignore method.notFound */
$components
=
$this
->
componentManager
->
getSortedDefinitions
();
foreach
(
$components
as
$component
)
{
$id
=
(
string
)
$component
[
'id'
];
$block_plugin_id
=
sprintf
(
'ui_patterns:%s'
,
$id
);
$block
=
$this
->
blockManager
->
createInstance
(
$block_plugin_id
);
$this
->
assertNotNull
(
$block
,
"Block for component
{
$component
[
'id'
]
}
is missing"
);
$this
->
assertInstanceOf
(
ComponentBlock
::
class
,
$block
,
get_class
(
$block
)
.
" "
.
$component
[
'id'
]
.
" "
.
print_r
(
$this
->
blockManager
->
getDefinitions
(),
TRUE
));
$block_plugin_id
=
sprintf
(
'ui_patterns_entity:%s'
,
$id
);
$block
=
$this
->
blockManager
->
createInstance
(
$block_plugin_id
);
$this
->
assertNotNull
(
$block
,
"Block with entity context for component
{
$component
[
'id'
]
}
is missing"
);
$this
->
assertInstanceOf
(
EntityComponentBlock
::
class
,
$block
);
$plugin_definition
=
$block
->
getPluginDefinition
()
??
[];
if
(
!
is_array
(
$plugin_definition
))
{
$plugin_definition
=
[];
}
$context_definitions
=
$plugin_definition
[
'context_definitions'
]
??
[];
$this
->
assertArrayHasKey
(
'entity'
,
$context_definitions
);
}
}
}
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