100 lines
No EOL
4.8 KiB
JSON
100 lines
No EOL
4.8 KiB
JSON
{
|
|
"uuid": [
|
|
{
|
|
"value": "15237599-15e7-496b-a7e0-c02fddae26f8"
|
|
}
|
|
],
|
|
"langcode": [
|
|
{
|
|
"value": "en"
|
|
}
|
|
],
|
|
"type": [
|
|
{
|
|
"target_id": "daily_email",
|
|
"target_type": "node_type",
|
|
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
|
|
}
|
|
],
|
|
"revision_timestamp": [
|
|
{
|
|
"value": "2025-05-11T09:00:34+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": "Asserting all the things\n"
|
|
}
|
|
],
|
|
"created": [
|
|
{
|
|
"value": "2023-08-19T00:00:00+00:00"
|
|
}
|
|
],
|
|
"changed": [
|
|
{
|
|
"value": "2025-05-11T09:00:34+00:00"
|
|
}
|
|
],
|
|
"promote": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"sticky": [
|
|
{
|
|
"value": false
|
|
}
|
|
],
|
|
"default_langcode": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"revision_translation_affected": [
|
|
{
|
|
"value": true
|
|
}
|
|
],
|
|
"path": [
|
|
{
|
|
"alias": "\/daily\/2023\/08\/19\/asserting-all-the-things",
|
|
"langcode": "en"
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"value": "\n <p>As well as assertions within tests, you can also check within implementation code that things are in an expected state or contain a certain value.<\/p>\n\n<p>In PHP, this is done by throwing an Exception if a condition is met.<\/p>\n\n<p>For example:<\/p>\n\n<pre><code class=\"language-php\">if (!is_array(false)) {\n throw new \\Exception('Not an array');\n}\n<\/code><\/pre>\n\n<p>There's also the <code>assert<\/code> construct which, since PHP 8.0, throws an Exception by default:<\/p>\n\n<pre><code class=\"language-php\">assert(is_array(false));\n<\/code><\/pre>\n\n<p>You can also use an assertion library, such as <code>webmozart\/assert<\/code> or <code>beberlei\/assert<\/code> which provide assertions and guard methods:<\/p>\n\n<pre><code class=\"language-php\">use Webmozart\\Assert\\Assert;\n\nAssert::isArray(false);\n<\/code><\/pre>\n\n<p>Similarly, if the condition fails, it throws an Exception that can be caught elsewhere.<\/p>\n\n<p>As well as basic assertions such as the item is the expected type or don't match the condition, there are more complex assertions, such as all items within an array are a certain type or that an integer is positive.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>I use guard conditions a lot within my code. If something is not as I'd expect, I like for an error to be thrown. This makes is easy to test and to debug any failures compared to failing silently.<\/p>\n\n ",
|
|
"format": "full_html",
|
|
"processed": "\n <p>As well as assertions within tests, you can also check within implementation code that things are in an expected state or contain a certain value.<\/p>\n\n<p>In PHP, this is done by throwing an Exception if a condition is met.<\/p>\n\n<p>For example:<\/p>\n\n<pre><code class=\"language-php\">if (!is_array(false)) {\n throw new \\Exception('Not an array');\n}\n<\/code><\/pre>\n\n<p>There's also the <code>assert<\/code> construct which, since PHP 8.0, throws an Exception by default:<\/p>\n\n<pre><code class=\"language-php\">assert(is_array(false));\n<\/code><\/pre>\n\n<p>You can also use an assertion library, such as <code>webmozart\/assert<\/code> or <code>beberlei\/assert<\/code> which provide assertions and guard methods:<\/p>\n\n<pre><code class=\"language-php\">use Webmozart\\Assert\\Assert;\n\nAssert::isArray(false);\n<\/code><\/pre>\n\n<p>Similarly, if the condition fails, it throws an Exception that can be caught elsewhere.<\/p>\n\n<p>As well as basic assertions such as the item is the expected type or don't match the condition, there are more complex assertions, such as all items within an array are a certain type or that an integer is positive.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>I use guard conditions a lot within my code. If something is not as I'd expect, I like for an error to be thrown. This makes is easy to test and to debug any failures compared to failing silently.<\/p>\n\n ",
|
|
"summary": null
|
|
}
|
|
],
|
|
"feeds_item": [
|
|
{
|
|
"imported": "1970-01-01T00:33:45+00:00",
|
|
"guid": null,
|
|
"hash": "fff5236abf836cd7767bdeeb7e9ba028",
|
|
"target_type": "feeds_feed",
|
|
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
|
|
}
|
|
]
|
|
} |