From d3c8060dfb7870989ef83e6d797d58c6f24b4a90 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 27 May 2021 11:19:07 +1000 Subject: [PATCH] Fixes for tests --- app/DataMapper/CompanySettings.php | 2 +- app/Http/Controllers/UserController.php | 2 -- tests/Feature/Import/ImportCompanyTest.php | 27 +++++++++++++++++++++- tests/Feature/UserTest.php | 14 +++++------ 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 607e638b55eb..f7d4240719fb 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -202,7 +202,7 @@ class CompanySettings extends BaseSettings public $schedule_reminder2 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented public $schedule_reminder3 = ''; // (enum: after_invoice_date, before_due_date, after_due_date) implmemented - public $reminder_send_time = 32400; //number of seconds from UTC +0 to send reminders @TODO + public $reminder_send_time = 0; //number of seconds from UTC +0 to send reminders @TODO public $late_fee_amount1 = 0; //@implemented public $late_fee_amount2 = 0; //@implemented diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 02d9503af1d5..5cdd4f64ac75 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -211,8 +211,6 @@ class UserController extends BaseController $ct = CreateCompanyToken::dispatchNow($company, $user, $user_agent); - nlog("in the store method of the usercontroller class"); - event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); $user->setCompany($company); diff --git a/tests/Feature/Import/ImportCompanyTest.php b/tests/Feature/Import/ImportCompanyTest.php index a30fe6f1144e..6e633aaa78d6 100644 --- a/tests/Feature/Import/ImportCompanyTest.php +++ b/tests/Feature/Import/ImportCompanyTest.php @@ -46,7 +46,6 @@ class ImportCompanyTest extends TestCase ThrottleRequests::class ); - $this->withoutExceptionHandling(); $this->account = Account::factory()->create(); @@ -71,6 +70,32 @@ class ImportCompanyTest extends TestCase unlink($backup_json_file); } + private function unpackZip() + { + + $backup_json_file_zip = base_path().'/tests/Feature/Import/backup.zip'; + + $zip = new \ZipArchive; + $res = $zip->open($backup_json_file_zip); + if ($res === TRUE) { + $zip->extractTo(sys_get_temp_dir()); + $zip->close(); + } + + $backup_json_file = sys_get_temp_dir() . "/backup/backup.json"; + + $backup_json_object = json_decode(file_get_contents($backup_json_file)); + + return $backup_json_object; + } + + private function testAppVersion() + { + $obj = $this->unpackZip(); + + $this->assertEquals("5.1.52", $obj->app_version); + } + public function testImportUsers() { $backup_json_file_zip = base_path().'/tests/Feature/Import/backup.zip'; diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index ab63f8d66917..7d573549342f 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -109,18 +109,18 @@ class UserTest extends TestCase $response = false; - try { +// try { $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, 'X-API-PASSWORD' => 'ALongAndBriliantPassword', ])->post('/api/v1/users?include=company_user', $data); - } catch (ValidationException $e) { - $message = json_decode($e->validator->getMessageBag(), 1); - nlog($message); - $this->assertNotNull($message); - } + // } catch (ValidationException $e) { + // $message = json_decode($e->validator->getMessageBag(), 1); + // nlog($message); + // $this->assertNotNull($message); + // } $response->assertStatus(200); @@ -130,7 +130,7 @@ class UserTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - 'X-API-PASSWORD' => 'ALongAndBriliantPassword', + 'X-API-PASSWORD' => 'ALongAndBriliantPassword', ])->delete('/api/v1/users/'.$this->encodePrimaryKey($user->id).'/detach_from_company?include=company_user'); $response->assertStatus(200);