1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Fixes for tests - base PHP version now 7.3

This commit is contained in:
David Bomba 2019-07-09 10:01:29 +10:00
parent 1241f14063
commit 60e0e84980
11 changed files with 23 additions and 15 deletions

View File

@ -58,18 +58,15 @@ class CreateAccount
* Create company
*/
$company = CreateCompany::dispatchNow($this->request, $account);
/*
* Set default company
*/
$account->default_company_id = $company->id;
$account->save();
/*
* Create user
*/
$user = CreateUser::dispatchNow($this->request, $account, $company, true); //make user company_owner
/*
* Required dependencies
*/
@ -77,23 +74,20 @@ class CreateAccount
auth()->login($user, false);
$user->setCompany($company);
/*
* Create token
*/
$company_token = CreateCompanyToken::dispatchNow($company, $user);
/*
* Login user
*/
//Auth::loginUsingId($user->id, true);
/*
* Fire related events
*/
if($user)
event(new AccountCreated($user));
return $account;
}
}

View File

@ -18,6 +18,7 @@ use App\Models\User;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class CreateUser
{
@ -30,6 +31,8 @@ class CreateUser
protected $company;
protected $company_owner;
/**
* Create a new job instance.
*

View File

@ -40,7 +40,7 @@ class CreatedUserActivity
$fields = new \stdClass;
if(auth()->user()->id)
if(auth()->user())
$fields->user_id = auth()->user()->id;
else
$fields->user_id = $event->user->id;

View File

@ -29,7 +29,7 @@ class BaseModel extends Model
///const CREATED_AT = 'creation_date';
//const UPDATED_AT = 'last_update';
//protected $dateFormat = 'Y-m-d H:i:s.u';
protected $dateFormat = 'Y-m-d H:i:s.u';
public function __call($method, $params)
{

View File

@ -37,6 +37,9 @@ class ClientContact extends Authenticatable
protected $dates = ['deleted_at'];
protected $dateFormat = 'Y-m-d H:i:s.u';
protected $fillable = [
'first_name',
'last_name',

View File

@ -19,14 +19,13 @@ class CompanyUser extends Pivot
{
protected $guarded = ['id'];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'settings' => 'collection',
'settings' => 'object',
'permissions' => 'object',
];

View File

@ -45,6 +45,8 @@ class User extends Authenticatable implements MustVerifyEmail
protected $with = ['companies','user_companies'];
protected $dateFormat = 'Y-m-d H:i:s.u';
public $company;
/**
@ -77,6 +79,11 @@ class User extends Authenticatable implements MustVerifyEmail
'slack_webhook_url',
];
protected $casts = [
'settings' => 'object',
'permissions' => 'object',
];
/**
* Returns a account.
*
@ -105,6 +112,7 @@ class User extends Authenticatable implements MustVerifyEmail
public function companies()
{
return $this->belongsToMany(Company::class)->using(CompanyUser::class)->withPivot('permissions', 'settings', 'is_admin', 'is_owner', 'is_locked');
}
/**

View File

@ -172,8 +172,6 @@ class CreateUsersTable extends Migration
$table->boolean('is_owner')->default(false);
$table->boolean('is_admin');
$table->boolean('is_locked')->default(false); // locks user out of account
$table->timestamps(6);
$table->softDeletes();
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');

View File

@ -1,5 +1,6 @@
<?php
use App\DataMapper\DefaultSettings;
use App\Models\Account;
use App\Models\Client;
use App\Models\ClientContact;
@ -52,6 +53,8 @@ class RandomDataSeeder extends Seeder
'is_owner' => 1,
'is_admin' => 1,
'is_locked' => 0,
'permissions' => json_encode([]),
'settings' => json_encode(DefaultSettings::userSettings()),
]);
$client = factory(\App\Models\Client::class)->create([

View File

@ -43,7 +43,7 @@
"hashids": "^1.2.2",
"laravel-echo": "^1.4.0",
"lodash.get": "^4.4.2",
"puppeteer": "^1.15.0",
"puppeteer": "^1.18.1",
"quill": "^1.3.6",
"socket.io-client": "^2.1.1",
"ts-loader": "3.5.0",

View File

@ -64,7 +64,7 @@ class ClientTest extends TestCase
$acc = $response->json();
Log::error($acc);
$account = Account::find($this->decodePrimaryKey($acc['data']['id']));
$token = $account->default_company->tokens->first()->token;