Skip to content

Commit

Permalink
[Tests/GreeterTest] 時計をモックして朝とそれ以外のテストを記述した
Browse files Browse the repository at this point in the history
  • Loading branch information
hidenorigoto committed Oct 9, 2013
1 parent a0d58b6 commit 1ff9b8c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/CodeIQ/Greeter/Tests/GreeterTest.php
Expand Up @@ -19,11 +19,27 @@ class GreeterTest extends \PHPUnit_Framework_TestCase
/**
* @test
*/
public function あいさつする()
public function 朝ならおはようございます()
{
$this->clock->expects($this->once())
->method('getCurrentTime')
->will($this->returnValue(new \DateTimeImmutable('08:00:00')));
$this->assertThat($this->SUT->greet(), $this->equalTo('おはようございます'));
}

/**
* @test
*/
public function 朝でないならあいさつなし()
{
$this->clock->expects($this->once())
->method('getCurrentTime')
->will($this->returnValue(new \DateTimeImmutable('15:00:00')));

$this->assertThat($this->SUT->greet(), $this->equalTo(''));
}

protected function setUp()
{
$this->clock = $this->getMock('CodeIQ\Greeter\Clock');
Expand Down

0 comments on commit 1ff9b8c

Please sign in to comment.