Skip to content

A free open source IT asset/license management system

(develop): Fix failing Unit Tests (#6807)

Martin Mereditha462e9198360
diff --git a/app/Importer/UserImporter.php b/app/Importer/UserImporter.php
index 206e39e6b7..4b8b75ad93 100644
--- a/app/Importer/UserImporter.php
+++ b/app/Importer/UserImporter.php
@@ -19,6 +19,8 @@ use App\Notifications\WelcomeNotification;
class UserImporter extends ItemImporter
{
protected $users;
+ protected $send_welcome = false;
+
public function __construct($filename)
{
parent::__construct($filename);
@@ -92,6 +94,7 @@ class UserImporter extends ItemImporter
'last_name' => $user->last_name,
'password' => $this->tempPassword,
];
+
if ($this->send_welcome) {
$user->notify(new WelcomeNotification($data));
}
@@ -131,4 +134,8 @@ class UserImporter extends ItemImporter
$this->logError($department, 'Company');
return null;
}
+
+ public function sendWelcome($send = true) {
+ $this->send_welcome = $send;
+ }
}
diff --git a/tests/unit/DepreciationTest.php b/tests/unit/DepreciationTest.php
index b883b891b1..9e442b1d4a 100644
--- a/tests/unit/DepreciationTest.php
+++ b/tests/unit/DepreciationTest.php
@@ -39,7 +39,7 @@ class DepreciationTest extends BaseTest
{
$category = $this->createValidCategory('license-graphics-category');
$depreciation = $this->createValidDepreciation('computer', ['name' => 'New Depreciation']);
- $licenses = factory(App\Models\LicenseModel::class, 5)->states('photoshop')->create([
+ $licenses = factory(App\Models\License::class, 5)->states('photoshop')->create([
'depreciation_id'=>$depreciation->id,
'category_id' => $category->id
]);
diff --git a/tests/unit/ImporterTest.php b/tests/unit/ImporterTest.php
index 666305f00e..8fdaaf9256 100644
--- a/tests/unit/ImporterTest.php
+++ b/tests/unit/ImporterTest.php
@@ -689,12 +689,14 @@ EOT;
Notification::fake();
$this->signIn();
$csv = <<<'EOT'
-First Name,Last Name,email,Username,Location,Phone Number,Job Title,Employee Number,Company,Department
-Blanche,O'Collopy,[email protected],bocollopy0,Hinapalanan,63-(199)661-2186,Clinical Specialist,7080919053,Morar-Ward,Management
-Jessie,Primo,,jprimo1,Korenovsk,7-(885)578-0266,Paralegal,6284292031,Jast-Stiedemann
+First Name,Last Name,email,Username,Location,Phone Number,Job Title,Employee Number,Company,Department,activated
+Blanche,O'Collopy,[email protected],bocollopy0,Hinapalanan,63-(199)661-2186,Clinical Specialist,7080919053,Morar-Ward,Management,1
+Jessie,Primo,,jprimo1,Korenovsk,7-(885)578-0266,Paralegal,6284292031,Jast-Stiedemann,1
EOT;
- $this->import(new UserImporter($csv));
+ $user_importer = new UserImporter($csv);
+ $user_importer->sendWelcome();
+ $this->import($user_importer);
$this->tester->seeRecord('users', [
'first_name' => 'Blanche',