Browse Source

Refactor ManagePaymentsTest

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
39fad81641
  1. 34
      resources/lang/id/customer.php
  2. 8
      resources/views/payments/index.blade.php
  3. 4
      tests/Feature/ManageSubscriptionsTest.php
  4. 82
      tests/Feature/Payments/ManagePaymentsTest.php

34
resources/lang/id/customer.php

@ -2,26 +2,28 @@
return [ return [
// Labels // Labels
'customer' => 'Customer',
'list' => 'Customer List',
'search' => 'Search Customer',
'not_found' => 'Customer not found.',
'empty' => 'Customer is empty.',
'back_to_show' => 'Back to Customer Detail',
'back_to_index' => 'Back to Customer List',
'customer' => 'Customer',
'list' => 'Daftar Customer',
'search' => 'Cari Customer',
'not_found' => 'Customer tidak ditemukan',
'empty' => 'Belum ada Customer',
'back_to_show' => 'Kembali ke detail Customer',
'back_to_index' => 'Kembali ke daftar Customer',
// Actions // Actions
'create' => 'Create new Customer',
'created' => 'Create new Customer succeded.',
'create' => 'Input Customer Baru',
'created' => 'Input Customer baru telah berhasil.',
'show' => 'Detail Customer',
'edit' => 'Edit Customer', 'edit' => 'Edit Customer',
'update' => 'Update Customer', 'update' => 'Update Customer',
'updated' => 'Update Customer succeded.',
'delete' => 'Delete Customer',
'delete_confirm' => 'Are you sure to delete this Customer?',
'deleted' => 'Delete Customer succeded.',
'undeleted' => 'Customer not deleted.',
'updated' => 'Update data Customer telah berhasil.',
'delete' => 'Hapus Customer',
'delete_confirm' => 'Anda yakin akan menghapus Customer ini?',
'deleted' => 'Hapus data Customer telah berhasil.',
'undeleted' => 'Data Customer gagal dihapus.',
'undeleteable' => 'Data Customer tidak dapat dihapus.',
// Attributes // Attributes
'name' => 'Customer Name',
'description' => 'Customer Description',
'name' => 'Nama Customer',
'description' => 'Deskripsi Customer',
]; ];

8
resources/views/payments/index.blade.php

@ -23,8 +23,8 @@
<th class="col-md-1 text-center">{{ trans('app.date') }}</th> <th class="col-md-1 text-center">{{ trans('app.date') }}</th>
<th class="col-md-2 text-right">{{ trans('payment.amount') }}</th> <th class="col-md-2 text-right">{{ trans('payment.amount') }}</th>
<th class="col-md-3">{{ trans('payment.description') }}</th> <th class="col-md-3">{{ trans('payment.description') }}</th>
<th class="col-md-2">{{ trans('payment.customer') }}</th>
<th class="col-md-1">{{ trans('app.action') }}</th>
<th class="col-md-1">{{ trans('payment.customer') }}</th>
<th class="col-md-2">{{ trans('app.action') }}</th>
</thead> </thead>
<tbody> <tbody>
@forelse($payments as $key => $payment) @forelse($payments as $key => $payment)
@ -36,8 +36,8 @@
<td>{{ $payment->description }}</td> <td>{{ $payment->description }}</td>
<td>{{ $payment->customer->name }}</td> <td>{{ $payment->customer->name }}</td>
<td> <td>
{!! link_to_route('payments.show','Lihat',[$payment->id],['class'=>'btn btn-info btn-xs']) !!}
{!! link_to_route('payments.edit',trans('app.edit'),[$payment->id],['class'=>'btn btn-warning btn-xs']) !!}
{!! link_to_route('payments.show', trans('app.show'), [$payment->id], ['class'=>'btn btn-info btn-xs']) !!}
{!! link_to_route('payments.edit', trans('app.edit'), [$payment->id], ['class'=>'btn btn-warning btn-xs']) !!}
</td> </td>
</tr> </tr>
@empty @empty

4
tests/Feature/ManageSubscriptionsTest.php

@ -51,11 +51,11 @@ class ManageSubscriptionsTest extends TestCase
/** @test */ /** @test */
public function admin_can_edit_subscription_data() public function admin_can_edit_subscription_data()
{ {
$eppCode = str_random(10);
$user = $this->adminUserSigningIn(); $user = $this->adminUserSigningIn();
$customer = $this->createUser('customer');
$vendor = $this->createUser('vendor'); $vendor = $this->createUser('vendor');
$eppCode = str_random(10);
$project = factory(Project::class)->create(); $project = factory(Project::class)->create();
$customer = $this->createUser('customer');
$subscription = factory(Subscription::class)->create(['customer_id' => $customer->id, 'project_id' => $project->id]); $subscription = factory(Subscription::class)->create(['customer_id' => $customer->id, 'project_id' => $project->id]);

82
tests/Feature/Payments/ManagePaymentsTest.php

@ -12,21 +12,16 @@ class ManagePaymentsTest extends TestCase
/** @test */ /** @test */
public function admin_can_entry_project_a_cashin_payment() public function admin_can_entry_project_a_cashin_payment()
{ {
$user = factory(User::class)->create();
$user->assignRole('admin');
$this->actingAs($user);
$user = $this->adminUserSigningIn();
$customer = $this->createUser('customer');
$project = factory(Project::class)->create(); $project = factory(Project::class)->create();
$customer = factory(User::class)->create();
$customer->assignRole('customer');
$this->visit('payments');
$this->seePageIs('payments');
$this->visit(route('payments.index'));
$this->seePageIs(route('payments.index'));
$this->click(trans('payment.create')); $this->click(trans('payment.create'));
// Fill Form // Fill Form
$this->seePageIs('payments/create');
$this->seePageIs(route('payments.create'));
$this->type('2015-05-01', 'date'); $this->type('2015-05-01', 'date');
$this->select(1, 'in_out'); $this->select(1, 'in_out');
$this->type(1000000, 'amount'); $this->type(1000000, 'amount');
@ -43,21 +38,16 @@ class ManagePaymentsTest extends TestCase
/** @test */ /** @test */
public function admin_can_entry_project_a_cashout_payment() public function admin_can_entry_project_a_cashout_payment()
{ {
$user = factory(User::class)->create();
$user->assignRole('admin');
$this->actingAs($user);
$user = $this->adminUserSigningIn();
$customer = $this->createUser('customer');
$project = factory(Project::class)->create(); $project = factory(Project::class)->create();
$customer = factory(User::class)->create();
$customer->assignRole('customer');
$this->visit('payments');
$this->seePageIs('payments');
$this->visit(route('payments.index'));
$this->seePageIs(route('payments.index'));
$this->click(trans('payment.create')); $this->click(trans('payment.create'));
// Fill Form // Fill Form
$this->seePageIs('payments/create');
$this->seePageIs(route('payments.create'));
$this->type('2015-05-01', 'date'); $this->type('2015-05-01', 'date');
$this->select(0, 'in_out'); $this->select(0, 'in_out');
$this->select(3, 'type_id'); $this->select(3, 'type_id');
@ -74,26 +64,22 @@ class ManagePaymentsTest extends TestCase
/** @test */ /** @test */
public function admin_can_edit_payment_data() public function admin_can_edit_payment_data()
{ {
$user = factory(User::class)->create();
$user->assignRole('admin');
$this->actingAs($user);
$user = $this->adminUserSigningIn();
$customer = $this->createUser('customer');
$project = factory(Project::class)->create(); $project = factory(Project::class)->create();
$customer = factory(User::class)->create();
$customer->assignRole('customer');
$payment = factory(Payment::class)->create(['customer_id' => $customer->id, 'project_id' => $project->id, 'owner_id' => $user->id]); $payment = factory(Payment::class)->create(['customer_id' => $customer->id, 'project_id' => $project->id, 'owner_id' => $user->id]);
$this->visit('payments/'.$payment->id.'/edit');
$this->seePageIs('payments/'.$payment->id.'/edit');
$this->visit(route('payments.edit', $payment->id));
$this->seePageIs(route('payments.edit', $payment->id));
$this->type('2016-05-20', 'date'); $this->type('2016-05-20', 'date');
$this->select(1, 'in_out'); $this->select(1, 'in_out');
$this->select(3, 'type_id'); $this->select(3, 'type_id');
$this->type(1234567890, 'amount'); $this->type(1234567890, 'amount');
$this->press(trans('payment.update')); $this->press(trans('payment.update'));
$this->seePageIs('payments/'.$payment->id);
$this->seePageIs(route('payments.show', $payment->id));
$this->see(trans('payment.updated')); $this->see(trans('payment.updated'));
$this->seeInDatabase('payments', [ $this->seeInDatabase('payments', [
'customer_id' => $customer->id, 'customer_id' => $customer->id,
@ -106,54 +92,32 @@ class ManagePaymentsTest extends TestCase
/** @test */ /** @test */
public function admin_can_delete_a_payment() public function admin_can_delete_a_payment()
{ {
$user = factory(User::class)->create();
$user->assignRole('admin');
$this->actingAs($user);
$user = $this->adminUserSigningIn();
$payment = factory(Payment::class)->create(['owner_id' => $user->id]); $payment = factory(Payment::class)->create(['owner_id' => $user->id]);
$this->visit('/payments');
$this->visit(route('payments.index'));
$this->click(trans('app.edit')); $this->click(trans('app.edit'));
$this->click(trans('payment.delete')); $this->click(trans('payment.delete'));
$this->press(trans('app.delete_confirm_button')); $this->press(trans('app.delete_confirm_button'));
$this->seePageIs('projects/'.$payment->project_id.'/payments');
$this->seePageIs(route('projects.payments', $payment->project_id));
$this->see(trans('payment.deleted')); $this->see(trans('payment.deleted'));
} }
/** @test */ /** @test */
public function admin_can_see_a_payment() public function admin_can_see_a_payment()
{ {
$user = factory(User::class)->create();
$user->assignRole('admin');
$this->actingAs($user);
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create(['owner_id' => $user->id]); $project = factory(Project::class)->create(['owner_id' => $user->id]);
$payment = factory(Payment::class)->create(['project_id' => $project->id,'owner_id' => $user->id]); $payment = factory(Payment::class)->create(['project_id' => $project->id,'owner_id' => $user->id]);
$this->visit('/payments');
$this->click('Lihat');
$this->seePageIs('payments/'.$payment->id);
$this->visit(route('payments.index'));
$this->click(trans('app.show'));
$this->seePageIs(route('payments.show', $payment->id));
$this->see(trans('payment.show')); $this->see(trans('payment.show'));
$this->see($payment->date); $this->see($payment->date);
$this->see(formatRp($payment->amount)); $this->see(formatRp($payment->amount));
$this->see($payment->description); $this->see($payment->description);
$this->see($payment->customer->name); $this->see($payment->customer->name);
} }
// /** @test */
// public function admin_can_see_all_payments()
// {
// $user = factory(User::class)->create();
// $user->assignRole('admin');
// $this->actingAs($user);
// $payments = factory(Payment::class, 5)->create(['owner_id' => $user->id]);
// $this->assertEquals(5, $payments->count());
// $this->visit(route('payments.index'));
// $this->seePageIs(route('payments.index'));
// $this->see($payments[4]->project->name);
// $this->see($payments[4]->date);
// $this->see(formatRp($payments[4]->amount));
// $this->see($payments[4]->customer->name);
// }
} }
Loading…
Cancel
Save