Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
custom_elements
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
custom_elements
Commits
f7a0f899
Commit
f7a0f899
authored
3 months ago
by
Roderik Muit
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3500903
by roderik: PHPUnit failure
parent
919caba3
No related branches found
No related tags found
1 merge request
!113
Create config entities through Entity API
Pipeline
#401681
passed with warnings
3 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Functional/CustomElementsRenderMarkupTest.php
+25
-20
25 additions, 20 deletions
tests/src/Functional/CustomElementsRenderMarkupTest.php
with
25 additions
and
20 deletions
tests/src/Functional/CustomElementsRenderMarkupTest.php
+
25
−
20
View file @
f7a0f899
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\Tests\custom_elements\Functional
;
use
Drupal\Core\Config\FileStorage
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\custom_elements
\CustomElement
;
use
Drupal\custom_elements
\CustomElementGeneratorTrait
;
...
...
@@ -9,7 +10,6 @@ use Drupal\file\Entity\File;
use
Drupal\media\Entity\Media
;
use
Drupal\node\Entity\Node
;
use
Drupal\paragraphs\Entity\Paragraph
;
use
Symfony\Component\Yaml\Parser
;
/**
* Test rendering custom elements into markup.
...
...
@@ -126,28 +126,33 @@ class CustomElementsRenderMarkupTest extends BrowserTestBase {
private
function
importPartialThunderConfig
(
array
$exclude_bundles
)
{
$config_dir
=
dirname
(
dirname
(
dirname
(
__DIR__
)))
.
'/modules/custom_elements_thunder/config/install'
;
// Avoid warnings when opendir does not have the permissions to open a
// directory.
if
(
$handle
=
opendir
(
$config_dir
))
{
while
(
FALSE
!==
(
$filename
=
readdir
(
$handle
)))
{
if
(
str_ends_with
(
$filename
,
'.yml'
)
&&
!
array_filter
(
$source
=
new
FileStorage
(
$config_dir
);
// Get config names that do not contain any of $exclude_bundles.
$config_names
=
array_filter
(
$source
->
listAll
(),
function
(
$config_name
)
use
(
$exclude_bundles
)
{
// Return boolean indicating config name contains any of $exclude.
return
!
array_filter
(
$exclude_bundles
,
function
(
$bundle
)
use
(
$
file
name
)
{
return
str_contains
(
$
file
name
,
$bundle
);
function
(
$bundle
)
use
(
$
config_
name
)
{
return
str_contains
(
$
config_
name
,
$bundle
);
}
))
{
$config_name
=
substr
(
$filename
,
0
,
strlen
(
$filename
)
-
4
);
$data
=
file_get_contents
(
"
$config_dir
/
$filename
"
);
$parser
=
new
Parser
();
$data
=
$parser
->
parse
(
$data
);
$config
=
\Drupal
::
configFactory
()
->
getEditable
(
$config_name
);
foreach
(
$data
as
$data_key
=>
$value
)
{
$config
->
set
(
$data_key
,
$value
);
}
$config
->
save
();
}
);
}
);
foreach
(
$config_names
as
$config_name
)
{
// Use the entity API to create config entities.
$entity_type_id
=
\Drupal
::
service
(
'config.manager'
)
->
getEntityTypeIdByName
(
$config_name
);
if
(
$entity_type_id
)
{
\Drupal
::
entityTypeManager
()
->
getStorage
(
$entity_type_id
)
->
create
(
$source
->
read
(
$config_name
))
->
save
();
}
else
{
\Drupal
::
service
(
'config.storage'
)
->
write
(
$config_name
,
$source
->
read
(
$config_name
));
}
closedir
(
$handle
);
}
}
...
...
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