mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 11:14:37 -04:00
Fixes for Migration (#3572)
* Remove \Log::, fixes for tests, and fixes for migration * Debugging migration * Fixes for Migration
This commit is contained in:
parent
a303026b14
commit
eba0c19824
@ -229,7 +229,7 @@ class MigrationController extends BaseController
|
|||||||
if (app()->environment() == 'testing') {
|
if (app()->environment() == 'testing') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $company);
|
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $company);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
@ -49,8 +49,9 @@ class QueryLogging
|
|||||||
$time = $timeEnd - $timeStart;
|
$time = $timeEnd - $timeStart;
|
||||||
Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
|
Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
|
||||||
|
|
||||||
// if($count > 50)
|
if($count > 50)
|
||||||
// Log::info($queries);
|
Log::info($queries);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class Import implements ShouldQueue
|
|||||||
'payments',
|
'payments',
|
||||||
'credits',
|
'credits',
|
||||||
'company_gateways',
|
'company_gateways',
|
||||||
'documents',
|
//'documents',
|
||||||
'client_gateway_tokens',
|
'client_gateway_tokens',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -107,6 +107,10 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
public $tries = 1;
|
public $tries = 1;
|
||||||
|
|
||||||
|
public $timeout = 86400;
|
||||||
|
|
||||||
|
public $retryAfter = 86430;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*
|
*
|
||||||
@ -131,14 +135,19 @@ class Import implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach ($this->data as $key => $resource) {
|
foreach ($this->data as $key => $resource) {
|
||||||
|
|
||||||
if (!in_array($key, $this->available_imports)) {
|
if (!in_array($key, $this->available_imports)) {
|
||||||
throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
//throw new ResourceNotAvailableForMigration("Resource {$key} is not available for migration.");
|
||||||
|
\Log::error("cannot migrate {$key} yet....");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = sprintf("process%s", Str::ucfirst(Str::camel($key)));
|
$method = sprintf("process%s", Str::ucfirst(Str::camel($key)));
|
||||||
|
|
||||||
|
\Log::error("Importing {$key}");
|
||||||
|
|
||||||
$this->{$method}($resource);
|
$this->{$method}($resource);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -184,10 +193,14 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
foreach ($data['settings'] as $key => $value) {
|
foreach ($data['settings'] as $key => $value) {
|
||||||
|
|
||||||
if($key == 'invoice_design_id' || $key == 'quote_design_id' || $key == 'credit_design_id')
|
if($key == 'invoice_design_id' || $key == 'quote_design_id' || $key == 'credit_design_id'){
|
||||||
{
|
|
||||||
$value = $this->encodePrimaryKey($value);
|
$value = $this->encodePrimaryKey($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($key == 'payment_terms' && $key = ''){
|
||||||
|
$value = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$company_settings->{$key} = $value;
|
$company_settings->{$key} = $value;
|
||||||
|
|
||||||
@ -273,7 +286,7 @@ class Import implements ShouldQueue
|
|||||||
$modified = $resource;
|
$modified = $resource;
|
||||||
unset($modified['id']);
|
unset($modified['id']);
|
||||||
|
|
||||||
$user = $user_repository->save($modified, $this->fetchUser($resource['email']));
|
$user = $user_repository->save($modified, $this->fetchUser($resource['email']), true);
|
||||||
|
|
||||||
$user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT');
|
$user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT');
|
||||||
|
|
||||||
@ -410,6 +423,9 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
unset($modified['id']);
|
unset($modified['id']);
|
||||||
|
|
||||||
|
if(array_key_exists('invitations', $modified))
|
||||||
|
unset($modified['invitations']);
|
||||||
|
|
||||||
$invoice = $invoice_repository->save(
|
$invoice = $invoice_repository->save(
|
||||||
$modified,
|
$modified,
|
||||||
InvoiceFactory::create($this->company->id, $modified['user_id'])
|
InvoiceFactory::create($this->company->id, $modified['user_id'])
|
||||||
@ -455,6 +471,9 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
unset($modified['id']);
|
unset($modified['id']);
|
||||||
|
|
||||||
|
if(array_key_exists('invitations', $modified))
|
||||||
|
unset($modified['invitations']);
|
||||||
|
|
||||||
$credit = $credit_repository->save(
|
$credit = $credit_repository->save(
|
||||||
$modified,
|
$modified,
|
||||||
CreditFactory::create($this->company->id, $modified['user_id'])
|
CreditFactory::create($this->company->id, $modified['user_id'])
|
||||||
@ -501,6 +520,9 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
unset($modified['id']);
|
unset($modified['id']);
|
||||||
|
|
||||||
|
if(array_key_exists('invitations', $modified))
|
||||||
|
unset($modified['invitations']);
|
||||||
|
|
||||||
$invoice = $quote_repository->save(
|
$invoice = $quote_repository->save(
|
||||||
$modified,
|
$modified,
|
||||||
QuoteFactory::create($this->company->id, $modified['user_id'])
|
QuoteFactory::create($this->company->id, $modified['user_id'])
|
||||||
@ -763,4 +785,11 @@ class Import implements ShouldQueue
|
|||||||
|
|
||||||
return $this->transformId('users', $resource['user_id']);
|
return $this->transformId('users', $resource['user_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function failed($exception = null)
|
||||||
|
{
|
||||||
|
\Log::error("the job failed");
|
||||||
|
\Log::error(print_r($exception->getMessage(),1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,13 @@ class StartMigration implements ShouldQueue
|
|||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Company $company
|
* @param Company $company
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public $tries = 1;
|
||||||
|
|
||||||
|
public $timeout = 86400;
|
||||||
|
|
||||||
|
public $retryAfter = 86430;
|
||||||
|
|
||||||
public function __construct($filepath, User $user, Company $company)
|
public function __construct($filepath, User $user, Company $company)
|
||||||
{
|
{
|
||||||
$this->filepath = $filepath;
|
$this->filepath = $filepath;
|
||||||
@ -65,12 +72,15 @@ class StartMigration implements ShouldQueue
|
|||||||
|
|
||||||
auth()->user()->setCompany($this->company);
|
auth()->user()->setCompany($this->company);
|
||||||
|
|
||||||
|
$this->company->setMigration(true);
|
||||||
|
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$archive = $zip->open($this->filepath);
|
$archive = $zip->open($this->filepath);
|
||||||
|
|
||||||
$filename = pathinfo($this->filepath, PATHINFO_FILENAME);
|
$filename = pathinfo($this->filepath, PATHINFO_FILENAME);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!$archive) {
|
if (!$archive) {
|
||||||
throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.');
|
throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.');
|
||||||
}
|
}
|
||||||
@ -82,8 +92,23 @@ class StartMigration implements ShouldQueue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->start($filename);
|
$this->company->setMigration(false);
|
||||||
|
|
||||||
|
$file = storage_path("migrations/$filename/migration.json");
|
||||||
|
|
||||||
|
if (!file_exists($file)) {
|
||||||
|
throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode(file_get_contents($file), 1);
|
||||||
|
|
||||||
|
Import::dispatchNow($data, $this->company, $this->user);
|
||||||
|
|
||||||
|
|
||||||
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
|
} catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
|
||||||
|
|
||||||
|
$this->company->setMigration(false);
|
||||||
|
|
||||||
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
|
Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
|
||||||
|
|
||||||
if (app()->environment() !== 'production') {
|
if (app()->environment() !== 'production') {
|
||||||
@ -93,26 +118,8 @@ class StartMigration implements ShouldQueue
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function failed($exception = null)
|
||||||
/**
|
|
||||||
* Main method to start the migration.
|
|
||||||
* @throws NonExistingMigrationFile
|
|
||||||
*/
|
|
||||||
public function start(string $filename): void
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$file = storage_path("migrations/$filename/migration.json");
|
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
|
||||||
throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$handle = fopen($file, "r");
|
|
||||||
$file = fread($handle, filesize($file));
|
|
||||||
fclose($handle);
|
|
||||||
|
|
||||||
$data = json_decode($file, 1);
|
|
||||||
Import::dispatchNow($data, $this->company, $this->user);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,14 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Notifications\Admin\NewPaymentNotification;
|
use App\Notifications\Admin\NewPaymentNotification;
|
||||||
use App\Repositories\ActivityRepository;
|
use App\Repositories\ActivityRepository;
|
||||||
|
use App\Utils\Traits\Notifications\UserNotifies;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
class PaymentNotification implements ShouldQueue
|
class PaymentNotification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
use UserNotifies;
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
@ -41,13 +43,16 @@ class PaymentNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
$payment = $event->payment;
|
$payment = $event->payment;
|
||||||
|
|
||||||
//todo need to iterate through teh company user and determine if the user
|
|
||||||
//will receive this notification.
|
|
||||||
|
|
||||||
foreach ($payment->company->company_users as $company_user) {
|
foreach ($payment->company->company_users as $company_user) {
|
||||||
if ($company_user->user) {
|
|
||||||
$company_user->user->notify(new NewPaymentNotification($payment, $payment->company));
|
$user = $company_user->user;
|
||||||
}
|
|
||||||
|
$notification = new NewPaymentNotification($payment, $payment->company);
|
||||||
|
$notification->method = $this->findUserEntityNotificationType($payment, $company_user, ['all_notifications']);
|
||||||
|
|
||||||
|
if($user)
|
||||||
|
$user->notify($notification);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($payment->company->slack_webhook_url)) {
|
if (isset($payment->company->slack_webhook_url)) {
|
||||||
|
@ -39,7 +39,7 @@ class UpdateUserLastLogin implements ShouldQueue
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle($event)
|
public function handle($event)
|
||||||
{ //\Log::error("listener firing");
|
{
|
||||||
$user = $event->user;
|
$user = $event->user;
|
||||||
|
|
||||||
$user->last_login = now();
|
$user->last_login = now();
|
||||||
|
@ -388,4 +388,13 @@ class Company extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->slack_webhook_url;
|
return $this->slack_webhook_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setMigration($status)
|
||||||
|
{
|
||||||
|
$this->company_users->each(function ($cu) use($status){
|
||||||
|
$cu->is_migrating=$status;
|
||||||
|
$cu->save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,12 +55,12 @@ class CompanyUser extends Pivot
|
|||||||
|
|
||||||
public function user_pivot()
|
public function user_pivot()
|
||||||
{
|
{
|
||||||
return $this->hasOne(User::class)->withPivot('permissions', 'settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url');
|
return $this->hasOne(User::class)->withPivot('permissions', 'settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url','migrating');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function company_pivot()
|
public function company_pivot()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Company::class)->withPivot('permissions', 'settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url');
|
return $this->hasOne(Company::class)->withPivot('permissions', 'settings', 'is_admin', 'is_owner', 'is_locked', 'slack_webhook_url','migrating');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
@ -31,12 +31,17 @@ class NewPaymentNotification extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
protected $is_system;
|
protected $is_system;
|
||||||
|
|
||||||
|
public $method;
|
||||||
|
|
||||||
public function __construct($payment, $company, $is_system = false, $settings = null)
|
public function __construct($payment, $company, $is_system = false, $settings = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->payment = $payment;
|
$this->payment = $payment;
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
$this->settings = $payment->client->getMergedSettings();
|
$this->settings = $payment->client->getMergedSettings();
|
||||||
$this->is_system = $is_system;
|
$this->is_system = $is_system;
|
||||||
|
$this->method = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,11 +50,15 @@ class NewPaymentNotification extends Notification implements ShouldQueue
|
|||||||
* @param mixed $notifiable
|
* @param mixed $notifiable
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
// public function via($notifiable)
|
||||||
|
// {
|
||||||
|
// return $this->is_system ? ['slack'] : ['mail'];
|
||||||
|
//}
|
||||||
|
|
||||||
public function via($notifiable)
|
public function via($notifiable)
|
||||||
{
|
{
|
||||||
return $this->is_system ? ['slack'] : ['mail'];
|
return $this->method ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mail representation of the notification.
|
* Get the mail representation of the notification.
|
||||||
*
|
*
|
||||||
|
@ -79,15 +79,15 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
|
|
||||||
// Queue::before(function (JobProcessing $event) {
|
// Queue::before(function (JobProcessing $event) {
|
||||||
// \Log::info('Event Job '.$event->connectionName);
|
// // \Log::info('Event Job '.$event->connectionName);
|
||||||
// \Log::info('Event Job '.$event->job);
|
// \Log::error('Event Job '.$event->job->getJobId);
|
||||||
// \Log::info('Event Job '.$event->job->payload());
|
// // \Log::info('Event Job '.$event->job->payload());
|
||||||
// });
|
// });
|
||||||
// //! Update Posted AT
|
//! Update Posted AT
|
||||||
// Queue::after(function (JobProcessed $event) {
|
// Queue::after(function (JobProcessed $event) {
|
||||||
// \Log::info('Event Job '.$event->connectionName);
|
// // \Log::info('Event Job '.$event->connectionName);
|
||||||
// \Log::info('Event Job '.$event->job);
|
// \Log::error('Event Job '.$event->job->getJobId);
|
||||||
// \Log::info('Event Job '.$event->job->payload());
|
// // \Log::info('Event Job '.$event->job->payload());
|
||||||
// });
|
// });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -211,13 +211,14 @@ class BaseRepository
|
|||||||
|
|
||||||
$tmp_data = $data;
|
$tmp_data = $data;
|
||||||
|
|
||||||
|
/* We need to unset some variable as we sometimes unguard the model */
|
||||||
|
|
||||||
if(isset($tmp_data['invitations']))
|
if(isset($tmp_data['invitations']))
|
||||||
unset($tmp_data['invitations']);
|
unset($tmp_data['invitations']);
|
||||||
|
|
||||||
if(isset($tmp_data['client_contacts']))
|
if(isset($tmp_data['client_contacts']))
|
||||||
unset($tmp_data['client_contacts']);
|
unset($tmp_data['client_contacts']);
|
||||||
|
|
||||||
\Log::error(print_r($tmp_data,1));
|
|
||||||
|
|
||||||
$model->fill($tmp_data);
|
$model->fill($tmp_data);
|
||||||
$model->save();
|
$model->save();
|
||||||
@ -244,8 +245,6 @@ class BaseRepository
|
|||||||
|
|
||||||
foreach ($data['invitations'] as $invitation) {
|
foreach ($data['invitations'] as $invitation) {
|
||||||
|
|
||||||
\Log::error(print_r($invitation,1));
|
|
||||||
|
|
||||||
//if no invitations are present - create one.
|
//if no invitations are present - create one.
|
||||||
if (! $this->getInvitation($invitation, $resource)) {
|
if (! $this->getInvitation($invitation, $resource)) {
|
||||||
if (isset($invitation['id'])) {
|
if (isset($invitation['id'])) {
|
||||||
@ -255,8 +254,6 @@ class BaseRepository
|
|||||||
//make sure we are creating an invite for a contact who belongs to the client only!
|
//make sure we are creating an invite for a contact who belongs to the client only!
|
||||||
$contact = ClientContact::find($invitation['client_contact_id']);
|
$contact = ClientContact::find($invitation['client_contact_id']);
|
||||||
|
|
||||||
\Log::error(print_r($contact,1));
|
|
||||||
|
|
||||||
if ($model->client_id == $contact->client_id);
|
if ($model->client_id == $contact->client_id);
|
||||||
{
|
{
|
||||||
$new_invitation = $invitation_factory_class::create($model->company_id, $model->user_id);
|
$new_invitation = $invitation_factory_class::create($model->company_id, $model->user_id);
|
||||||
|
@ -55,8 +55,6 @@ class CompanyRepository extends BaseRepository
|
|||||||
|
|
||||||
$company->save();
|
$company->save();
|
||||||
|
|
||||||
//\Log::error(print_r($company->settings,1));
|
|
||||||
|
|
||||||
return $company;
|
return $company;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class UserRepository extends BaseRepository
|
|||||||
*
|
*
|
||||||
* @return user|\App\Models\user|null user Object
|
* @return user|\App\Models\user|null user Object
|
||||||
*/
|
*/
|
||||||
public function save(array $data, User $user)
|
public function save(array $data, User $user, $is_migrating = false)
|
||||||
{
|
{
|
||||||
$company = auth()->user()->company();
|
$company = auth()->user()->company();
|
||||||
$account_id = $company->account->id;
|
$account_id = $company->account->id;
|
||||||
@ -61,11 +61,13 @@ class UserRepository extends BaseRepository
|
|||||||
if (!$cu) {
|
if (!$cu) {
|
||||||
$data['company_user']['account_id'] = $account_id;
|
$data['company_user']['account_id'] = $account_id;
|
||||||
$data['company_user']['notifications'] = CompanySettings::notificationDefaults();
|
$data['company_user']['notifications'] = CompanySettings::notificationDefaults();
|
||||||
|
$data['company_user']['is_migrating'] = $is_migrating;
|
||||||
$user->companies()->attach($company->id, $data['company_user']);
|
$user->companies()->attach($company->id, $data['company_user']);
|
||||||
} else {
|
} else {
|
||||||
$cu->fill($data['company_user']);
|
$cu->fill($data['company_user']);
|
||||||
$cu->restore();
|
$cu->restore();
|
||||||
$cu->tokens()->restore();
|
$cu->tokens()->restore();
|
||||||
|
$cu->is_migrating = true;
|
||||||
$cu->save();
|
$cu->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +140,6 @@ class SystemHealth
|
|||||||
Mail::to(config('mail.from.address'))
|
Mail::to(config('mail.from.address'))
|
||||||
->send(new TestMailServer('Email Server Works!', config('mail.from.address')));
|
->send(new TestMailServer('Email Server Works!', config('mail.from.address')));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Log::error($e->getMessage());
|
|
||||||
|
|
||||||
return $e->getMessage();
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,8 +151,6 @@ class SystemHealth
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (Mail::failures() > 0) {
|
if (Mail::failures() > 0) {
|
||||||
\Log::error(print_r(Mail::failures(), 1));
|
|
||||||
|
|
||||||
return Mail::failures();
|
return Mail::failures();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,18 +84,48 @@ trait CompanyGatewayFeesAndLimitsSaver
|
|||||||
{
|
{
|
||||||
$new_arr = [];
|
$new_arr = [];
|
||||||
|
|
||||||
|
if(!is_array($fees_and_limits))
|
||||||
|
return $new_arr;
|
||||||
|
|
||||||
|
$fal = new FeesAndLimits;
|
||||||
|
|
||||||
foreach ($fees_and_limits as $key => $value) {
|
foreach ($fees_and_limits as $key => $value) {
|
||||||
$fal = new FeesAndLimits;
|
|
||||||
|
|
||||||
foreach ($value as $k => $v) {
|
$key = $this->transformFeesAndLimitsKeys($key);
|
||||||
$fal->{$k} = $v;
|
|
||||||
$fal->{$k} = BaseSettings::castAttribute(FeesAndLimits::$casts[$k], $v);
|
$fal->{$key} = BaseSettings::castAttribute(FeesAndLimits::$casts[$key], $value);
|
||||||
}
|
|
||||||
|
|
||||||
$new_arr[$key] = (array)$fal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $new_arr;
|
return $fal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function transformFeesAndLimitsKeys($key)
|
||||||
|
{
|
||||||
|
switch ($key) {
|
||||||
|
case 'tax_name1':
|
||||||
|
return 'fee_tax_name1';
|
||||||
|
break;
|
||||||
|
case 'tax_name2':
|
||||||
|
return 'fee_tax_name2';
|
||||||
|
break;
|
||||||
|
case 'tax_name3':
|
||||||
|
return 'fee_tax_name3';
|
||||||
|
break;
|
||||||
|
case 'tax_rate1':
|
||||||
|
return 'fee_tax_rate1';
|
||||||
|
break;
|
||||||
|
case 'tax_rate2':
|
||||||
|
return 'fee_tax_rate2';
|
||||||
|
break;
|
||||||
|
case 'tax_rate3':
|
||||||
|
return 'fee_tax_rate3';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return $key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,8 +246,6 @@ trait GeneratesCounter
|
|||||||
*/
|
*/
|
||||||
public function hasSharedCounter(Client $client) : bool
|
public function hasSharedCounter(Client $client) : bool
|
||||||
{
|
{
|
||||||
// \Log::error((bool) $client->getSetting('shared_invoice_quote_counter'));
|
|
||||||
// \Log::error($client->getSetting('shared_invoice_quote_counter'));
|
|
||||||
return (bool) $client->getSetting('shared_invoice_quote_counter');
|
return (bool) $client->getSetting('shared_invoice_quote_counter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ trait UserNotifies
|
|||||||
{
|
{
|
||||||
public function findUserNotificationTypes($invitation, $company_user, $entity_name, $required_permissions) :array
|
public function findUserNotificationTypes($invitation, $company_user, $entity_name, $required_permissions) :array
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if($this->migrationRunning($company_user))
|
||||||
|
return [];
|
||||||
|
|
||||||
$notifiable_methods = [];
|
$notifiable_methods = [];
|
||||||
$notifications = $company_user->notifications;
|
$notifications = $company_user->notifications;
|
||||||
|
|
||||||
@ -32,7 +36,37 @@ trait UserNotifies
|
|||||||
|
|
||||||
// if(count(array_intersect($required_permissions, $notifications->slack)) >=1)
|
// if(count(array_intersect($required_permissions, $notifications->slack)) >=1)
|
||||||
// array_push($notifiable_methods, 'slack');
|
// array_push($notifiable_methods, 'slack');
|
||||||
|
|
||||||
return $notifiable_methods;
|
return $notifiable_methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function findUserEntityNotificationType($entity, $company_user, $required_permissions) :array
|
||||||
|
{
|
||||||
|
|
||||||
|
if($this->migrationRunning($company_user))
|
||||||
|
return [];
|
||||||
|
|
||||||
|
$notifiable_methods = [];
|
||||||
|
$notifications = $company_user->notifications;
|
||||||
|
|
||||||
|
if ($entity->user_id == $company_user->_user_id || $entity->assigned_user_id == $company_user->user_id) {
|
||||||
|
array_push($required_permissions, "all_user_notifications");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count(array_intersect($required_permissions, $notifications->email)) >=1) {
|
||||||
|
array_push($notifiable_methods, 'mail');
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(count(array_intersect($required_permissions, $notifications->slack)) >=1)
|
||||||
|
// array_push($notifiable_methods, 'slack');
|
||||||
|
|
||||||
|
return $notifiable_methods;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function migrationRunning($company_user)
|
||||||
|
{
|
||||||
|
return $company_user->is_migrating;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,7 @@ class CreateUsersTable extends Migration
|
|||||||
$table->string('slack_webhook_url');
|
$table->string('slack_webhook_url');
|
||||||
$table->boolean('is_owner')->default(false);
|
$table->boolean('is_owner')->default(false);
|
||||||
$table->boolean('is_admin')->default(false);
|
$table->boolean('is_admin')->default(false);
|
||||||
|
$table->boolean('is_migrating')->default(false);
|
||||||
$table->boolean('is_locked')->default(false); // locks user out of account
|
$table->boolean('is_locked')->default(false); // locks user out of account
|
||||||
|
|
||||||
$table->softDeletes('deleted_at', 6);
|
$table->softDeletes('deleted_at', 6);
|
||||||
|
@ -40,39 +40,6 @@ class AccountTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function testAccountCreation()
|
|
||||||
// {
|
|
||||||
// $data = [
|
|
||||||
// 'first_name' => $this->faker->firstName,
|
|
||||||
// 'last_name' => $this->faker->lastName,
|
|
||||||
// 'name' => $this->faker->company,
|
|
||||||
// 'email' => $this->faker->unique()->safeEmail,
|
|
||||||
// 'password' => 'ALongAndBrilliantPassword123',
|
|
||||||
// '_token' => csrf_token(),
|
|
||||||
// 'privacy_policy' => 1,
|
|
||||||
// 'terms_of_service' => 1
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// try {
|
|
||||||
|
|
||||||
// $response = $this->post('/signup', $data, ['X-API-SECRET' => 'password']);
|
|
||||||
|
|
||||||
// }
|
|
||||||
// catch(ValidationException $e) {
|
|
||||||
|
|
||||||
// $message = json_decode($e->validator->getMessageBag(),1);
|
|
||||||
|
|
||||||
// \Log::error($message);
|
|
||||||
// }
|
|
||||||
// finally {
|
|
||||||
// $response->assertStatus(200);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $response->assertStatus(200);
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function testApiAccountCreation()
|
public function testApiAccountCreation()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -358,7 +358,6 @@ class ClientTest extends TestCase
|
|||||||
])->post('/api/v1/clients/', $data);
|
])->post('/api/v1/clients/', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
//\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,8 +380,6 @@ class ClientTest extends TestCase
|
|||||||
])->post('/api/v1/clients/', $data);
|
])->post('/api/v1/clients/', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
////\Log::error($message);
|
|
||||||
//$this->assertNotNull($message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
@ -410,7 +407,6 @@ class ClientTest extends TestCase
|
|||||||
])->post('/api/v1/clients/', $data);
|
])->post('/api/v1/clients/', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
//\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +424,6 @@ class ClientTest extends TestCase
|
|||||||
|
|
||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
|
|
||||||
//\Log::error($arr);
|
|
||||||
$safe_email = $this->faker->unique()->safeEmail;
|
$safe_email = $this->faker->unique()->safeEmail;
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -450,7 +445,6 @@ class ClientTest extends TestCase
|
|||||||
])->post('/api/v1/clients/', $data);
|
])->post('/api/v1/clients/', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
//\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +479,6 @@ class ClientTest extends TestCase
|
|||||||
])->post('/api/v1/clients/', $data);
|
])->post('/api/v1/clients/', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
//\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ class CompanySettingsTest extends TestCase
|
|||||||
])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray());
|
])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray());
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
\Log::error($message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response) {
|
if ($response) {
|
||||||
|
@ -148,10 +148,6 @@ class CompanyTest extends TestCase
|
|||||||
])->get('/api/v1/companies/'.$this->encodePrimaryKey($company->id))
|
])->get('/api/v1/companies/'.$this->encodePrimaryKey($company->id))
|
||||||
->assertStatus(200)->decodeResponseJson();
|
->assertStatus(200)->decodeResponseJson();
|
||||||
|
|
||||||
//\Log::error($response);
|
|
||||||
//$this->assertEquals(1, $response['data']['size_id']);
|
|
||||||
|
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $token,
|
'X-API-TOKEN' => $token,
|
||||||
|
@ -188,9 +188,7 @@ class PaymentTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/payments?include=invoices', $data);
|
])->post('/api/v1/payments?include=invoices', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// \Log::error('in the validator');
|
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
// \Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +306,6 @@ class PaymentTest extends TestCase
|
|||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
//\Log::error($message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response) {
|
if ($response) {
|
||||||
@ -390,8 +387,6 @@ class PaymentTest extends TestCase
|
|||||||
])->post('/api/v1/payments?include=invoices', $data);
|
])->post('/api/v1/payments?include=invoices', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
//\Log::error($message);
|
|
||||||
//\Log::error('errrr');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
@ -516,8 +511,6 @@ class PaymentTest extends TestCase
|
|||||||
$this->assertTrue(array_key_exists('amount', $message));
|
$this->assertTrue(array_key_exists('amount', $message));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if($response)
|
|
||||||
// $response->assertStatus(200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -795,13 +788,10 @@ class PaymentTest extends TestCase
|
|||||||
])->put('/api/v1/payments/'.$this->encodePrimaryKey($payment->id), $data);
|
])->put('/api/v1/payments/'.$this->encodePrimaryKey($payment->id), $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
// \Log::error(print_r($e->validator->getMessageBag(),1));
|
|
||||||
|
|
||||||
$this->assertTrue(array_key_exists('invoices', $message));
|
$this->assertTrue(array_key_exists('invoices', $message));
|
||||||
// \Log::error('hit error');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//$response->assertStatus(302);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -897,7 +887,6 @@ class PaymentTest extends TestCase
|
|||||||
\Log::error(print_r($e->validator->getMessageBag(), 1));
|
\Log::error(print_r($e->validator->getMessageBag(), 1));
|
||||||
|
|
||||||
$this->assertTrue(array_key_exists('invoices', $message));
|
$this->assertTrue(array_key_exists('invoices', $message));
|
||||||
//\Log::error('hit error');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
@ -948,9 +937,7 @@ class PaymentTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/payments?include=invoices', $data);
|
])->post('/api/v1/payments?include=invoices', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// \Log::error('in the validator');
|
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
// \Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,9 +997,7 @@ class PaymentTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/payments?include=invoices', $data);
|
])->post('/api/v1/payments?include=invoices', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// \Log::error('in the validator');
|
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
// \Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1089,9 +1074,7 @@ class PaymentTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/payments?include=invoices', $data);
|
])->post('/api/v1/payments?include=invoices', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// \Log::error('in the validator');
|
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1143,9 +1126,7 @@ class PaymentTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->post('/api/v1/payments?include=invoices', $data);
|
])->post('/api/v1/payments?include=invoices', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// \Log::error('in the validator');
|
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
//\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +49,6 @@ class PreviewTest extends TestCase
|
|||||||
{
|
{
|
||||||
$design = Design::find(3);
|
$design = Design::find(3);
|
||||||
|
|
||||||
// $designer = new Designer($this->invoice, $design, $this->company->settings->pdf_variables, 'invoice');
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'entity' => 'invoice',
|
'entity' => 'invoice',
|
||||||
'entity_id' => $this->invoice->hashed_id,
|
'entity_id' => $this->invoice->hashed_id,
|
||||||
@ -67,9 +65,6 @@ class PreviewTest extends TestCase
|
|||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
// $arr = $response->json();
|
|
||||||
|
|
||||||
// \Log::error($arr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,8 +85,5 @@ class PreviewTest extends TestCase
|
|||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
// $arr = $response->json();
|
|
||||||
|
|
||||||
// \Log::error($arr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,6 @@ class RefundTest extends TestCase
|
|||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
|
|
||||||
\Log::error($message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
@ -602,7 +601,6 @@ class RefundTest extends TestCase
|
|||||||
|
|
||||||
$payment = Payment::find($this->decodePrimaryKey($arr['data']['id']));
|
$payment = Payment::find($this->decodePrimaryKey($arr['data']['id']));
|
||||||
|
|
||||||
// \Log::error(print_r($payment->paymentables->toArray(),1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Additional scenarios*/
|
/*Additional scenarios*/
|
||||||
|
@ -177,9 +177,7 @@ class MultiDBUserTest extends TestCase
|
|||||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||||
])->post('/api/v1/users?include=company_user', $data);
|
])->post('/api/v1/users?include=company_user', $data);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
\Log::error('in the validator');
|
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,8 +190,6 @@ class MultiDBUserTest extends TestCase
|
|||||||
public function test_cross_db_user_linking_succeeds_appropriately()
|
public function test_cross_db_user_linking_succeeds_appropriately()
|
||||||
{
|
{
|
||||||
|
|
||||||
//$this->withoutExceptionHandling();
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'first_name' => 'hey',
|
'first_name' => 'hey',
|
||||||
'last_name' => 'you',
|
'last_name' => 'you',
|
||||||
|
@ -50,9 +50,7 @@ class UpdateCompanyUserTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->put('/api/v1/company_users/'.$this->encodePrimaryKey($this->user->id), $user);
|
])->put('/api/v1/company_users/'.$this->encodePrimaryKey($this->user->id), $user);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// \Log::error('in the validator');
|
|
||||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||||
//\Log::error($message);
|
|
||||||
$this->assertNotNull($message);
|
$this->assertNotNull($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,34 +23,6 @@ class PdfVariablesTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->assertTrue(is_array($this->settings->pdf_variables->client_details));
|
$this->assertTrue(is_array($this->settings->pdf_variables->client_details));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public function testPdfVariableDefaults()
|
|
||||||
{
|
|
||||||
$pdf_variables = $this->settings->pdf_variables;
|
|
||||||
|
|
||||||
$this->assertEquals(ctrans('texts.client_name'), $pdf_variables->client_details->{'$client.name'});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPdfVariablesConvertedToArray()
|
|
||||||
{
|
|
||||||
$pdf_variables = json_decode(json_encode($this->settings->pdf_variables), true);
|
|
||||||
|
|
||||||
$this->assertEquals(ctrans('texts.client_name'), $pdf_variables['client_details']['$client.name']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testReplaceSampleHeaderText()
|
|
||||||
{
|
|
||||||
$pdf_variables = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->settings->pdf_variables)));
|
|
||||||
|
|
||||||
//\Log::error(print_r($pdf_variables,1));
|
|
||||||
|
|
||||||
$sample_header_text = '<tr><td>$client.name</td><td>$product.product_key</td><td>$product.line_total</td></tr>';
|
|
||||||
|
|
||||||
$replaced_header_text = str_replace(array_keys($pdf_variables), array_values($pdf_variables), $sample_header_text);
|
|
||||||
|
|
||||||
$this->assertEquals($replaced_header_text, '<tr><td>Client Name</td><td>Product</td><td>Line Total</td></tr>');
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,5 @@ class SystemHealthTest extends TestCase
|
|||||||
$this->assertTrue($results['extensions'][2]['curl']);
|
$this->assertTrue($results['extensions'][2]['curl']);
|
||||||
$this->assertTrue($results['extensions'][3]['zip']);
|
$this->assertTrue($results['extensions'][3]['zip']);
|
||||||
|
|
||||||
// \Log::error(print_r($results,1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user