Skip to content

Commit 3f6cf85

Browse files
committed
switch to Mockery;
1 parent 904b2ef commit 3f6cf85

File tree

6 files changed

+181
-81
lines changed

6 files changed

+181
-81
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"psr-0": {"phpDocumentor": ["src/", "tests/unit"]}
1313
},
1414
"require-dev": {
15-
"phpunit/phpunit": "^6.5"
15+
"phpunit/phpunit": "^6.5",
16+
"mockery/mockery": "^1.0"
1617
}
1718
}

composer.lock

Lines changed: 114 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/phpDocumentor/GraphViz/Test/AttributeTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class AttributeTest extends TestCase
2626
{
27-
/** @var \phpDocumentor\GraphViz\Attribute */
27+
/** @var Attribute */
2828
protected $fixture = null;
2929

3030
/**
@@ -46,7 +46,7 @@ public function testConstruct()
4646
{
4747
$fixture = new Attribute('MyKey', 'MyValue');
4848
$this->assertInstanceOf(
49-
'phpDocumentor\GraphViz\Attribute',
49+
Attribute::class,
5050
$fixture
5151
);
5252
$this->assertSame('MyKey', $fixture->getKey());
@@ -56,8 +56,8 @@ public function testConstruct()
5656
/**
5757
* Tests the getting and setting of the key.
5858
*
59-
* @covers \phpDocumentor\GraphViz\Attribute::getKey
60-
* @covers \phpDocumentor\GraphViz\Attribute::setKey
59+
* @covers phpDocumentor\GraphViz\Attribute::getKey
60+
* @covers phpDocumentor\GraphViz\Attribute::setKey
6161
*/
6262
public function testKey()
6363
{
@@ -81,8 +81,8 @@ public function testKey()
8181
/**
8282
* Tests the getting and setting of the value.
8383
*
84-
* @covers \phpDocumentor\GraphViz\Attribute::getValue
85-
* @covers \phpDocumentor\GraphViz\Attribute::setValue
84+
* @covers phpDocumentor\GraphViz\Attribute::getValue
85+
* @covers phpDocumentor\GraphViz\Attribute::setValue
8686
*/
8787
public function testValue()
8888
{
@@ -106,7 +106,7 @@ public function testValue()
106106
/**
107107
* Tests whether a string starting with a < is recognized as HTML.
108108
*
109-
* @covers \phpDocumentor\GraphViz\Attribute::isValueInHtml
109+
* @covers phpDocumentor\GraphViz\Attribute::isValueInHtml
110110
*/
111111
public function testIsValueInHtml()
112112
{
@@ -126,7 +126,7 @@ public function testIsValueInHtml()
126126
/**
127127
* Tests whether the toString provides a valid GraphViz attribute string.
128128
*
129-
* @covers \phpDocumentor\GraphViz\Attribute::__toString
129+
* @covers phpDocumentor\GraphViz\Attribute::__toString
130130
*/
131131
public function testToString()
132132
{
@@ -162,8 +162,8 @@ public function testToString()
162162
/**
163163
* Tests whether the toString provides a valid GraphViz attribute string.
164164
*
165-
* @covers \phpDocumentor\GraphViz\Attribute::__toString
166-
* @covers \phpDocumentor\GraphViz\Attribute::encodeSpecials
165+
* @covers phpDocumentor\GraphViz\Attribute::__toString
166+
* @covers phpDocumentor\GraphViz\Attribute::encodeSpecials
167167
*/
168168
public function testToStringWithSpecials()
169169
{
@@ -192,7 +192,7 @@ public function testToStringWithSpecials()
192192
/**
193193
* Tests whether the isValueContainingSpecials function
194194
*
195-
* @covers \phpDocumentor\GraphViz\Attribute::isValueContainingSpecials
195+
* @covers phpDocumentor\GraphViz\Attribute::isValueContainingSpecials
196196
*/
197197
public function testIsValueContainingSpecials()
198198
{

tests/phpDocumentor/GraphViz/Test/EdgeTest.php

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace phpDocumentor\GraphViz\Test;
1515

16+
use Mockery as m;
1617
use phpDocumentor\GraphViz\Edge;
1718
use phpDocumentor\GraphViz\Node;
1819
use PHPUnit\Framework\TestCase;
@@ -27,26 +28,13 @@
2728
*/
2829
class EdgeTest extends TestCase
2930
{
30-
/**
31-
* @var phpDocumentor\GraphViz\Edge
32-
*/
33-
protected $fixture;
34-
35-
/**
36-
* Sets up the fixture, for example, opens a network connection.
37-
* This method is called before a test is executed.
38-
*/
39-
protected function setUp()
40-
{
41-
$this->fixture = new Edge(new Node('from'), new Node('to'));
42-
}
43-
4431
/**
4532
* Tears down the fixture, for example, closes a network connection.
4633
* This method is called after a test is executed.
4734
*/
4835
protected function tearDown()
4936
{
37+
m::close();
5038
}
5139

5240
/**
@@ -56,14 +44,12 @@ protected function tearDown()
5644
*/
5745
public function testConstruct()
5846
{
59-
$this->markTestIncomplete('Need to redo mock technique.');
60-
61-
$fromNode = $this->getMock('phpDocumentor\GraphViz\Node', [], [], '', false);
62-
$toNode = $this->getMock('phpDocumentor\GraphViz\Node', [], [], '', false);
47+
$fromNode = m::mock(Node::class);
48+
$toNode = m::mock(Node::class);
6349
$fixture = new Edge($fromNode, $toNode);
6450

6551
$this->assertInstanceOf(
66-
'phpDocumentor\GraphViz\Edge',
52+
Edge::class,
6753
$fixture
6854
);
6955
$this->assertSame(
@@ -84,7 +70,7 @@ public function testConstruct()
8470
public function testCreate()
8571
{
8672
$this->assertInstanceOf(
87-
'phpDocumentor\GraphViz\Edge',
73+
Edge::class,
8874
Edge::create(new Node('from'), new Node('to'))
8975
);
9076
}
@@ -125,9 +111,10 @@ public function testGetTo()
125111
public function testCall()
126112
{
127113
$label = 'my label';
128-
$this->assertInstanceOf('phpDocumentor\GraphViz\Edge', $this->fixture->setLabel($label));
129-
$this->assertSame($label, $this->fixture->getLabel()->getValue());
130-
$this->assertNull($this->fixture->someNonExcistingMethod());
114+
$fixture = new Edge(new Node('from'), new Node('to'));
115+
$this->assertInstanceOf(Edge::class, $fixture->setLabel($label));
116+
$this->assertSame($label, $fixture->getLabel()->getValue());
117+
$this->assertNull($fixture->someNonExcistingMethod());
131118
}
132119

133120
/**
@@ -138,8 +125,9 @@ public function testCall()
138125
*/
139126
public function testToString()
140127
{
141-
$this->fixture->setLabel('MyLabel');
142-
$this->fixture->setWeight(45);
128+
$fixture = new Edge(new Node('from'), new Node('to'));
129+
$fixture->setLabel('MyLabel');
130+
$fixture->setWeight(45);
143131

144132
$dot = <<<DOT
145133
"from" -> "to" [
@@ -148,6 +136,6 @@ public function testToString()
148136
]
149137
DOT;
150138

151-
$this->assertSame($dot, (string) $this->fixture);
139+
$this->assertSame($dot, (string) $fixture);
152140
}
153141
}

0 commit comments

Comments
 (0)