diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Utils/ReflectionUtilsTest.php |
first commit
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.php | 46 |
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']); + } + +} |