1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fixes for tests

This commit is contained in:
David Bomba 2023-11-08 23:51:53 +11:00
parent cb94973bd1
commit 1b60ee132e
3 changed files with 30 additions and 7 deletions

View File

@ -778,7 +778,12 @@ class Client extends BaseModel implements HasLocalePreference
$timezone = $this->company->timezone();
$offset -= $timezone->utc_offset;
//2023-11-08 adjustments for DST
date_default_timezone_set('GMT');
$date = new \DateTime("now", new \DateTimeZone($timezone->name));
$offset -= $date->getOffset();
// $offset -= $timezone->utc_offset;
$offset += ($entity_send_time * 3600);
return $offset;

View File

@ -928,7 +928,11 @@ class Company extends BaseModel
$timezone = $this->timezone();
$offset -= $timezone->utc_offset;
date_default_timezone_set('GMT');
$date = new \DateTime("now", new \DateTimeZone($timezone->name));
$offset -= $date->getOffset();
// $offset -= $timezone->utc_offset;
$offset += ($entity_send_time * 3600);
return $offset;

View File

@ -322,15 +322,29 @@ class ReminderTest extends TestCase
$this->travelTo(now()->startOfDay());
for($x=0; $x<46; $x++) {
$travel_date = Carbon::parse($this->invoice->next_send_date);
$x = false;
for($x=0; $x<50; $x++) {
// nlog("traveller {$x} ".now()->format('Y-m-d h:i:s'));
(new ReminderJob())->handle();
$this->invoice = $this->invoice->fresh();
$this->assertNull($this->invoice->reminder1_sent);
$this->assertNull($this->invoice->reminder_last_sent);
if(now()->gt($travel_date) && !$x) {
$this->assertNotNull($this->invoice->reminder1_sent);
$this->assertNotNull($this->invoice->reminder_last_sent);
$x=true;
}
if(!$x){
$this->invoice = $this->invoice->fresh();
$this->assertNull($this->invoice->reminder1_sent);
$this->assertNull($this->invoice->reminder_last_sent);
}
$this->travelTo(now()->addHours(1));
}
// nlog("traveller ".now()->format('Y-m-d'));