oliverdavies.uk/content/node.cbfe0f07-d0fc-46d0-950f-167a091e020d.json

91 lines
3.8 KiB
JSON
Raw Normal View History

2025-04-21 02:34:46 +01:00
{
"uuid": [
{
2025-05-11 09:40:11 +01:00
"value": "cbfe0f07-d0fc-46d0-950f-167a091e020d"
2025-04-21 02:34:46 +01:00
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "daily_email",
"target_type": "node_type",
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
}
],
"revision_timestamp": [
{
2025-05-11 09:40:11 +01:00
"value": "2025-05-11T09:00:34+00:00"
2025-04-21 02:34:46 +01: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": "Testing multiple implementations with contract tests\n"
}
],
"created": [
{
"value": "2023-08-24T00:00:00+00:00"
}
],
"changed": [
{
2025-05-11 09:40:11 +01:00
"value": "2025-05-11T09:00:34+00:00"
2025-04-21 02:34:46 +01:00
}
],
"promote": [
{
"value": false
}
],
"sticky": [
{
"value": false
}
],
"default_langcode": [
{
"value": true
}
],
"revision_translation_affected": [
{
"value": true
}
],
"path": [
{
"alias": "\/daily\/2023\/08\/24\/testing-multiple-implementations-with-contract-tests",
2025-04-29 14:30:51 +01:00
"langcode": "en"
2025-04-21 02:34:46 +01:00
}
],
"body": [
{
2025-05-30 02:14:32 +01:00
"value": "\n <p>If you have multiple implementations of a service, as I <a href=\"\/daily\/2023\/08\/23\/dont-use-third-party-services-directly\">mentioned in yesterday's email<\/a>, you need to ensure they all provide the same functionality.<\/p>\n\n<p>You need to be able to run the same tests against each implementation and have them pass.<\/p>\n\n<h2 id=\"how-do-you-do-this%3F\">How do you do this?<\/h2>\n\n<p>In PHP, I use a trait that contains the test methods and then have a test class for each implementation that uses the trait and sets up any test data.<\/p>\n\n<p>Then, each test class will run the methods from the contract test trait and ensure they all provide the same behaviour, regardless of how it does so - whether it communicates with an API, uses an SDK, or returns fake values.<\/p>\n\n<p>If one implementation doesn't return the same result as the others, its test will fail.<\/p>\n\n<p>If you add a new implementation, you create a new test class, use the trait and get the tests to pass.<\/p>\n\n ",
2025-04-21 02:34:46 +01:00
"format": "full_html",
2025-05-30 02:14:32 +01:00
"processed": "\n <p>If you have multiple implementations of a service, as I <a href=\"http:\/\/default\/daily\/2023\/08\/23\/dont-use-third-party-services-directly\">mentioned in yesterday's email<\/a>, you need to ensure they all provide the same functionality.<\/p>\n\n<p>You need to be able to run the same tests against each implementation and have them pass.<\/p>\n\n<h2 id=\"how-do-you-do-this%3F\">How do you do this?<\/h2>\n\n<p>In PHP, I use a trait that contains the test methods and then have a test class for each implementation that uses the trait and sets up any test data.<\/p>\n\n<p>Then, each test class will run the methods from the contract test trait and ensure they all provide the same behaviour, regardless of how it does so - whether it communicates with an API, uses an SDK, or returns fake values.<\/p>\n\n<p>If one implementation doesn't return the same result as the others, its test will fail.<\/p>\n\n<p>If you add a new implementation, you create a new test class, use the trait and get the tests to pass.<\/p>\n\n ",
2025-04-21 02:34:46 +01:00
"summary": null
}
]
}