Skip to content

Commit

Permalink
added tests for #238
Browse files Browse the repository at this point in the history
  • Loading branch information
Halleck45 committed Apr 10, 2017
1 parent d7599aa commit 1310058
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
3 changes: 0 additions & 3 deletions tests/Component/Tree/GraphTest.php
Expand Up @@ -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');
Expand Down
52 changes: 52 additions & 0 deletions tests/Metric/Class_/ClassEnumVisitorTest.php
Expand Up @@ -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 = '<?php
namespace Blackprism\CouchbaseODM\Observer;
/**
* Interface NotifyPropertyChangedInterface
*/
interface NotifyPropertyChangedInterface
{
/**
* Enable tracking on object.
*/
public function track();
/**
* Check if object is tracked.
*
* @return bool
*/
public function isTracked(): bool;
}';
}
}
1 change: 0 additions & 1 deletion tests/Metric/Class_/Coupling/ExternalsVisitorTest.php
Expand Up @@ -53,7 +53,6 @@ public function provideExamples()

/**
* @dataProvider provideExamplesAnnotation
* @group wip
*/
public function testDependenciesAreFoundEvenInAnnotation($example, $classname, $expected)
{
Expand Down

0 comments on commit 1310058

Please sign in to comment.