Last active
November 3, 2019 14:32
-
-
Save hungtrinh/aa9771ae3e8f45a0f2c8f67b60a92f29 to your computer and use it in GitHub Desktop.
Write Production Without Test
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
<?php | |
function discountRateByMembershipType($userId) { | |
//$date = getCurrentDateFromLocalTimeOrRemoteTimeServer(); //with remote time server, we can't fake date | |
//if (is_not_black_friday($date) return 0; // we can't not test CORE BUSINESS if add this spec | |
$membershipType = getMemberShipTypeFromDatabaseOrRemoteApi($userId); | |
//CORE BUSINESS need coverage by unit test or manual test | |
if ('platinum' === $membershipType) return 0.15; | |
if ('gold' === $membershipType) return 0.1; | |
if ('slive' === $membershipType) return 0.05; | |
throw new UnknowMembershipTypeException('invalid membership type'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment