From 6752c26bf1051287eb7aa9ae9eeeaa095fa0ffef Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Mon, 24 Apr 2017 00:16:54 +0200 Subject: [PATCH] Add test case for DefinitionResolver --- tests/DefinitionResolverTest.php | 51 ++++++++++++++++++++++++++++++++ tests/MockPhpDocument.php | 20 +++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/DefinitionResolverTest.php create mode 100644 tests/MockPhpDocument.php diff --git a/tests/DefinitionResolverTest.php b/tests/DefinitionResolverTest.php new file mode 100644 index 0000000..ea0f481 --- /dev/null +++ b/tests/DefinitionResolverTest.php @@ -0,0 +1,51 @@ +parse("setAttribute('ownerDocument', new MockPhpDocument); + + $index = new Index; + $definitionResolver = new DefinitionResolver($index); + $def = $definitionResolver->createDefinitionFromNode($stmts[0], '\TEST_DEFINE'); + + $this->assertInstanceOf(\phpDocumentor\Reflection\Types\Boolean::class, $def->type); + } + + public function testGetTypeFromNode() + { + $parser = new Parser; + $stmts = $parser->parse("setAttribute('ownerDocument', new MockPhpDocument); + + $index = new Index; + $definitionResolver = new DefinitionResolver($index); + $type = $definitionResolver->getTypeFromNode($stmts[0]); + + $this->assertInstanceOf(\phpDocumentor\Reflection\Types\Boolean::class, $type); + } + + public function testGetDefinedFqn() + { + // define('XXX') (only one argument) must not introduce a new symbol + $parser = new Parser; + $stmts = $parser->parse("setAttribute('ownerDocument', new MockPhpDocument); + + $index = new Index; + $definitionResolver = new DefinitionResolver($index); + $fqn = $definitionResolver->getDefinedFqn($stmts[0]); + + $this->assertNull($fqn); + } +} diff --git a/tests/MockPhpDocument.php b/tests/MockPhpDocument.php new file mode 100644 index 0000000..48d4b70 --- /dev/null +++ b/tests/MockPhpDocument.php @@ -0,0 +1,20 @@ +