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