summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateu Aguiló Bosch2017-12-26 09:05:49 (GMT)
committerMateu Aguiló Bosch2017-12-26 09:05:49 (GMT)
commita6fbee6db59caeea7626dff32558859bf6ae8978 (patch)
tree7a569f68f5a1831ac3acb2db57809e37afe017cd
parenta580122c8b4805a64075d8526942efcf7b5e0888 (diff)
feat(test): add coverage for related endpoint get
-rw-r--r--tests/src/Functional/JsonExtrasApiFunctionalTest.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/src/Functional/JsonExtrasApiFunctionalTest.php b/tests/src/Functional/JsonExtrasApiFunctionalTest.php
index f69b6c8..2f353d0 100644
--- a/tests/src/Functional/JsonExtrasApiFunctionalTest.php
+++ b/tests/src/Functional/JsonExtrasApiFunctionalTest.php
@@ -106,6 +106,20 @@ class JsonExtrasApiFunctionalTest extends JsonApiFunctionalTestBase {
// 8. Test the field enhancers: SingleNestedEnhancer.
$output = Json::decode($this->drupalGet('/api/articles/' . $this->nodes[3]->uuid()));
$this->assertInternalType('string', $output['data']['attributes']['body']);
+
+ // 9. Test the related endpoint.
+ // This tests the overridden resource name, the overridden field names and
+ // the disabled fields.
+ $output = Json::decode($this->drupalGet('/api/articles/' . $this->nodes[4]->uuid() . '/contentType'));
+ $this->assertArrayNotHasKey('type', $output['data']['attributes']);
+ $this->assertSame('article', $output['data']['attributes']['machineName']);
+ $this->assertSame('contentTypes', $output['data']['type']);
+ $this->assertArrayNotHasKey('uuid', $output['data']['attributes']);
+
+ // 10. Test the relationships endpoint.
+ $output = Json::decode($this->drupalGet('/api/articles/' . $this->nodes[4]->uuid() . '/relationships/contentType'));
+ $this->assertSame('contentTypes', $output['data']['type']);
+ $this->assertArrayHasKey('id', $output['data']);
}
/**