This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0292420
commit 1180d9a
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
require_once __DIR__.'/../../vendor/autoload.php'; | ||
use edsonmedina\php_testability\NodeVisitors\ErrorSuppressionVisitor; | ||
|
||
class ErrorSuppressionVisitorTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function setup () | ||
{ | ||
$this->data = $this->getMockBuilder('edsonmedina\php_testability\ReportData') | ||
->disableOriginalConstructor() | ||
->setMethods(array('addIssue')) | ||
->getMock(); | ||
|
||
$this->scope = $this->getMockBuilder('edsonmedina\php_testability\AnalyserScope') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->node = $this->getMockBuilder ('PhpParser\Node\Expr\ErrorSuppress') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->node2 = $this->getMockBuilder ('PhpParser\Node\Expr\StaticCall') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->factory = $this->getMockBuilder ('edsonmedina\php_testability\AnalyserAbstractFactory') | ||
->getMock(); | ||
} | ||
|
||
/** | ||
* @covers edsonmedina\php_testability\NodeVisitors\ErrorSuppressionVisitor::leaveNode | ||
*/ | ||
public function testLeaveNodeWithDifferentType () | ||
{ | ||
$this->data->expects($this->never())->method('addIssue'); | ||
|
||
$visitor = new ErrorSuppressionVisitor ($this->data, $this->scope, $this->factory); | ||
$visitor->leaveNode ($this->node2); | ||
} | ||
|
||
/** | ||
* @covers edsonmedina\php_testability\NodeVisitors\ErrorSuppressionVisitor::leaveNode | ||
*/ | ||
public function testLeaveNodeInGlobalSpace () | ||
{ | ||
$this->data->expects($this->never())->method('addIssue'); | ||
|
||
$this->scope->method ('inGlobalSpace')->willReturn (true); | ||
|
||
$visitor = new ErrorSuppressionVisitor ($this->data, $this->scope, $this->factory); | ||
$visitor->leaveNode ($this->node); | ||
} | ||
|
||
/** | ||
* @covers edsonmedina\php_testability\NodeVisitors\ErrorSuppressionVisitor::leaveNode | ||
*/ | ||
public function testLeaveNode () | ||
{ | ||
$this->data->expects($this->once())->method('addIssue'); | ||
|
||
$this->scope->method ('inGlobalSpace')->willReturn (false); | ||
|
||
$visitor = new ErrorSuppressionVisitor ($this->data, $this->scope, $this->factory); | ||
$visitor->leaveNode ($this->node); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters