v2 first commit
This commit is contained in:
		@@ -2,9 +2,7 @@
 | 
			
		||||
 | 
			
		||||
namespace Tests\Feature\Expenses;
 | 
			
		||||
 | 
			
		||||
use App\Models\Common\Item;
 | 
			
		||||
use App\Models\Expense\Bill;
 | 
			
		||||
use App\Models\Expense\Vendor;
 | 
			
		||||
use App\Jobs\Expense\CreateBill;
 | 
			
		||||
use Tests\Feature\FeatureTestCase;
 | 
			
		||||
 | 
			
		||||
class BillsTest extends FeatureTestCase
 | 
			
		||||
@@ -29,8 +27,7 @@ class BillsTest extends FeatureTestCase
 | 
			
		||||
    {
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->post(route('bills.store'), $this->getBillRequest())
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(route('bills.show', ['bill' => 1]));
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
@@ -39,29 +36,27 @@ class BillsTest extends FeatureTestCase
 | 
			
		||||
    {
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->post(route('bills.store'), $this->getBillRequest(1))
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(route('bills.show', ['bill' => 1]));
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testItShouldSeeBillUpdatePage()
 | 
			
		||||
    {
 | 
			
		||||
        $bill = Bill::create($this->getBillRequest());
 | 
			
		||||
        $bill = dispatch_now(new CreateBill($this->getBillRequest()));
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->get(route('bills.edit', ['bill' => $bill->id]))
 | 
			
		||||
            ->assertStatus(200)
 | 
			
		||||
            ->assertSee($bill->vendor_name)
 | 
			
		||||
            ->assertSee($bill->vendor_email);
 | 
			
		||||
            ->assertSee($bill->contact_name)
 | 
			
		||||
            ->assertSee($bill->contact_email);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testItShouldUpdateBill()
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->getBillRequest();
 | 
			
		||||
        $bill = dispatch_now(new CreateBill($this->getBillRequest()));
 | 
			
		||||
 | 
			
		||||
        $bill = Bill::create($request);
 | 
			
		||||
 | 
			
		||||
        $request['vendor_name'] = $this->faker->name;
 | 
			
		||||
        $request['contact_name'] = $this->faker->name;
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->patch(route('bills.update', $bill->id), $request)
 | 
			
		||||
@@ -72,7 +67,7 @@ class BillsTest extends FeatureTestCase
 | 
			
		||||
 | 
			
		||||
    public function testItShouldDeleteBill()
 | 
			
		||||
    {
 | 
			
		||||
        $bill = Bill::create($this->getBillRequest());
 | 
			
		||||
        $bill = dispatch_now(new CreateBill($this->getBillRequest()));
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->delete(route('bills.destroy', $bill->id))
 | 
			
		||||
@@ -90,26 +85,26 @@ class BillsTest extends FeatureTestCase
 | 
			
		||||
        $items = [['name' =>  $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD', 'tax_id' => null]];
 | 
			
		||||
 | 
			
		||||
        $data =  [
 | 
			
		||||
            'vendor_id' => '0',
 | 
			
		||||
            'company_id' => $this->company->id,
 | 
			
		||||
            'billed_at' => $this->faker->date(),
 | 
			
		||||
            'due_at' => $this->faker->date(),
 | 
			
		||||
            'bill_number' => '1',
 | 
			
		||||
            'order_number' => '1',
 | 
			
		||||
            'currency_code' => setting('general.default_currency'),
 | 
			
		||||
            'currency_code' => setting('default.currency'),
 | 
			
		||||
            'currency_rate' => '1',
 | 
			
		||||
            'item' => $items,
 | 
			
		||||
            'items' => $items,
 | 
			
		||||
            'discount' => '0',
 | 
			
		||||
            'notes' => $this->faker->text(5),
 | 
			
		||||
            'category_id' => $this->company->categories()->type('expense')->first()->id,
 | 
			
		||||
            'recurring_frequency' => 'no',
 | 
			
		||||
            'vendor_name' =>  $this->faker->name,
 | 
			
		||||
            'vendor_email' =>$this->faker->email,
 | 
			
		||||
            'vendor_tax_number' => null,
 | 
			
		||||
            'vendor_phone' =>  null,
 | 
			
		||||
            'vendor_address' =>  $this->faker->address,
 | 
			
		||||
            'contact_id' => '0',
 | 
			
		||||
            'contact_name' =>  $this->faker->name,
 | 
			
		||||
            'contact_email' =>$this->faker->email,
 | 
			
		||||
            'contact_tax_number' => null,
 | 
			
		||||
            'contact_phone' =>  null,
 | 
			
		||||
            'contact_address' =>  $this->faker->address,
 | 
			
		||||
            'bill_status_code' => 'draft',
 | 
			
		||||
            'amount' => $amount,
 | 
			
		||||
            'company_id' => $this->company->id,
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        if ($recurring) {
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
namespace Tests\Feature\Expenses;
 | 
			
		||||
 | 
			
		||||
use App\Models\Expense\Payment;
 | 
			
		||||
use App\Models\Banking\Transaction;
 | 
			
		||||
use Illuminate\Http\UploadedFile;
 | 
			
		||||
use Tests\Feature\FeatureTestCase;
 | 
			
		||||
 | 
			
		||||
@@ -11,7 +11,7 @@ class PaymentsTest extends FeatureTestCase
 | 
			
		||||
    public function testItShouldSeePaymentListPage()
 | 
			
		||||
    {
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->get(url('expenses/payments'))
 | 
			
		||||
            ->get(route('payments.index'))
 | 
			
		||||
            ->assertStatus(200)
 | 
			
		||||
            ->assertSeeText(trans_choice('general.payments', 2));
 | 
			
		||||
    }
 | 
			
		||||
@@ -19,7 +19,7 @@ class PaymentsTest extends FeatureTestCase
 | 
			
		||||
    public function testItShouldSeePaymentCreatePage()
 | 
			
		||||
    {
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->get(url('expenses/payments/create'))
 | 
			
		||||
            ->get(route('payments.create'))
 | 
			
		||||
            ->assertStatus(200)
 | 
			
		||||
            ->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.payments', 1)]));
 | 
			
		||||
    }
 | 
			
		||||
@@ -27,9 +27,8 @@ class PaymentsTest extends FeatureTestCase
 | 
			
		||||
    public function testItShouldCreatePayment()
 | 
			
		||||
    {
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->post(url('expenses/payments'), $this->getPaymentRequest())
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(url('expenses/payments'));
 | 
			
		||||
            ->post(route('payments.store'), $this->getPaymentRequest())
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
@@ -38,26 +37,24 @@ class PaymentsTest extends FeatureTestCase
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->getPaymentRequest();
 | 
			
		||||
 | 
			
		||||
        $payment = Payment::create($request);
 | 
			
		||||
        $payment = Transaction::create($request);
 | 
			
		||||
 | 
			
		||||
        $request['name'] = $this->faker->text(15);
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->patch(url('expenses/payments', $payment->id), $request)
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(url('expenses/payments'));
 | 
			
		||||
            ->patch(route('payments.update', $payment->id), $request)
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testItShouldDeletePayment()
 | 
			
		||||
    {
 | 
			
		||||
        $payment = Payment::create($this->getPaymentRequest());
 | 
			
		||||
        $payment = Transaction::create($this->getPaymentRequest());
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->delete(url('expenses/payments', $payment->id))
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(url('expenses/payments'));
 | 
			
		||||
            ->delete(route('payments.destroy', $payment->id))
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
@@ -68,15 +65,15 @@ class PaymentsTest extends FeatureTestCase
 | 
			
		||||
 | 
			
		||||
        return [
 | 
			
		||||
            'company_id' => $this->company->id,
 | 
			
		||||
            'account_id' => setting('general.default_account'),
 | 
			
		||||
            'vendor_id' => '',
 | 
			
		||||
            'type' => 'expense',
 | 
			
		||||
            'account_id' => setting('default.account'),
 | 
			
		||||
            'paid_at' => $this->faker->date(),
 | 
			
		||||
            'amount' => $this->faker->randomFloat(2, 2),
 | 
			
		||||
            'currency_code' => setting('general.default_currency'),
 | 
			
		||||
            'currency_code' => setting('default.currency'),
 | 
			
		||||
            'currency_rate' => '1',
 | 
			
		||||
            'description' => $this->faker->text(5),
 | 
			
		||||
            'category_id' => $this->company->categories()->type('expense')->first()->id,
 | 
			
		||||
            'payment_method' => setting('general.default_payment_method'),
 | 
			
		||||
            'payment_method' => setting('default.payment_method'),
 | 
			
		||||
            'reference' => $this->faker->text(5),
 | 
			
		||||
            'attachment' => $attachment,
 | 
			
		||||
        ];
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
namespace Tests\Feature\Expenses;
 | 
			
		||||
 | 
			
		||||
use App\Models\Expense\Vendor;
 | 
			
		||||
use App\Models\Common\Contact;
 | 
			
		||||
use Tests\Feature\FeatureTestCase;
 | 
			
		||||
 | 
			
		||||
class VendorsTest extends FeatureTestCase
 | 
			
		||||
@@ -27,15 +27,14 @@ class VendorsTest extends FeatureTestCase
 | 
			
		||||
    {
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->post(route('vendors.store'), $this->getVendorRequest())
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(route('vendors.index'));
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testItShouldSeeVendorDetailPage()
 | 
			
		||||
    {
 | 
			
		||||
        $vendor = Vendor::create($this->getVendorRequest());
 | 
			
		||||
        $vendor = Contact::create($this->getVendorRequest());
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->get(route('vendors.show', ['vendor' => $vendor->id]))
 | 
			
		||||
@@ -45,7 +44,7 @@ class VendorsTest extends FeatureTestCase
 | 
			
		||||
 | 
			
		||||
    public function testItShouldSeeVendorUpdatePage()
 | 
			
		||||
    {
 | 
			
		||||
        $vendor = Vendor::create($this->getVendorRequest());
 | 
			
		||||
        $vendor = Contact::create($this->getVendorRequest());
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->get(route('vendors.edit', ['vendor' => $vendor->id]))
 | 
			
		||||
@@ -58,26 +57,24 @@ class VendorsTest extends FeatureTestCase
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->getVendorRequest();
 | 
			
		||||
 | 
			
		||||
        $vendor = Vendor::create($request);
 | 
			
		||||
        $vendor = Contact::create($request);
 | 
			
		||||
 | 
			
		||||
        $request['name'] = $this->faker->name;
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->patch(route('vendors.update', $vendor->id), $request)
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(route('vendors.index'));
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testItShouldDeleteVendor()
 | 
			
		||||
    {
 | 
			
		||||
        $vendor = Vendor::create($this->getVendorRequest());
 | 
			
		||||
        $vendor = Contact::create($this->getVendorRequest());
 | 
			
		||||
 | 
			
		||||
        $this->loginAs()
 | 
			
		||||
            ->delete(route('vendors.destroy', $vendor->id))
 | 
			
		||||
            ->assertStatus(302)
 | 
			
		||||
            ->assertRedirect(route('vendors.index'));
 | 
			
		||||
            ->assertStatus(200);
 | 
			
		||||
 | 
			
		||||
        $this->assertFlashLevel('success');
 | 
			
		||||
    }
 | 
			
		||||
@@ -86,6 +83,7 @@ class VendorsTest extends FeatureTestCase
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'company_id' => $this->company->id,
 | 
			
		||||
            'type' => 'vendor',
 | 
			
		||||
            'name' => $this->faker->name,
 | 
			
		||||
            'email' => $this->faker->email,
 | 
			
		||||
            'tax_number' => $this->faker->randomNumber(9),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user