Skip to content

Instantly share code, notes, and snippets.

@banqhsia
Created April 27, 2019 13:27
Show Gist options
  • Save banqhsia/916ca2edf78be3be6bd5e7158caa7f26 to your computer and use it in GitHub Desktop.
Save banqhsia/916ca2edf78be3be6bd5e7158caa7f26 to your computer and use it in GitHub Desktop.
<?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