diff --git a/tests/Component/Tree/GraphTest.php b/tests/Component/Tree/GraphTest.php index 17db931c..abc07661 100644 --- a/tests/Component/Tree/GraphTest.php +++ b/tests/Component/Tree/GraphTest.php @@ -69,9 +69,6 @@ public function testICanListEdges() { $this->assertEquals(1, sizeof($graph->getEdges())); } - /** - * @group wip - */ public function testEdgeIsAddedToFromAndToNode() { $graph = new Graph(); $a = new Node('A'); diff --git a/tests/Metric/Class_/ClassEnumVisitorTest.php b/tests/Metric/Class_/ClassEnumVisitorTest.php index 16d98fa4..35602613 100644 --- a/tests/Metric/Class_/ClassEnumVisitorTest.php +++ b/tests/Metric/Class_/ClassEnumVisitorTest.php @@ -62,4 +62,56 @@ public function testAnonymousClassIsHandledCorrectly() $traverser->traverse($stmts); } + /** + * @link https://github.com/phpmetrics/PhpMetrics/issues/238 + */ + public function testDynamicAttributeClassIsHandledCorrectly() + { + $metrics = new Metrics(); + + $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); + $traverser = new \PhpParser\NodeTraverser(); + $traverser->addVisitor(new \PhpParser\NodeVisitor\NameResolver()); + $traverser->addVisitor(new ClassEnumVisitor($metrics)); + + $code = ' +class A { + public function foo() { + $reflection = new \ReflectionObject($this); + + foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $return[$property->name] = $this->{$property->name}; + } + } +} +'; + $stmts = $parser->parse($code); + $traverser->traverse($stmts); + } + + + /** + * @link https://github.com/phpmetrics/PhpMetrics/issues/238#issuecomment-292466274 + */ + public function testDynamicAttributeClassIsHandledCorrectly2() + { + $code = '