mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 12:17:02 -04:00
Fixes for tests
This commit is contained in:
parent
2f657aaac8
commit
70fe64ed96
@ -13,8 +13,8 @@ group: deprecated-2017Q4
|
|||||||
|
|
||||||
php:
|
php:
|
||||||
- 7.3
|
- 7.3
|
||||||
- 7.4snapshot
|
# - 7.4snapshot
|
||||||
- nightly
|
# - nightly
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
|
@ -106,11 +106,14 @@ class CompanyController extends BaseController
|
|||||||
|
|
||||||
if($request->file('logo'))
|
if($request->file('logo'))
|
||||||
{
|
{
|
||||||
\Log::error('logo exists');
|
|
||||||
$path = UploadAvatar::dispatchNow($request->file('logo'), $company->company_key);
|
$path = UploadAvatar::dispatchNow($request->file('logo'), $company->company_key);
|
||||||
|
|
||||||
if($path){
|
if($path){
|
||||||
$company->logo = $path;
|
|
||||||
|
$settings = $company->settings;
|
||||||
|
$settings->logo_url = config('ninja.site_url').$path;
|
||||||
|
$company->settings = $settings;
|
||||||
$company->save();
|
$company->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,11 +189,15 @@ class CompanyController extends BaseController
|
|||||||
|
|
||||||
if($request->file('logo'))
|
if($request->file('logo'))
|
||||||
{
|
{
|
||||||
\Log::error('logo exists');
|
|
||||||
$path = UploadAvatar::dispatchNow($request->file('logo'), $company->company_key);
|
$path = UploadAvatar::dispatchNow($request->file('logo'), $company->company_key);
|
||||||
|
|
||||||
if($path){
|
if($path){
|
||||||
$company->logo = $path;
|
// $company->logo = $path;
|
||||||
|
//
|
||||||
|
$settings = $company->settings;
|
||||||
|
$settings->logo_url = config('ninja.site_url').$path;
|
||||||
|
$company->settings = $settings;
|
||||||
$company->save();
|
$company->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class StoreProductRequest extends Request
|
|||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
if($input['quantity'] < 1)
|
if(!isset($input['quantity']) || $input['quantity'] < 1)
|
||||||
$input['quantity'] = 1;
|
$input['quantity'] = 1;
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
|
@ -48,7 +48,7 @@ class UpdateProductRequest extends Request
|
|||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
if($input['quantity'] < 1)
|
if(!isset($input['quantity']) || $input['quantity'] < 1)
|
||||||
$input['quantity'] = 1;
|
$input['quantity'] = 1;
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
|
@ -49,13 +49,15 @@ class CreateCompany
|
|||||||
*/
|
*/
|
||||||
public function handle() : ?Company
|
public function handle() : ?Company
|
||||||
{
|
{
|
||||||
|
$settings = CompanySettings::defaults();
|
||||||
|
$settings->name = isset($this->request['name']) ? $this->request['name'] : $this->request['first_name'] . ' ' . $this->request['last_name'];
|
||||||
|
|
||||||
$company = new Company();
|
$company = new Company();
|
||||||
$company->name = isset($this->request['name']) ? $this->request['name'] : $this->request['first_name'] . ' ' . $this->request['last_name'];
|
//$company->name = isset($this->request['name']) ? $this->request['name'] : $this->request['first_name'] . ' ' . $this->request['last_name'];
|
||||||
$company->account_id = $this->account->id;
|
$company->account_id = $this->account->id;
|
||||||
$company->company_key = $this->createHash();
|
$company->company_key = $this->createHash();
|
||||||
$company->ip = request()->ip();
|
$company->ip = request()->ip();
|
||||||
$company->settings = CompanySettings::defaults();
|
$company->settings = $settings;
|
||||||
$company->db = config('database.default');
|
$company->db = config('database.default');
|
||||||
$company->save();
|
$company->save();
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class BaseModel extends Model
|
|||||||
return $this->getSettings()->{$key};
|
return $this->getSettings()->{$key};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log::error(print_r(new CompanySettings($this->company->settings),1));
|
//Log::error(print_r(new CompanySettings($this->company->settings),1));
|
||||||
return (new CompanySettings($this->company->settings))->{$key};
|
return (new CompanySettings($this->company->settings))->{$key};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function getLogo()
|
public function getLogo()
|
||||||
{
|
{
|
||||||
return $this->logo ? config('ninja.site_url').$this->logo : null;
|
return $this->settings->logo ? config('ninja.site_url').$this->settings->logo : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,7 @@ class GroupSetting extends StaticModel
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'settings'
|
'settings'
|
||||||
]
|
];
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
|
@ -318,7 +318,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
public function getEmailVerifiedAt()
|
public function getEmailVerifiedAt()
|
||||||
{
|
{
|
||||||
if($this->email_verified_at)
|
if($this->email_verified_at)
|
||||||
return Carbon::parse($user->email_verified_at)->timestamp;
|
return Carbon::parse($this->email_verified_at)->timestamp;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="false">
|
stopOnFailure="true">
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Unit">
|
<testsuite name="Unit">
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
<directory suffix="Test.php">./tests/Unit</directory>
|
||||||
|
@ -15,6 +15,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
|
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
@ -37,6 +38,8 @@ class UploadLogoTest extends TestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
|
|
||||||
|
Company::reguard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +61,7 @@ class UploadLogoTest extends TestCase
|
|||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
$acc = $response->json();
|
$acc = $response->json();
|
||||||
$logo = $acc['data']['logo_url'];
|
$logo = $acc['data']['settings']['logo_url'];
|
||||||
|
|
||||||
$logo_file = Storage::url($logo);
|
$logo_file = Storage::url($logo);
|
||||||
|
|
||||||
@ -82,11 +85,11 @@ class UploadLogoTest extends TestCase
|
|||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $data);
|
])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $data);
|
||||||
|
|
||||||
$response->assertStatus(302);
|
|
||||||
|
|
||||||
//$acc = $response->json();
|
//$acc = $response->json();
|
||||||
|
|
||||||
//\Log::error(print_r($acc,1));
|
$response->assertStatus(302);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user