mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Fixes for tests
This commit is contained in:
parent
fa1e52b4ca
commit
fecf1e13b5
@ -33,7 +33,6 @@ use PDOException;
|
||||
use Sentry\Laravel\Integration;
|
||||
use Sentry\State\Scope;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use League\Flysystem\UnableToCreateDirectory;
|
||||
@ -47,27 +46,27 @@ class Handler extends ExceptionHandler
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
// PDOException::class,
|
||||
// MaxAttemptsExceededException::class,
|
||||
// CommandNotFoundException::class,
|
||||
// ValidationException::class,
|
||||
// ModelNotFoundException::class,
|
||||
// NotFoundHttpException::class,
|
||||
PDOException::class,
|
||||
MaxAttemptsExceededException::class,
|
||||
CommandNotFoundException::class,
|
||||
ValidationException::class,
|
||||
ModelNotFoundException::class,
|
||||
NotFoundHttpException::class,
|
||||
];
|
||||
|
||||
protected $selfHostDontReport = [
|
||||
// FilePermissionsFailure::class,
|
||||
// PDOException::class,
|
||||
// MaxAttemptsExceededException::class,
|
||||
// CommandNotFoundException::class,
|
||||
// ValidationException::class,
|
||||
// ModelNotFoundException::class,
|
||||
// NotFoundHttpException::class,
|
||||
// UnableToCreateDirectory::class,
|
||||
// GuzzleHttp\Exception\ConnectException::class,
|
||||
// Symfony\Component\Process\Exception\RuntimeException::class,
|
||||
// InvalidArgumentException::class,
|
||||
// RuntimeException::class,
|
||||
FilePermissionsFailure::class,
|
||||
PDOException::class,
|
||||
MaxAttemptsExceededException::class,
|
||||
CommandNotFoundException::class,
|
||||
ValidationException::class,
|
||||
ModelNotFoundException::class,
|
||||
NotFoundHttpException::class,
|
||||
UnableToCreateDirectory::class,
|
||||
GuzzleHttp\Exception\ConnectException::class,
|
||||
Symfony\Component\Process\Exception\RuntimeException::class,
|
||||
InvalidArgumentException::class,
|
||||
RuntimeException::class,
|
||||
];
|
||||
|
||||
protected $hostedDontReport = [
|
||||
|
@ -276,6 +276,8 @@ class VendorController extends BaseController
|
||||
|
||||
event(new VendorWasUpdated($vendor, $vendor->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
event('eloquent.updated: App\Models\Vendor', $vendor);
|
||||
|
||||
return $this->itemResponse($vendor->fresh());
|
||||
}
|
||||
|
||||
@ -372,6 +374,8 @@ class VendorController extends BaseController
|
||||
|
||||
event(new VendorWasCreated($vendor, $vendor->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
event('eloquent.created: App\Models\Vendor', $vendor);
|
||||
|
||||
return $this->itemResponse($vendor);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ use App\Models\Client as ClientModel;
|
||||
use App\Models\Company;
|
||||
use App\Models\Product;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Webhook;
|
||||
use App\Transformers\ArraySerializer;
|
||||
use GuzzleHttp\Client;
|
||||
@ -244,7 +245,7 @@ class WebhookSingle implements ShouldQueue
|
||||
private function resolveClient()
|
||||
{
|
||||
//make sure it isn't an instance of the Client Model
|
||||
if (! $this->entity instanceof ClientModel && ! $this->entity instanceof Product && $this->entity->client()->exists()) {
|
||||
if (! $this->entity instanceof ClientModel && ! $this->entity instanceof Product && ! $this->entity instanceof Vendor && $this->entity->client()->exists()) {
|
||||
return $this->entity->client;
|
||||
}
|
||||
|
||||
@ -253,10 +254,8 @@ class WebhookSingle implements ShouldQueue
|
||||
|
||||
public function failed($exception = null)
|
||||
{
|
||||
if($exception){
|
||||
nlog("failed in webhooksingle");
|
||||
nlog($exception->getMessage());
|
||||
}
|
||||
|
||||
config(['queue.failed.driver' => null]);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,27 +24,27 @@ class Webhook extends BaseModel
|
||||
|
||||
const EVENT_CREATE_QUOTE = 3; //tested
|
||||
|
||||
const EVENT_CREATE_PAYMENT = 4;
|
||||
const EVENT_CREATE_PAYMENT = 4; //tested
|
||||
|
||||
const EVENT_CREATE_VENDOR = 5;
|
||||
const EVENT_CREATE_VENDOR = 5; //tested
|
||||
|
||||
const EVENT_UPDATE_QUOTE = 6;
|
||||
const EVENT_UPDATE_QUOTE = 6; //tested
|
||||
|
||||
const EVENT_DELETE_QUOTE = 7;
|
||||
const EVENT_DELETE_QUOTE = 7; //tested
|
||||
|
||||
const EVENT_UPDATE_INVOICE = 8; //tested
|
||||
|
||||
const EVENT_DELETE_INVOICE = 9; //tested
|
||||
|
||||
const EVENT_UPDATE_CLIENT = 10;
|
||||
const EVENT_UPDATE_CLIENT = 10; //tested
|
||||
|
||||
const EVENT_DELETE_CLIENT = 11;
|
||||
const EVENT_DELETE_CLIENT = 11; //tested
|
||||
|
||||
const EVENT_DELETE_PAYMENT = 12;
|
||||
const EVENT_DELETE_PAYMENT = 12; //tested
|
||||
|
||||
const EVENT_UPDATE_VENDOR = 13;
|
||||
const EVENT_UPDATE_VENDOR = 13; //tested
|
||||
|
||||
const EVENT_DELETE_VENDOR = 14;
|
||||
const EVENT_DELETE_VENDOR = 14; //
|
||||
|
||||
const EVENT_CREATE_EXPENSE = 15;
|
||||
|
||||
|
@ -32,9 +32,9 @@ class VendorObserver
|
||||
->where('event_id', Webhook::EVENT_CREATE_VENDOR)
|
||||
->exists();
|
||||
|
||||
if ($subscriptions) {
|
||||
if ($subscriptions)
|
||||
WebhookHandler::dispatch(Webhook::EVENT_CREATE_VENDOR, $vendor, $vendor->company)->delay(rand(1,5));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ class VendorContactRepository extends BaseRepository
|
||||
$update_contact->password = Hash::make($contact['password']);
|
||||
}
|
||||
|
||||
$update_contact->save();
|
||||
$update_contact->saveQuietly();
|
||||
});
|
||||
|
||||
$vendor->load('contacts');
|
||||
@ -80,7 +80,7 @@ class VendorContactRepository extends BaseRepository
|
||||
$new_contact->user_id = $vendor->user_id;
|
||||
$new_contact->contact_key = Str::random(40);
|
||||
$new_contact->is_primary = true;
|
||||
$new_contact->save();
|
||||
$new_contact->saveQuietly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,13 +45,13 @@ class VendorRepository extends BaseRepository
|
||||
{
|
||||
$vendor->fill($data);
|
||||
|
||||
$vendor->save();
|
||||
$vendor->saveQuietly();
|
||||
|
||||
if ($vendor->number == '' || ! $vendor->number) {
|
||||
$vendor->number = $this->getNextVendorNumber($vendor);
|
||||
} //todo write tests for this and make sure that custom vendor numbers also works as expected from here
|
||||
|
||||
$vendor->save();
|
||||
$vendor->saveQuietly();
|
||||
|
||||
if (isset($data['contacts'])) {
|
||||
$this->contact_repo->save($data, $vendor);
|
||||
|
@ -40,7 +40,7 @@ class ClientService
|
||||
|
||||
$this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();
|
||||
$this->client->balance += $amount;
|
||||
$this->client->save();
|
||||
$this->client->saveQuietly();
|
||||
|
||||
}, 2);
|
||||
}
|
||||
@ -61,7 +61,7 @@ class ClientService
|
||||
$this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();
|
||||
$this->client->balance += $balance;
|
||||
$this->client->paid_to_date += $paid_to_date;
|
||||
$this->client->save();
|
||||
$this->client->saveQuietly();
|
||||
|
||||
}, 2);
|
||||
}
|
||||
@ -80,7 +80,7 @@ class ClientService
|
||||
|
||||
$this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first();
|
||||
$this->client->paid_to_date += $amount;
|
||||
$this->client->save();
|
||||
$this->client->saveQuietly();
|
||||
|
||||
}, 2);
|
||||
|
||||
|
@ -93,14 +93,14 @@ class SchedulerService
|
||||
private function calculateStartAndEndDates(): array
|
||||
{
|
||||
return match ($this->scheduler->parameters['date_range']) {
|
||||
'this_month' => [now()->firstOfMonth()->format('Y-m-d'), now()->lastOfMonth()->format('Y-m-d')],
|
||||
'this_quarter' => [now()->firstOfQuarter()->format('Y-m-d'), now()->lastOfQuarter()->format('Y-m-d')],
|
||||
'this_year' => [now()->firstOfYear()->format('Y-m-d'), now()->lastOfYear()->format('Y-m-d')],
|
||||
'previous_month' => [now()->subMonth()->firstOfMonth()->format('Y-m-d'), now()->subMonth()->lastOfMonth()->format('Y-m-d')],
|
||||
'previous_quarter' => [now()->subQuarter()->firstOfQuarter()->format('Y-m-d'), now()->subQuarter()->lastOfQuarter()->format('Y-m-d')],
|
||||
'previous_year' => [now()->subYear()->firstOfYear()->format('Y-m-d'), now()->subYear()->lastOfYear()->format('Y-m-d')],
|
||||
'this_month' => [now()->startOfDay()->firstOfMonth()->format('Y-m-d'), now()->startOfDay()->lastOfMonth()->format('Y-m-d')],
|
||||
'this_quarter' => [now()->startOfDay()->firstOfQuarter()->format('Y-m-d'), now()->startOfDay()->lastOfQuarter()->format('Y-m-d')],
|
||||
'this_year' => [now()->startOfDay()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->lastOfYear()->format('Y-m-d')],
|
||||
'previous_month' => [now()->startOfDay()->subMonthNoOverflow()->firstOfMonth()->format('Y-m-d'), now()->startOfDay()->subMonthNoOverflow()->lastOfMonth()->format('Y-m-d')],
|
||||
'previous_quarter' => [now()->startOfDay()->subQuarterNoOverflow()->firstOfQuarter()->format('Y-m-d'), now()->startOfDay()->subQuarterNoOverflow()->lastOfQuarter()->format('Y-m-d')],
|
||||
'previous_year' => [now()->startOfDay()->subYearNoOverflow()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->subYearNoOverflow()->lastOfYear()->format('Y-m-d')],
|
||||
'custom_range' => [$this->scheduler->parameters['start_date'], $this->scheduler->parameters['end_date']],
|
||||
default => [now()->firstOfMonth()->format('Y-m-d'), now()->lastOfMonth()->format('Y-m-d')],
|
||||
default => [now()->startOfDay()->firstOfMonth()->format('Y-m-d'), now()->startOfDay()->lastOfMonth()->format('Y-m-d')],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -258,6 +258,7 @@ class SchedulerTest extends TestCase
|
||||
|
||||
public function testCalculateStartAndEndDates()
|
||||
{
|
||||
$this->travelTo(Carbon::parse('2023-01-01'));
|
||||
|
||||
$scheduler = SchedulerFactory::create($this->company->id, $this->user->id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user