summaryrefslogtreecommitdiff
path: root/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Utils/ReflectionUtilsTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Utils/ReflectionUtilsTest.php')
-rw-r--r--www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Utils/ReflectionUtilsTest.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Utils/ReflectionUtilsTest.php b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Utils/ReflectionUtilsTest.php
new file mode 100644
index 00000000..d94de337
--- /dev/null
+++ b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Utils/ReflectionUtilsTest.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Civi\Test\Api4\Utils;
+
+use Civi\Api4\Utils\ReflectionUtils;
+use Civi\Test\Api4\Mock\MockV4ReflectionGrandchild;
+use Civi\Test\Api4\UnitTestCase;
+
+/**
+ * @group headless
+ */
+class ReflectionUtilsTest extends UnitTestCase {
+
+ /**
+ * Test that class annotations are returned across @inheritDoc
+ */
+ public function testGetDocBlockForClass() {
+ $grandChild = new MockV4ReflectionGrandchild();
+ $reflection = new \ReflectionClass($grandChild);
+ $doc = ReflectionUtils::getCodeDocs($reflection);
+
+ $this->assertEquals(TRUE, $doc['internal']);
+ $this->assertEquals('Grandchild class', $doc['description']);
+
+ $expectedComment = 'This is an extended description.
+
+There is a line break in this description.
+
+This is the base class.';
+
+ $this->assertEquals($expectedComment, $doc['comment']);
+ }
+
+ /**
+ * Test that property annotations are returned across @inheritDoc
+ */
+ public function testGetDocBlockForProperty() {
+ $grandChild = new MockV4ReflectionGrandchild();
+ $reflection = new \ReflectionClass($grandChild);
+ $doc = ReflectionUtils::getCodeDocs($reflection->getProperty('foo'), 'Property');
+
+ $this->assertEquals('This is the foo property.', $doc['description']);
+ $this->assertEquals("In the child class, foo has been barred.\n\nIn general, you can do nothing with it.", $doc['comment']);
+ }
+
+}