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

* Reference correct class for Licence Model

* Make sure we activate users in test to send Welcome Notification
This commit is contained in:
Martin Meredith 2019-03-13 17:57:43 +00:00 committed by snipe
parent 400907cc40
commit a462e91983
3 changed files with 14 additions and 5 deletions

View file

@ -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;
}
}

View file

@ -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
]);

View file

@ -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,bocollopy0@livejournal.com,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,bocollopy0@livejournal.com,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',