Created
July 23, 2022 21:59
-
-
Save svpernova09/3e268c9b414a26aaff207ce90150c91c 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 | |
namespace Tests\Unit; | |
use PHPUnit\Framework\TestCase; | |
class ShouldSendEmailTest extends TestCase | |
{ | |
/** | |
* A basic unit test example. | |
* | |
* @return void | |
*/ | |
public function test_should_send_email_method() | |
{ | |
$class = new Foo(); | |
#$email_send_time = Source your send time | |
#$timezone - # Set your timezone on send time | |
$this->assertTrue($class->shouldSendEmail($email_send_time, $timezone)); | |
} | |
} | |
class Foo { | |
public function shouldSendEmail($email_send_time, $timezone) { | |
// $email_send_time = $location->settings->automatic_email_send_time; | |
// $timezone = $location->timezone; | |
$send_at = Carbon::createFromTimeString($email_send_time, $timezone); | |
$now = Carbon::now('UTC'); | |
$utc_send = $send_at->setTimezone('UTC'); | |
if ($utc_send->equalTo($now)) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment