mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 21:47:32 -05:00 
			
		
		
		
	Fixes for tests
This commit is contained in:
		
							parent
							
								
									2faff4eb05
								
							
						
					
					
						commit
						d53418f041
					
				@ -20,7 +20,6 @@ class CompanyGatewayFactory
 | 
				
			|||||||
        $company_gateway = new CompanyGateway;
 | 
					        $company_gateway = new CompanyGateway;
 | 
				
			||||||
        $company_gateway->company_id = $company_id;
 | 
					        $company_gateway->company_id = $company_id;
 | 
				
			||||||
        $company_gateway->user_id = $user_id;
 | 
					        $company_gateway->user_id = $user_id;
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $company_gateway;
 | 
					        return $company_gateway;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										17
									
								
								database/factories/GatewayFactory.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								database/factories/GatewayFactory.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Faker\Generator as Faker;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$factory->define(App\Models\Gateway::class, function (Faker $faker) {
 | 
				
			||||||
 | 
					    return [
 | 
				
			||||||
 | 
					        'key' => '3b6621f970ab18887c4f6dca78d3f8bb',
 | 
				
			||||||
 | 
					        'visible' => true,
 | 
				
			||||||
 | 
					        'sort_order' =>1,
 | 
				
			||||||
 | 
					        'name' => 'demo',
 | 
				
			||||||
 | 
					        'provider' =>  'test',
 | 
				
			||||||
 | 
					        'is_offsite' => true,
 | 
				
			||||||
 | 
					        'is_secure' => true,
 | 
				
			||||||
 | 
					        'fields' => '',
 | 
				
			||||||
 | 
					        'default_gateway_type_id' => 1,
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@ -21,6 +21,7 @@ use Illuminate\Support\Facades\Log;
 | 
				
			|||||||
use Illuminate\Support\Facades\Session;
 | 
					use Illuminate\Support\Facades\Session;
 | 
				
			||||||
use Tests\MockAccountData;
 | 
					use Tests\MockAccountData;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					use PaymentLibrariesSeeder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @test
 | 
					 * @test
 | 
				
			||||||
@ -48,6 +49,7 @@ class CompanyGatewayApiTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testCompanyGatewayEndPoints()
 | 
					    public function testCompanyGatewayEndPoints()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $data = [
 | 
					        $data = [
 | 
				
			||||||
            'config' => 'random config',
 | 
					            'config' => 'random config',
 | 
				
			||||||
            'gateway_key' => '3b6621f970ab18887c4f6dca78d3f8bb',
 | 
					            'gateway_key' => '3b6621f970ab18887c4f6dca78d3f8bb',
 | 
				
			||||||
@ -67,55 +69,31 @@ class CompanyGatewayApiTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $response->assertStatus(200);
 | 
					        $response->assertStatus(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /* GET */
 | 
					 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					 | 
				
			||||||
                'X-API-SECRET' => config('ninja.api_secret'),
 | 
					 | 
				
			||||||
                'X-API-TOKEN' => $this->token
 | 
					 | 
				
			||||||
            ])->get("/api/v1/company_gateways/{$cg_id}");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $response->assertStatus(200);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /* GET CREATE */
 | 
					 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					 | 
				
			||||||
                'X-API-SECRET' => config('ninja.api_secret'),
 | 
					 | 
				
			||||||
                'X-API-TOKEN' => $this->token
 | 
					 | 
				
			||||||
            ])->get('/api/v1/company_gateways/create');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $response->assertStatus(200);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /* PUT */
 | 
					        /* PUT */
 | 
				
			||||||
        $data = [
 | 
					        $data = [
 | 
				
			||||||
            'config' => 'changed',
 | 
					            'config' => 'changed',
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					        $response = $this->withHeaders([
 | 
				
			||||||
                'X-API-SECRET' => config('ninja.api_secret'),
 | 
					                'X-API-SECRET' => config('ninja.api_secret'),
 | 
				
			||||||
                'X-API-TOKEN' => $this->token
 | 
					                'X-API-TOKEN' => $this->token
 | 
				
			||||||
            ])->put("/api/v1/company_gateways/".$cg_id, $data);
 | 
					            ])->put("/api/v1/company_gateways/".$cg_id, $data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $response->assertStatus(200);
 | 
					        $response->assertStatus(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					        $response = $this->withHeaders([
 | 
				
			||||||
                'X-API-SECRET' => config('ninja.api_secret'),
 | 
					                'X-API-SECRET' => config('ninja.api_secret'),
 | 
				
			||||||
                'X-API-TOKEN' => $this->token
 | 
					                'X-API-TOKEN' => $this->token
 | 
				
			||||||
            ])->delete("/api/v1/company_gateways/{$cg_id}", $data);
 | 
					            ])->delete("/api/v1/company_gateways/{$cg_id}", $data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $response->assertStatus(200);
 | 
					        $response->assertStatus(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testCompanyGatewayFeesAndLimitsSuccess()
 | 
					    public function testCompanyGatewayFeesAndLimitsSuccess()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $fee = new FeesAndLimits;
 | 
					        $fee = new FeesAndLimits;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $fee = (array)$fee;
 | 
					        $fee = (array)$fee;
 | 
				
			||||||
@ -164,6 +142,7 @@ class CompanyGatewayApiTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testCompanyGatewayFeesAndLimitsFails()
 | 
					    public function testCompanyGatewayFeesAndLimitsFails()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $fee_and_limit['bank_transfer'] = new FeesAndLimits;
 | 
					        $fee_and_limit['bank_transfer'] = new FeesAndLimits;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $fee_and_limit['bank_transfer']->adjust_fee_percent = 10;
 | 
					        $fee_and_limit['bank_transfer']->adjust_fee_percent = 10;
 | 
				
			||||||
@ -186,6 +165,7 @@ class CompanyGatewayApiTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testCompanyGatewayArrayBuilder()
 | 
					    public function testCompanyGatewayArrayBuilder()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $arr = [
 | 
					        $arr = [
 | 
				
			||||||
            'min_limit' => 1,
 | 
					            'min_limit' => 1,
 | 
				
			||||||
            'max_limit' => 2
 | 
					            'max_limit' => 2
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user