WorldCupReviewRepositoryMailCopyTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Tests\Unit;
  3. use App\Services\WorldCup\Repositories\SqlWorldCupReviewRepository;
  4. use PHPUnit\Framework\TestCase;
  5. use ReflectionClass;
  6. class WorldCupReviewRepositoryMailCopyTest extends TestCase
  7. {
  8. public function testInviteeApprovedMailUsesWelcomeRewardCopy(): void
  9. {
  10. $repository = new SqlWorldCupReviewRepository();
  11. $reward = $this->reward();
  12. $title = $this->callPrivate($repository, 'approvedInviteeMailTitle', [$reward]);
  13. $text = $this->callPrivate($repository, 'approvedInviteeMailText', [$reward]);
  14. $this->assertSame('Claim your $60 welcome reward', $title);
  15. $this->assertContains('Welcome! Your referral reward is ready to claim.', $text);
  16. $this->assertContains('You signed up with an invite and made your first deposit of $120.', $text);
  17. $this->assertContains('Reward: $60 (50% of your first deposit).', $text);
  18. $this->assertContains('Tap Claim to add it to your balance.', $text);
  19. }
  20. public function testInviteeRejectedMailUsesWelcomeRewardCopy(): void
  21. {
  22. $repository = new SqlWorldCupReviewRepository();
  23. $reward = $this->reward();
  24. $title = $this->callPrivate($repository, 'rejectedInviteeMailTitle', [$reward]);
  25. $text = $this->callPrivate($repository, 'rejectedInviteeMailText', [$reward, 'Same device']);
  26. $this->assertSame('Welcome reward not approved', $title);
  27. $this->assertContains('Your welcome reward could not be approved.', $text);
  28. $this->assertContains('Reason: Same device.', $text);
  29. $this->assertContains('If you think this is a mistake, contact support.', $text);
  30. }
  31. private function reward(): array
  32. {
  33. return [
  34. 'reward_id' => 1,
  35. 'referrer_id' => 1001,
  36. 'invitee_id' => 1002,
  37. 'first_deposit_amt' => 12000,
  38. 'reward_each' => 6000,
  39. 'total_liability' => 12000,
  40. 'risk_level' => 'low',
  41. 'status' => 'reviewing',
  42. ];
  43. }
  44. private function callPrivate(object $object, string $method, array $arguments)
  45. {
  46. $reflection = new ReflectionClass($object);
  47. $method = $reflection->getMethod($method);
  48. $method->setAccessible(true);
  49. return $method->invokeArgs($object, $arguments);
  50. }
  51. }