2018-10-09 11:24:50 +03:00
|
|
|
<?php
|
|
|
|
|
2019-12-31 15:49:09 +03:00
|
|
|
namespace Tests\Feature\Purchases;
|
2018-10-09 11:24:50 +03:00
|
|
|
|
2019-11-17 15:06:00 +03:00
|
|
|
use App\Jobs\Common\CreateContact;
|
2018-10-09 11:24:50 +03:00
|
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
|
|
|
|
class VendorsTest extends FeatureTestCase
|
|
|
|
{
|
|
|
|
public function testItShouldSeeVendorListPage()
|
|
|
|
{
|
|
|
|
$this->loginAs()
|
|
|
|
->get(route('vendors.index'))
|
|
|
|
->assertStatus(200)
|
|
|
|
->assertSeeText(trans_choice('general.vendors', 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShouldSeeVendorCreatePage()
|
|
|
|
{
|
|
|
|
$this->loginAs()
|
|
|
|
->get(route('vendors.create'))
|
|
|
|
->assertStatus(200)
|
|
|
|
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.vendors', 1)]));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShouldCreateVendor()
|
|
|
|
{
|
|
|
|
$this->loginAs()
|
|
|
|
->post(route('vendors.store'), $this->getVendorRequest())
|
2019-11-16 10:21:14 +03:00
|
|
|
->assertStatus(200);
|
2018-10-09 11:24:50 +03:00
|
|
|
|
|
|
|
$this->assertFlashLevel('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShouldSeeVendorDetailPage()
|
|
|
|
{
|
2019-11-17 15:06:00 +03:00
|
|
|
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
|
2018-10-09 11:24:50 +03:00
|
|
|
|
|
|
|
$this->loginAs()
|
|
|
|
->get(route('vendors.show', ['vendor' => $vendor->id]))
|
|
|
|
->assertStatus(200)
|
|
|
|
->assertSee($vendor->email);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShouldSeeVendorUpdatePage()
|
|
|
|
{
|
2019-11-17 15:06:00 +03:00
|
|
|
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
|
2018-10-09 11:24:50 +03:00
|
|
|
|
|
|
|
$this->loginAs()
|
|
|
|
->get(route('vendors.edit', ['vendor' => $vendor->id]))
|
|
|
|
->assertStatus(200)
|
|
|
|
->assertSee($vendor->email)
|
|
|
|
->assertSee($vendor->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShouldUpdateVendor()
|
|
|
|
{
|
|
|
|
$request = $this->getVendorRequest();
|
|
|
|
|
2019-11-17 15:06:00 +03:00
|
|
|
$vendor = $this->dispatch(new CreateContact($request));
|
2018-10-09 11:24:50 +03:00
|
|
|
|
|
|
|
$request['name'] = $this->faker->name;
|
|
|
|
|
|
|
|
$this->loginAs()
|
|
|
|
->patch(route('vendors.update', $vendor->id), $request)
|
2019-11-16 10:21:14 +03:00
|
|
|
->assertStatus(200);
|
2018-10-09 11:24:50 +03:00
|
|
|
|
|
|
|
$this->assertFlashLevel('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItShouldDeleteVendor()
|
|
|
|
{
|
2019-11-17 15:06:00 +03:00
|
|
|
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
|
2018-10-09 11:24:50 +03:00
|
|
|
|
|
|
|
$this->loginAs()
|
|
|
|
->delete(route('vendors.destroy', $vendor->id))
|
2019-11-16 10:21:14 +03:00
|
|
|
->assertStatus(200);
|
2018-10-09 11:24:50 +03:00
|
|
|
|
|
|
|
$this->assertFlashLevel('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getVendorRequest()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'company_id' => $this->company->id,
|
2019-11-16 10:21:14 +03:00
|
|
|
'type' => 'vendor',
|
2018-10-09 11:24:50 +03:00
|
|
|
'name' => $this->faker->name,
|
|
|
|
'email' => $this->faker->email,
|
|
|
|
'tax_number' => $this->faker->randomNumber(9),
|
|
|
|
'phone' => $this->faker->phoneNumber,
|
|
|
|
'address' => $this->faker->address,
|
|
|
|
'website' => 'www.akaunting.com',
|
|
|
|
'currency_code' => $this->company->currencies()->enabled()->first()->code,
|
|
|
|
'enabled' => $this->faker->boolean ? 1 : 0
|
|
|
|
];
|
|
|
|
}
|
2019-04-02 18:51:06 +03:00
|
|
|
}
|