diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php index d30835056c6f..b44de47fb23c 100644 --- a/app/Http/Controllers/MigrationController.php +++ b/app/Http/Controllers/MigrationController.php @@ -229,7 +229,7 @@ class MigrationController extends BaseController if (app()->environment() == 'testing') { return; } - + StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $company); return response()->json([ diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 110c927b5ccc..69d011c0f59f 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -49,8 +49,9 @@ class QueryLogging $time = $timeEnd - $timeStart; Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); - // if($count > 50) - // Log::info($queries); + if($count > 50) + Log::info($queries); + } } diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 4f1cce5e79a9..68a05184597f 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -82,7 +82,7 @@ class Import implements ShouldQueue 'payments', 'credits', 'company_gateways', - 'documents', + //'documents', 'client_gateway_tokens', ]; @@ -107,6 +107,10 @@ class Import implements ShouldQueue public $tries = 1; + public $timeout = 86400; + + public $retryAfter = 86430; + /** * Create a new job instance. * @@ -131,14 +135,19 @@ class Import implements ShouldQueue */ public function handle() { + foreach ($this->data as $key => $resource) { 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))); + \Log::error("Importing {$key}"); + $this->{$method}($resource); } @@ -184,10 +193,14 @@ class Import implements ShouldQueue 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); - } + } + + if($key == 'payment_terms' && $key = ''){ + $value = -1; + } + $company_settings->{$key} = $value; @@ -273,7 +286,7 @@ class Import implements ShouldQueue $modified = $resource; 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'); @@ -410,6 +423,9 @@ class Import implements ShouldQueue unset($modified['id']); + if(array_key_exists('invitations', $modified)) + unset($modified['invitations']); + $invoice = $invoice_repository->save( $modified, InvoiceFactory::create($this->company->id, $modified['user_id']) @@ -455,6 +471,9 @@ class Import implements ShouldQueue unset($modified['id']); + if(array_key_exists('invitations', $modified)) + unset($modified['invitations']); + $credit = $credit_repository->save( $modified, CreditFactory::create($this->company->id, $modified['user_id']) @@ -501,6 +520,9 @@ class Import implements ShouldQueue unset($modified['id']); + if(array_key_exists('invitations', $modified)) + unset($modified['invitations']); + $invoice = $quote_repository->save( $modified, QuoteFactory::create($this->company->id, $modified['user_id']) @@ -763,4 +785,11 @@ class Import implements ShouldQueue return $this->transformId('users', $resource['user_id']); } + + + public function failed($exception = null) + { + \Log::error("the job failed"); + \Log::error(print_r($exception->getMessage(),1)); + } } diff --git a/app/Jobs/Util/StartMigration.php b/app/Jobs/Util/StartMigration.php index f300f4d12cd7..ba79b13fa271 100644 --- a/app/Jobs/Util/StartMigration.php +++ b/app/Jobs/Util/StartMigration.php @@ -42,6 +42,13 @@ class StartMigration implements ShouldQueue * @param User $user * @param Company $company */ + + public $tries = 1; + + public $timeout = 86400; + + public $retryAfter = 86430; + public function __construct($filepath, User $user, Company $company) { $this->filepath = $filepath; @@ -65,12 +72,15 @@ class StartMigration implements ShouldQueue auth()->user()->setCompany($this->company); + $this->company->setMigration(true); + $zip = new \ZipArchive(); $archive = $zip->open($this->filepath); $filename = pathinfo($this->filepath, PATHINFO_FILENAME); try { + if (!$archive) { throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.'); } @@ -82,8 +92,23 @@ class StartMigration implements ShouldQueue 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) { + + $this->company->setMigration(false); + Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage())); if (app()->environment() !== 'production') { @@ -93,26 +118,8 @@ class StartMigration implements ShouldQueue } - - /** - * Main method to start the migration. - * @throws NonExistingMigrationFile - */ - public function start(string $filename): void + public function failed($exception = null) { - - $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); - } + } diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index 70ca2405b861..3622f644c1a9 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -16,12 +16,14 @@ use App\Models\Invoice; use App\Models\Payment; use App\Notifications\Admin\NewPaymentNotification; use App\Repositories\ActivityRepository; +use App\Utils\Traits\Notifications\UserNotifies; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Notification; class PaymentNotification implements ShouldQueue { + use UserNotifies; /** * Create the event listener. * @@ -41,13 +43,16 @@ class PaymentNotification implements ShouldQueue { $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) { - 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)) { diff --git a/app/Listeners/User/UpdateUserLastLogin.php b/app/Listeners/User/UpdateUserLastLogin.php index 89b96c7b2504..04afbcd3d164 100644 --- a/app/Listeners/User/UpdateUserLastLogin.php +++ b/app/Listeners/User/UpdateUserLastLogin.php @@ -39,7 +39,7 @@ class UpdateUserLastLogin implements ShouldQueue * @return void */ public function handle($event) - { //\Log::error("listener firing"); + { $user = $event->user; $user->last_login = now(); diff --git a/app/Models/Company.php b/app/Models/Company.php index 6eebd2459a31..3f0ec0f05f40 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -388,4 +388,13 @@ class Company extends BaseModel { return $this->slack_webhook_url; } + + public function setMigration($status) + { + $this->company_users->each(function ($cu) use($status){ + $cu->is_migrating=$status; + $cu->save(); + }); + } + } diff --git a/app/Models/CompanyUser.php b/app/Models/CompanyUser.php index 96d8e2bda3bc..e98fdc4723f4 100644 --- a/app/Models/CompanyUser.php +++ b/app/Models/CompanyUser.php @@ -55,12 +55,12 @@ class CompanyUser extends 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() { - 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() diff --git a/app/Notifications/Admin/NewPaymentNotification.php b/app/Notifications/Admin/NewPaymentNotification.php index 6f7043aecb79..c1ac51221987 100644 --- a/app/Notifications/Admin/NewPaymentNotification.php +++ b/app/Notifications/Admin/NewPaymentNotification.php @@ -31,12 +31,17 @@ class NewPaymentNotification extends Notification implements ShouldQueue protected $is_system; + public $method; + public function __construct($payment, $company, $is_system = false, $settings = null) { + $this->payment = $payment; $this->company = $company; $this->settings = $payment->client->getMergedSettings(); $this->is_system = $is_system; + $this->method = null; + } /** @@ -45,11 +50,15 @@ class NewPaymentNotification extends Notification implements ShouldQueue * @param mixed $notifiable * @return array */ + // public function via($notifiable) + // { + // return $this->is_system ? ['slack'] : ['mail']; + //} + public function via($notifiable) { - return $this->is_system ? ['slack'] : ['mail']; + return $this->method ?: []; } - /** * Get the mail representation of the notification. * diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index e3a0e83660da..36bff8015ce3 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -79,15 +79,15 @@ class AppServiceProvider extends ServiceProvider // Queue::before(function (JobProcessing $event) { - // \Log::info('Event Job '.$event->connectionName); - // \Log::info('Event Job '.$event->job); - // \Log::info('Event Job '.$event->job->payload()); + // // \Log::info('Event Job '.$event->connectionName); + // \Log::error('Event Job '.$event->job->getJobId); + // // \Log::info('Event Job '.$event->job->payload()); // }); - // //! Update Posted AT + //! Update Posted AT // Queue::after(function (JobProcessed $event) { - // \Log::info('Event Job '.$event->connectionName); - // \Log::info('Event Job '.$event->job); - // \Log::info('Event Job '.$event->job->payload()); + // // \Log::info('Event Job '.$event->connectionName); + // \Log::error('Event Job '.$event->job->getJobId); + // // \Log::info('Event Job '.$event->job->payload()); // }); } diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 2aeee0765b7d..b0fa871dff4b 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -211,13 +211,14 @@ class BaseRepository $tmp_data = $data; + /* We need to unset some variable as we sometimes unguard the model */ + if(isset($tmp_data['invitations'])) unset($tmp_data['invitations']); if(isset($tmp_data['client_contacts'])) unset($tmp_data['client_contacts']); -\Log::error(print_r($tmp_data,1)); $model->fill($tmp_data); $model->save(); @@ -244,8 +245,6 @@ class BaseRepository foreach ($data['invitations'] as $invitation) { -\Log::error(print_r($invitation,1)); - //if no invitations are present - create one. if (! $this->getInvitation($invitation, $resource)) { 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! $contact = ClientContact::find($invitation['client_contact_id']); -\Log::error(print_r($contact,1)); - if ($model->client_id == $contact->client_id); { $new_invitation = $invitation_factory_class::create($model->company_id, $model->user_id); diff --git a/app/Repositories/CompanyRepository.php b/app/Repositories/CompanyRepository.php index c1095d541100..375ea5b322b7 100644 --- a/app/Repositories/CompanyRepository.php +++ b/app/Repositories/CompanyRepository.php @@ -55,8 +55,6 @@ class CompanyRepository extends BaseRepository $company->save(); - //\Log::error(print_r($company->settings,1)); - return $company; } diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index f211b5f484e9..2bffa773fe5f 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -45,7 +45,7 @@ class UserRepository extends BaseRepository * * @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(); $account_id = $company->account->id; @@ -61,11 +61,13 @@ class UserRepository extends BaseRepository if (!$cu) { $data['company_user']['account_id'] = $account_id; $data['company_user']['notifications'] = CompanySettings::notificationDefaults(); + $data['company_user']['is_migrating'] = $is_migrating; $user->companies()->attach($company->id, $data['company_user']); } else { $cu->fill($data['company_user']); $cu->restore(); $cu->tokens()->restore(); + $cu->is_migrating = true; $cu->save(); } diff --git a/app/Utils/SystemHealth.php b/app/Utils/SystemHealth.php index 46cfd7ee93b3..aae072b46361 100644 --- a/app/Utils/SystemHealth.php +++ b/app/Utils/SystemHealth.php @@ -140,8 +140,6 @@ class SystemHealth Mail::to(config('mail.from.address')) ->send(new TestMailServer('Email Server Works!', config('mail.from.address'))); } catch (\Exception $e) { - \Log::error($e->getMessage()); - return $e->getMessage(); } @@ -153,8 +151,6 @@ class SystemHealth */ if (Mail::failures() > 0) { - \Log::error(print_r(Mail::failures(), 1)); - return Mail::failures(); } diff --git a/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php b/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php index 5cc966a3c9de..0fb785ebec76 100644 --- a/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php +++ b/app/Utils/Traits/CompanyGatewayFeesAndLimitsSaver.php @@ -84,18 +84,48 @@ trait CompanyGatewayFeesAndLimitsSaver { $new_arr = []; + if(!is_array($fees_and_limits)) + return $new_arr; + + $fal = new FeesAndLimits; foreach ($fees_and_limits as $key => $value) { - $fal = new FeesAndLimits; - foreach ($value as $k => $v) { - $fal->{$k} = $v; - $fal->{$k} = BaseSettings::castAttribute(FeesAndLimits::$casts[$k], $v); - } + $key = $this->transformFeesAndLimitsKeys($key); + + $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; + } + } } diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index c0868dd37384..69830861a4f9 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -246,8 +246,6 @@ trait GeneratesCounter */ 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'); } diff --git a/app/Utils/Traits/Notifications/UserNotifies.php b/app/Utils/Traits/Notifications/UserNotifies.php index 9637712028d2..5c5b1d06ed70 100644 --- a/app/Utils/Traits/Notifications/UserNotifies.php +++ b/app/Utils/Traits/Notifications/UserNotifies.php @@ -19,6 +19,10 @@ trait UserNotifies { public function findUserNotificationTypes($invitation, $company_user, $entity_name, $required_permissions) :array { + + if($this->migrationRunning($company_user)) + return []; + $notifiable_methods = []; $notifications = $company_user->notifications; @@ -32,7 +36,37 @@ trait UserNotifies // if(count(array_intersect($required_permissions, $notifications->slack)) >=1) // array_push($notifiable_methods, 'slack'); - + 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; + } } diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 5d99b3563d66..57d09a2b4eae 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -201,6 +201,7 @@ class CreateUsersTable extends Migration $table->string('slack_webhook_url'); $table->boolean('is_owner')->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->softDeletes('deleted_at', 6); diff --git a/tests/Feature/AccountTest.php b/tests/Feature/AccountTest.php index 1472e01d524f..9e50b49598c6 100644 --- a/tests/Feature/AccountTest.php +++ b/tests/Feature/AccountTest.php @@ -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() { diff --git a/tests/Feature/ClientTest.php b/tests/Feature/ClientTest.php index 2bcdb2f195bc..91864c81a9f5 100644 --- a/tests/Feature/ClientTest.php +++ b/tests/Feature/ClientTest.php @@ -358,7 +358,6 @@ class ClientTest extends TestCase ])->post('/api/v1/clients/', $data); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - //\Log::error($message); $this->assertNotNull($message); } @@ -381,8 +380,6 @@ class ClientTest extends TestCase ])->post('/api/v1/clients/', $data); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - ////\Log::error($message); - //$this->assertNotNull($message); } $response->assertStatus(200); @@ -410,7 +407,6 @@ class ClientTest extends TestCase ])->post('/api/v1/clients/', $data); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - //\Log::error($message); $this->assertNotNull($message); } @@ -428,7 +424,6 @@ class ClientTest extends TestCase $arr = $response->json(); - //\Log::error($arr); $safe_email = $this->faker->unique()->safeEmail; $data = [ @@ -450,7 +445,6 @@ class ClientTest extends TestCase ])->post('/api/v1/clients/', $data); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - //\Log::error($message); $this->assertNotNull($message); } @@ -485,7 +479,6 @@ class ClientTest extends TestCase ])->post('/api/v1/clients/', $data); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - //\Log::error($message); $this->assertNotNull($message); } diff --git a/tests/Feature/CompanySettingsTest.php b/tests/Feature/CompanySettingsTest.php index 6c3ed43176ac..e85e263b5098 100644 --- a/tests/Feature/CompanySettingsTest.php +++ b/tests/Feature/CompanySettingsTest.php @@ -64,7 +64,6 @@ class CompanySettingsTest extends TestCase ])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - \Log::error($message); } if ($response) { diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 83678ff00dc0..6209a0e6e1fe 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -148,10 +148,6 @@ class CompanyTest extends TestCase ])->get('/api/v1/companies/'.$this->encodePrimaryKey($company->id)) ->assertStatus(200)->decodeResponseJson(); - //\Log::error($response); - //$this->assertEquals(1, $response['data']['size_id']); - - $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $token, diff --git a/tests/Feature/PaymentTest.php b/tests/Feature/PaymentTest.php index 22cfb42635fa..6edd6a2d52ce 100644 --- a/tests/Feature/PaymentTest.php +++ b/tests/Feature/PaymentTest.php @@ -188,9 +188,7 @@ class PaymentTest extends TestCase 'X-API-TOKEN' => $this->token, ])->post('/api/v1/payments?include=invoices', $data); } catch (ValidationException $e) { - // \Log::error('in the validator'); $message = json_decode($e->validator->getMessageBag(), 1); - // \Log::error($message); $this->assertNotNull($message); } @@ -308,7 +306,6 @@ class PaymentTest extends TestCase } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); $this->assertNotNull($message); - //\Log::error($message); } if ($response) { @@ -390,8 +387,6 @@ class PaymentTest extends TestCase ])->post('/api/v1/payments?include=invoices', $data); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - //\Log::error($message); - //\Log::error('errrr'); } $arr = $response->json(); @@ -516,8 +511,6 @@ class PaymentTest extends TestCase $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); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - // \Log::error(print_r($e->validator->getMessageBag(),1)); $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)); $this->assertTrue(array_key_exists('invoices', $message)); - //\Log::error('hit error'); } $response->assertStatus(200); @@ -948,9 +937,7 @@ class PaymentTest extends TestCase 'X-API-TOKEN' => $this->token, ])->post('/api/v1/payments?include=invoices', $data); } catch (ValidationException $e) { - // \Log::error('in the validator'); $message = json_decode($e->validator->getMessageBag(), 1); - // \Log::error($message); $this->assertNotNull($message); } @@ -1010,9 +997,7 @@ class PaymentTest extends TestCase 'X-API-TOKEN' => $this->token, ])->post('/api/v1/payments?include=invoices', $data); } catch (ValidationException $e) { - // \Log::error('in the validator'); $message = json_decode($e->validator->getMessageBag(), 1); - // \Log::error($message); $this->assertNotNull($message); } @@ -1089,9 +1074,7 @@ class PaymentTest extends TestCase 'X-API-TOKEN' => $this->token, ])->post('/api/v1/payments?include=invoices', $data); } catch (ValidationException $e) { - // \Log::error('in the validator'); $message = json_decode($e->validator->getMessageBag(), 1); - \Log::error($message); $this->assertNotNull($message); } } @@ -1143,9 +1126,7 @@ class PaymentTest extends TestCase 'X-API-TOKEN' => $this->token, ])->post('/api/v1/payments?include=invoices', $data); } catch (ValidationException $e) { - // \Log::error('in the validator'); $message = json_decode($e->validator->getMessageBag(), 1); - //\Log::error($message); $this->assertNotNull($message); } diff --git a/tests/Feature/PreviewTest.php b/tests/Feature/PreviewTest.php index 13eef11f9202..83d819470629 100644 --- a/tests/Feature/PreviewTest.php +++ b/tests/Feature/PreviewTest.php @@ -49,8 +49,6 @@ class PreviewTest extends TestCase { $design = Design::find(3); -// $designer = new Designer($this->invoice, $design, $this->company->settings->pdf_variables, 'invoice'); - $data = [ 'entity' => 'invoice', 'entity_id' => $this->invoice->hashed_id, @@ -67,9 +65,6 @@ class PreviewTest extends TestCase $response->assertStatus(200); - // $arr = $response->json(); - - // \Log::error($arr); } @@ -90,8 +85,5 @@ class PreviewTest extends TestCase $response->assertStatus(200); - // $arr = $response->json(); - - // \Log::error($arr); } } diff --git a/tests/Feature/RefundTest.php b/tests/Feature/RefundTest.php index d041e9710cc0..9bcbd6892aa4 100644 --- a/tests/Feature/RefundTest.php +++ b/tests/Feature/RefundTest.php @@ -120,7 +120,6 @@ class RefundTest extends TestCase } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); - \Log::error($message); } $arr = $response->json(); @@ -602,7 +601,6 @@ class RefundTest extends TestCase $payment = Payment::find($this->decodePrimaryKey($arr['data']['id'])); -// \Log::error(print_r($payment->paymentables->toArray(),1)); } /*Additional scenarios*/ diff --git a/tests/Integration/MultiDBUserTest.php b/tests/Integration/MultiDBUserTest.php index d40f3d88a9e0..c00cdd1bffe5 100644 --- a/tests/Integration/MultiDBUserTest.php +++ b/tests/Integration/MultiDBUserTest.php @@ -177,9 +177,7 @@ class MultiDBUserTest extends TestCase 'X-API-PASSWORD' => 'ALongAndBriliantPassword', ])->post('/api/v1/users?include=company_user', $data); } catch (ValidationException $e) { - \Log::error('in the validator'); $message = json_decode($e->validator->getMessageBag(), 1); - \Log::error($message); $this->assertNotNull($message); } @@ -192,8 +190,6 @@ class MultiDBUserTest extends TestCase public function test_cross_db_user_linking_succeeds_appropriately() { - //$this->withoutExceptionHandling(); - $data = [ 'first_name' => 'hey', 'last_name' => 'you', diff --git a/tests/Integration/UpdateCompanyUserTest.php b/tests/Integration/UpdateCompanyUserTest.php index ef5dc42c953b..6dd406279ba5 100644 --- a/tests/Integration/UpdateCompanyUserTest.php +++ b/tests/Integration/UpdateCompanyUserTest.php @@ -50,9 +50,7 @@ class UpdateCompanyUserTest extends TestCase 'X-API-TOKEN' => $this->token, ])->put('/api/v1/company_users/'.$this->encodePrimaryKey($this->user->id), $user); } catch (ValidationException $e) { - // \Log::error('in the validator'); $message = json_decode($e->validator->getMessageBag(), 1); - //\Log::error($message); $this->assertNotNull($message); } diff --git a/tests/Unit/PdfVariablesTest.php b/tests/Unit/PdfVariablesTest.php index 8c0bf0676de4..815a99faf465 100644 --- a/tests/Unit/PdfVariablesTest.php +++ b/tests/Unit/PdfVariablesTest.php @@ -23,34 +23,6 @@ class PdfVariablesTest extends TestCase { $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 = '