-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR merge advanced search, and write the example codes.
- Loading branch information
Showing
5 changed files
with
79 additions
and
2 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use JiraRestApi\Project\ProjectService; | ||
|
||
use \Mockery as m; | ||
|
||
class Temperature | ||
{ | ||
public function __construct($service) | ||
{ | ||
$this->_service = $service; | ||
} | ||
|
||
public function average() | ||
{ | ||
$total = 0; | ||
for ($i=0;$i<3;$i++) { | ||
$total += $this->_service->readTemp(); | ||
} | ||
return $total/3; | ||
} | ||
} | ||
|
||
class MockTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function tearDown() | ||
{ | ||
m::close(); | ||
} | ||
|
||
public function testGetsAverageTemperatureFromThreeServiceReadings() | ||
{ | ||
$service = m::mock('service'); | ||
$service->shouldReceive('readTemp')->times(3)->andReturn(10, 12, 14); | ||
|
||
$temperature = new Temperature($service); | ||
|
||
$this->assertEquals(12, $temperature->average()); | ||
} | ||
} |