Skip to content

Commit

Permalink
Fixing instanceof not appearing within condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswilms committed Aug 2, 2011
1 parent 5eb8653 commit 39d110e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rule/DependencyIsUsedRule.php
Expand Up @@ -42,7 +42,7 @@ protected function doCheck()
"new {$name}\(",
"{$name}::",
"\({$name} \\$",
"instanceof {$name}(:|\))",
"instanceof {$name}(;|:|\))",
"extends {$name}",
"implements {$name}"
);
Expand Down
15 changes: 15 additions & 0 deletions tests/Rule/DependencyIsUsedRule.php
Expand Up @@ -30,5 +30,20 @@ public function testDetect()
$this->assertTrue($this->result->hasViolations());
$this->assertEquals(1, $this->result->getNumberOfViolations());
}

/**
* @covers \spriebsch\PHPca\Rule\DependencyIsUsedRule
*/
public function testDetectInstanceof()
{
$this->init(__DIR__ . '/../_testdata/DependencyIsUsedRule/instanceof.php');

$rule = new DependencyIsUsedRule();

$rule->check($this->file, $this->result);

$this->assertFalse($this->result->hasViolations());
$this->assertEquals(0, $this->result->getNumberOfViolations());
}
}
?>
31 changes: 31 additions & 0 deletions tests/_testdata/DependencyIsUsedRule/instanceof.php
@@ -0,0 +1,31 @@
<?php

namespace foo\tests\integration\data;

use foo\data\Database;
use foo\data\Connections;
use foo\data\model\Query;
use foo\tests\mocks\data\source\Images;
use foo\tests\mocks\data\source\Galleries;

class DatabaseTest extends \lithium\test\Integration {

public $gallery = array(
'name' => 'Foo Gallery'
);

public function skip() {
$isDatabase = Connections::get('test') instanceof Database;
}

public function testCreateData() {
$gallery = Galleries::create($this->gallery);
}

public function testManyToOne() {
$query = new Query();
$images = Images::find('all', $opts + array('with' => 'Galleries'))->data();
}
}

?>

0 comments on commit 39d110e

Please sign in to comment.