bank rule testS

This commit is contained in:
David Bomba 2022-11-22 07:14:00 +11:00
parent b3fefb3ac8
commit 3fa0373abb

View File

@ -19,6 +19,7 @@ use App\Models\BankTransaction;
use App\Models\BankTransactionRule; use App\Models\BankTransactionRule;
use App\Models\Invoice; use App\Models\Invoice;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Validation\ValidationException;
use Tests\MockAccountData; use Tests\MockAccountData;
use Tests\TestCase; use Tests\TestCase;
@ -37,6 +38,8 @@ class BankTransactionRuleTest extends TestCase
$this->withoutMiddleware( $this->withoutMiddleware(
ThrottleRequests::class ThrottleRequests::class
); );
$this->withoutExceptionHandling();
} }
public function testUpdateValidationRules() public function testUpdateValidationRules()
@ -64,7 +67,7 @@ class BankTransactionRuleTest extends TestCase
"applies_to" => "DEBIT", "applies_to" => "DEBIT",
"archived_at" => 0, "archived_at" => 0,
"auto_convert" => False, "auto_convert" => False,
"category_id" => $this->expense_category, "category_id" => $this->expense_category->hashed_id,
"is_deleted" => False, "is_deleted" => False,
"isChanged" => True, "isChanged" => True,
"matches_on_all" => True, "matches_on_all" => True,
@ -73,16 +76,25 @@ class BankTransactionRuleTest extends TestCase
"vendor_id" => $this->vendor->hashed_id "vendor_id" => $this->vendor->hashed_id
]; ];
$response = null;
$response = $this->withHeaders([ try {
'X-API-SECRET' => config('ninja.api_secret'), $response = $this->withHeaders([
'X-API-TOKEN' => $this->token, 'X-API-SECRET' => config('ninja.api_secret'),
])->putJson('/api/v1/bank_transaction_rules/'. $br->hashed_id, $data); 'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/bank_transaction_rules/'. $br->hashed_id, $data);
$arr = $response->json(); } catch (ValidationException $e) {
$message = json_decode($e->validator->getMessageBag(), 1);
nlog($message);
}
$response->assertStatus(200); if($response){
$arr = $response->json();
$response->assertStatus(200);
}
} }