100 lines
No EOL
6.6 KiB
JSON
100 lines
No EOL
6.6 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "2ce56fae-e16d-4ff5-a13e-2a0d766924f6"
|
|
}
|
|
],
|
|
"langcode": [
|
|
{
|
|
"value": "en"
|
|
}
|
|
],
|
|
"type": [
|
|
{
|
|
"target_id": "daily_email",
|
|
"target_type": "node_type",
|
|
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
|
}
|
|
],
|
|
"revision_timestamp": [
|
|
{
|
|
"value": "2025-04-21T01:21:38+00:00"
|
|
}
|
|
],
|
|
"revision_uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"revision_log": [],
|
|
"status": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"uid": [
|
|
{
|
|
"target_type": "user",
|
|
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
|
|
}
|
|
],
|
|
"title": [
|
|
{
|
|
"value": "Another way to create test module configuration"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2024-02-17T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-04-21T01:21:38+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2024\/02\/17\/another-way-to-create-test-module-configuration",
|
|
"langcode": "en"
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>In one of the lessons in my <a href=\"https:\/\/www.oliverdavies.uk\/atdc\">free automated testing in Drupal email course<\/a>, I explain how I create configuration that I need within my tests, such as adding a custom field:<\/p>\n\n<blockquote>\n <p>But how do you know what to name the configuration files and what content to put in them?<\/p>\n \n <p>Rather than trying to write them by hand, I create the configuration I need, such as fields, within a Drupal site and then export and edit the files I need.<\/p>\n<\/blockquote>\n\n<p>As well as creating the fields in the Drupal UI, I was also using it to export the configuration files I needed:<\/p>\n\n<blockquote>\n <p>Once Drupal is installed and the configuration has been created, you can go to - \/admin\/config\/development\/configuration\/single\/export and select the configuration type and name.<\/p>\n \n <p>The filename is shown at the bottom of the page, and you can copy the content into files within your module.<\/p>\n<\/blockquote>\n\n<h2 id=\"there%27s-another-way\">There's another way<\/h2>\n\n<p>After reading that lesson, somene replied and reminded me that there's a <code>--destination<\/code> option you can use with the <code>drush config:export<\/code> command.<\/p>\n\n<p>Instead of exporting to the standard configuration directory, I can do it to a temporary directory:<\/p>\n\n<pre><code class=\"language-shell\">run drush cex --destination \/app\/.ignored\/config\n<\/code><\/pre>\n\n<p>Everyhing in a <code>.ignored<\/code> direcotry is automatically ignored by Git, and to get the files I need, I can use Linux's <code>find<\/code> command to find any files that contain the field name and copy them into my test module directory:<\/p>\n\n<pre><code class=\"language-shell\">find .ignored\/config \\\n -type f \\\n -name \\*drupal_project\\* \\\n -exec cp -r {} web\/modules\/custom\/foo\/modules\/foo_test\/config\/install \\;\n<\/code><\/pre>\n\n<p>I still need to edit the files to remove the <code>uuid<\/code> and <code>_core<\/code> values, but this approach means less clicking in the Drupal UI which makes me more productive.<\/p>\n\n<p>I used this approach when <a href=\"https:\/\/www.oliverdavies.uk\/daily\/2024\/02\/16\/keep-logic-within-tests-for-as-long-as-you-can\">writing my SaaS code yesterday<\/a> and it worked well.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>In one of the lessons in my <a href=\"https:\/\/www.oliverdavies.uk\/atdc\">free automated testing in Drupal email course<\/a>, I explain how I create configuration that I need within my tests, such as adding a custom field:<\/p>\n\n<blockquote>\n <p>But how do you know what to name the configuration files and what content to put in them?<\/p>\n \n <p>Rather than trying to write them by hand, I create the configuration I need, such as fields, within a Drupal site and then export and edit the files I need.<\/p>\n<\/blockquote>\n\n<p>As well as creating the fields in the Drupal UI, I was also using it to export the configuration files I needed:<\/p>\n\n<blockquote>\n <p>Once Drupal is installed and the configuration has been created, you can go to - \/admin\/config\/development\/configuration\/single\/export and select the configuration type and name.<\/p>\n \n <p>The filename is shown at the bottom of the page, and you can copy the content into files within your module.<\/p>\n<\/blockquote>\n\n<h2 id=\"there%27s-another-way\">There's another way<\/h2>\n\n<p>After reading that lesson, somene replied and reminded me that there's a <code>--destination<\/code> option you can use with the <code>drush config:export<\/code> command.<\/p>\n\n<p>Instead of exporting to the standard configuration directory, I can do it to a temporary directory:<\/p>\n\n<pre><code class=\"language-shell\">run drush cex --destination \/app\/.ignored\/config\n<\/code><\/pre>\n\n<p>Everyhing in a <code>.ignored<\/code> direcotry is automatically ignored by Git, and to get the files I need, I can use Linux's <code>find<\/code> command to find any files that contain the field name and copy them into my test module directory:<\/p>\n\n<pre><code class=\"language-shell\">find .ignored\/config \\\n -type f \\\n -name \\*drupal_project\\* \\\n -exec cp -r {} web\/modules\/custom\/foo\/modules\/foo_test\/config\/install \\;\n<\/code><\/pre>\n\n<p>I still need to edit the files to remove the <code>uuid<\/code> and <code>_core<\/code> values, but this approach means less clicking in the Drupal UI which makes me more productive.<\/p>\n\n<p>I used this approach when <a href=\"https:\/\/www.oliverdavies.uk\/daily\/2024\/02\/16\/keep-logic-within-tests-for-as-long-as-you-can\">writing my SaaS code yesterday<\/a> and it worked well.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
],
|
|
"feeds_item": [
|
|
{
|
|
"imported": "2025-04-21T01:21:38+00:00",
|
|
"guid": null,
|
|
"hash": "c22cd0a275dfae98de9b0fedf7c17fd2",
|
|
"target_type": "feeds_feed",
|
|
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
|
|
}
|
|
]
|
|
} |