fixed styling..

This commit is contained in:
Cüneyt Şentürk 2021-02-12 13:38:33 +03:00
parent 95e88e04f8
commit 46fdbc5d8a

View File

@ -12,118 +12,113 @@ use Tests\Feature\FeatureTestCase;
class CustomersTest extends FeatureTestCase class CustomersTest extends FeatureTestCase
{ {
public function testItShouldSeeCustomerListPage() public function testItShouldSeeCustomerListPage()
{ {
$this->loginAs() $this->loginAs()
->get(route('customers.index')) ->get(route('customers.index'))
->assertStatus(200) ->assertStatus(200)
->assertSeeText(trans_choice('general.customers', 2)); ->assertSeeText(trans_choice('general.customers', 2));
} }
public function testItShouldSeeCustomerCreatePage() public function testItShouldSeeCustomerCreatePage()
{ {
$this->loginAs() $this->loginAs()
->get(route('customers.create')) ->get(route('customers.create'))
->assertStatus(200) ->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.customers', 1)])); ->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.customers', 1)]));
} }
public function testItShouldCreateCustomer() public function testItShouldCreateCustomer()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('customers.store'), $request) ->post(route('customers.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('contacts', $request); $this->assertDatabaseHas('contacts', $request);
} }
public function testItShouldCreateCustomerWithUser() public function testItShouldCreateCustomerWithUser()
{ {
$request = $this->getRequestWithUser(); $request = $this->getRequestWithUser();
$this->loginAs() $this->loginAs()
->post(route('customers.store'), $request) ->post(route('customers.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$user = User::where('email', $request['email'])->first(); $user = User::where('email', $request['email'])->first();
$this->assertNotNull($user); $this->assertNotNull($user);
$this->assertEquals($request['email'], $user->email); $this->assertEquals($request['email'], $user->email);
} }
public function testItShouldSeeCustomerDetailPage() public function testItShouldSeeCustomerDetailPage()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$customer = $this->dispatch(new CreateContact($request)); $customer = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->get(route('customers.show', $customer->id)) ->get(route('customers.show', $customer->id))
->assertStatus(200) ->assertStatus(200)
->assertSee($customer->email); ->assertSee($customer->email);
} }
public function testItShouldSeeCustomerUpdatePage() public function testItShouldSeeCustomerUpdatePage()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$customer = $this->dispatch(new CreateContact($request)); $customer = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->get(route('customers.edit', $customer->id)) ->get(route('customers.edit', $customer->id))
->assertStatus(200) ->assertStatus(200)
->assertSee($customer->email); ->assertSee($customer->email);
} }
public function testItShouldUpdateCustomer() public function testItShouldUpdateCustomer()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$customer = $this->dispatch(new CreateContact($request)); $customer = $this->dispatch(new CreateContact($request));
$request['email'] = $this->faker->safeEmail; $request['email'] = $this->faker->safeEmail;
$this->loginAs() $this->loginAs()
->patch(route('customers.update', $customer->id), $request) ->patch(route('customers.update', $customer->id), $request)
->assertStatus(200) ->assertStatus(200)
->assertSee($request['email']); ->assertSee($request['email']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('contacts', $request); $this->assertDatabaseHas('contacts', $request);
} }
public function testItShouldDeleteCustomer() public function testItShouldDeleteCustomer()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$customer = $this->dispatch(new CreateContact($request)); $customer = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->delete(route('customers.destroy', $customer->id)) ->delete(route('customers.destroy', $customer->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('contacts', $request); $this->assertSoftDeleted('contacts', $request);
} }
public function testItShouldNotDeleteCustomerIfHasRelations() public function testItShouldNotDeleteCustomerIfHasRelations()
{
$this->assertTrue(true);
//TODO : This will write after done invoice and revenues tests.
}
public function getRequest()
{ {
return Contact::factory()->customer()->enabled()->raw(); $this->assertTrue(true);
//TODO : This will write after done invoice and revenues tests.
} }
public function testItShouldExportCustomers() public function testItShouldExportCustomers()
@ -189,15 +184,20 @@ class CustomersTest extends FeatureTestCase
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
} }
public function getRequestWithUser() public function getRequest()
{ {
$password = $this->faker->password; return Contact::factory()->customer()->enabled()->raw();
}
return $this->getRequest() + [ public function getRequestWithUser()
'create_user' => 'true', {
'locale' => 'en-GB', $password = $this->faker->password;
'password' => $password,
'password_confirmation' => $password, return $this->getRequest() + [
]; 'create_user' => 'true',
} 'locale' => 'en-GB',
'password' => $password,
'password_confirmation' => $password,
];
}
} }