mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 08:17:32 -05:00 
			
		
		
		
	add test quickbooks ingest job
This commit is contained in:
		
							parent
							
								
									207c3ec80a
								
							
						
					
					
						commit
						8e5c6509c2
					
				
							
								
								
									
										53
									
								
								tests/Feature/Jobs/Import/QuickbooksIngestTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								tests/Feature/Jobs/Import/QuickbooksIngestTest.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Tests\Feature\Jobs\Import;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Illuminate\Foundation\Testing\DatabaseTransactions;
 | 
				
			||||||
 | 
					use Illuminate\Foundation\Testing\RefreshDatabase;
 | 
				
			||||||
 | 
					use Illuminate\Foundation\Testing\WithFaker;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Cache;
 | 
				
			||||||
 | 
					use App\Jobs\Import\QuickbooksIngest;
 | 
				
			||||||
 | 
					use Illuminate\Support\Facades\Auth;
 | 
				
			||||||
 | 
					use App\Utils\Traits\MakesHash;
 | 
				
			||||||
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
 | 
					use Tests\MockAccountData;
 | 
				
			||||||
 | 
					use App\Models\Client;
 | 
				
			||||||
 | 
					use ReflectionClass;
 | 
				
			||||||
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class QuickbooksIngestTest extends TestCase
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    use MakesHash;
 | 
				
			||||||
 | 
					    use MockAccountData;
 | 
				
			||||||
 | 
					    use DatabaseTransactions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected $quickbooks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected function setUp(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        parent::setUp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        config(['database.default' => config('ninja.db.default')]);
 | 
				
			||||||
 | 
					        $this->makeTestData();
 | 
				
			||||||
 | 
					        $this->withoutExceptionHandling();
 | 
				
			||||||
 | 
					        Auth::setUser($this->user);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * A basic feature test example.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function testCanQuickbooksIngest(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $data = (json_decode( file_get_contents( base_path('tests/Feature/Import/customers.json') ), true))['Customer'];
 | 
				
			||||||
 | 
					        $hash = Str::random(32);
 | 
				
			||||||
 | 
					        Cache::put($hash.'-client', base64_encode(json_encode($data)), 360);
 | 
				
			||||||
 | 
					        QuickbooksIngest::dispatch([
 | 
				
			||||||
 | 
					            'hash' => $hash,
 | 
				
			||||||
 | 
					            'column_map' => ['client' => ['mapping' => []]],
 | 
				
			||||||
 | 
					            'skip_header' => true,
 | 
				
			||||||
 | 
					            'import_type' => 'quickbooks',
 | 
				
			||||||
 | 
					        ], $this->company )->handle();
 | 
				
			||||||
 | 
					        $this->assertTrue(Client::withTrashed()->where(['company_id' => $this->company->id, 'name' => "Freeman Sporting Goods"])->exists());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user