Created
April 27, 2019 13:27
-
-
Save banqhsia/916ca2edf78be3be6bd5e7158caa7f26 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
class BonusCalculatorTest extends TestCase | |
{ | |
public function test_isExpired_should_be_true() | |
{ | |
$target = $this->createPartialMock(BonusCalculator::class, [ | |
'getDateTime', | |
]); | |
// mock DateTime::getToday() return value.... | |
$datetime = $this->createMock(DateTime::class); | |
$datetime->method('getToday')->willReturn('2015-12-26'); | |
// inject mock object: DateTime | |
$target->method('getDateTime')->willReturn($datetime); | |
$this->assertTrue($target->isExpired()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment