|
|
@ -2,11 +2,11 @@ |
|
|
|
|
|
|
|
|
namespace Tests\Feature; |
|
|
namespace Tests\Feature; |
|
|
|
|
|
|
|
|
|
|
|
use App\Entities\Partners\Customer; |
|
|
use App\Entities\Payments\Payment; |
|
|
use App\Entities\Payments\Payment; |
|
|
use App\Entities\Projects\Feature; |
|
|
use App\Entities\Projects\Feature; |
|
|
use App\Entities\Projects\Project; |
|
|
use App\Entities\Projects\Project; |
|
|
use App\Entities\Projects\Task; |
|
|
use App\Entities\Projects\Task; |
|
|
use App\Entities\Users\User; |
|
|
|
|
|
use Tests\TestCase; |
|
|
use Tests\TestCase; |
|
|
|
|
|
|
|
|
class ManageProjectsTest extends TestCase |
|
|
class ManageProjectsTest extends TestCase |
|
|
@ -14,18 +14,15 @@ class ManageProjectsTest extends TestCase |
|
|
/** @test */ |
|
|
/** @test */ |
|
|
public function admin_can_input_new_project_with_existing_customer() |
|
|
public function admin_can_input_new_project_with_existing_customer() |
|
|
{ |
|
|
{ |
|
|
$users = factory(User::class, 2)->create(); |
|
|
|
|
|
$users[0]->assignRole('admin'); |
|
|
|
|
|
$this->actingAs($users[0]); |
|
|
|
|
|
|
|
|
|
|
|
$users[1]->assignRole('customer'); |
|
|
|
|
|
|
|
|
$user = $this->adminUserSigningIn(); |
|
|
|
|
|
$customer = factory(Customer::class)->create(); |
|
|
|
|
|
|
|
|
$this->visit(route('projects.index')); |
|
|
$this->visit(route('projects.index')); |
|
|
$this->seePageIs(route('projects.index')); |
|
|
$this->seePageIs(route('projects.index')); |
|
|
$this->click(trans('project.create')); |
|
|
$this->click(trans('project.create')); |
|
|
$this->seePageIs(route('projects.create')); |
|
|
$this->seePageIs(route('projects.create')); |
|
|
$this->type('Project Baru', 'name'); |
|
|
$this->type('Project Baru', 'name'); |
|
|
$this->select($users[1]->id, 'customer_id'); |
|
|
|
|
|
|
|
|
$this->select($customer->id, 'customer_id'); |
|
|
$this->type('2016-04-15', 'proposal_date'); |
|
|
$this->type('2016-04-15', 'proposal_date'); |
|
|
$this->type('2000000', 'proposal_value'); |
|
|
$this->type('2000000', 'proposal_value'); |
|
|
$this->type('Deskripsi project baru', 'description'); |
|
|
$this->type('Deskripsi project baru', 'description'); |
|
|
@ -59,11 +56,19 @@ class ManageProjectsTest extends TestCase |
|
|
$this->type('Customer Baru', 'customer_name'); |
|
|
$this->type('Customer Baru', 'customer_name'); |
|
|
$this->type('email@customer.baru', 'customer_email'); |
|
|
$this->type('email@customer.baru', 'customer_email'); |
|
|
$this->press(trans('project.create')); |
|
|
$this->press(trans('project.create')); |
|
|
|
|
|
|
|
|
$this->see(trans('project.created')); |
|
|
$this->see(trans('project.created')); |
|
|
$this->see('Project Baru'); |
|
|
$this->see('Project Baru'); |
|
|
$this->seeInDatabase('users', ['name' => 'Customer Baru', 'email' => 'email@customer.baru']); |
|
|
|
|
|
$newCustomer = User::whereName('Customer Baru')->whereEmail('email@customer.baru')->first(); |
|
|
|
|
|
$this->seeInDatabase('projects', ['name' => 'Project Baru', 'proposal_value' => '2000000', 'customer_id' => $newCustomer->id]); |
|
|
|
|
|
|
|
|
$this->seeInDatabase('customers', [ |
|
|
|
|
|
'name' => 'Customer Baru', |
|
|
|
|
|
'email' => 'email@customer.baru', |
|
|
|
|
|
]); |
|
|
|
|
|
$newCustomer = Customer::whereName('Customer Baru')->whereEmail('email@customer.baru')->first(); |
|
|
|
|
|
$this->seeInDatabase('projects', [ |
|
|
|
|
|
'name' => 'Project Baru', |
|
|
|
|
|
'proposal_value' => '2000000', |
|
|
|
|
|
'customer_id' => $newCustomer->id, |
|
|
|
|
|
]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** @test */ |
|
|
/** @test */ |
|
|
@ -73,7 +78,7 @@ class ManageProjectsTest extends TestCase |
|
|
|
|
|
|
|
|
$project = factory(Project::class)->create(['owner_id' => $user->id]); |
|
|
$project = factory(Project::class)->create(['owner_id' => $user->id]); |
|
|
$feature = factory(Feature::class)->create(['project_id' => $project->id]); |
|
|
$feature = factory(Feature::class)->create(['project_id' => $project->id]); |
|
|
$task = factory(Task::class)->create(['feature_id' => $feature->id]); |
|
|
|
|
|
|
|
|
$task = factory(Task::class)->create(['feature_id' => $feature->id]); |
|
|
$payment = factory(Payment::class)->create(['project_id' => $project->id]); |
|
|
$payment = factory(Payment::class)->create(['project_id' => $project->id]); |
|
|
|
|
|
|
|
|
$this->visit('projects/'.$project->id); |
|
|
$this->visit('projects/'.$project->id); |
|
|
@ -84,9 +89,9 @@ class ManageProjectsTest extends TestCase |
|
|
$this->see(trans('project.deleted')); |
|
|
$this->see(trans('project.deleted')); |
|
|
|
|
|
|
|
|
$this->notSeeInDatabase('projects', [ |
|
|
$this->notSeeInDatabase('projects', [ |
|
|
'name' => $project->name, |
|
|
|
|
|
|
|
|
'name' => $project->name, |
|
|
'proposal_value' => $project->proposal_value, |
|
|
'proposal_value' => $project->proposal_value, |
|
|
'owner_id' => $user->id, |
|
|
|
|
|
|
|
|
'owner_id' => $user->id, |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
$this->notSeeInDatabase('payments', [ |
|
|
$this->notSeeInDatabase('payments', [ |
|
|
@ -105,12 +110,9 @@ class ManageProjectsTest extends TestCase |
|
|
/** @test */ |
|
|
/** @test */ |
|
|
public function admin_can_edit_a_project() |
|
|
public function admin_can_edit_a_project() |
|
|
{ |
|
|
{ |
|
|
$users = factory(User::class, 2)->create(); |
|
|
|
|
|
$users[0]->assignRole('admin'); |
|
|
|
|
|
$this->actingAs($users[0]); |
|
|
|
|
|
|
|
|
|
|
|
$project = factory(Project::class)->create(['owner_id' => $users[0]->id]); |
|
|
|
|
|
$users[1]->assignRole('customer'); |
|
|
|
|
|
|
|
|
$user = $this->adminUserSigningIn(); |
|
|
|
|
|
$customer = factory(Customer::class)->create(); |
|
|
|
|
|
$project = factory(Project::class)->create(['owner_id' => $user->id]); |
|
|
|
|
|
|
|
|
$this->visit('projects/'.$project->id.'/edit'); |
|
|
$this->visit('projects/'.$project->id.'/edit'); |
|
|
$this->seePageIs('projects/'.$project->id.'/edit'); |
|
|
$this->seePageIs('projects/'.$project->id.'/edit'); |
|
|
@ -122,36 +124,34 @@ class ManageProjectsTest extends TestCase |
|
|
$this->type(2000000, 'proposal_value'); |
|
|
$this->type(2000000, 'proposal_value'); |
|
|
$this->type(2000000, 'project_value'); |
|
|
$this->type(2000000, 'project_value'); |
|
|
$this->select(4, 'status_id'); |
|
|
$this->select(4, 'status_id'); |
|
|
$this->select($users[1]->id, 'customer_id'); |
|
|
|
|
|
|
|
|
$this->select($customer->id, 'customer_id'); |
|
|
$this->type('Edit deskripsi project', 'description'); |
|
|
$this->type('Edit deskripsi project', 'description'); |
|
|
$this->press(trans('project.update')); |
|
|
$this->press(trans('project.update')); |
|
|
|
|
|
|
|
|
$this->seeInDatabase('projects', [ |
|
|
$this->seeInDatabase('projects', [ |
|
|
'id' => $project->id, |
|
|
|
|
|
'name' => 'Edit Project', |
|
|
|
|
|
|
|
|
'id' => $project->id, |
|
|
|
|
|
'name' => 'Edit Project', |
|
|
'proposal_date' => '2016-04-15', |
|
|
'proposal_date' => '2016-04-15', |
|
|
'start_date' => '2016-04-25', |
|
|
|
|
|
'end_date' => '2016-05-05', |
|
|
|
|
|
'customer_id' => $users[1]->id, |
|
|
|
|
|
'description' => 'Edit deskripsi project', |
|
|
|
|
|
|
|
|
'start_date' => '2016-04-25', |
|
|
|
|
|
'end_date' => '2016-05-05', |
|
|
|
|
|
'customer_id' => $customer->id, |
|
|
|
|
|
'description' => 'Edit deskripsi project', |
|
|
]); |
|
|
]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** @test */ |
|
|
/** @test */ |
|
|
public function form_is_validated_on_invalid_project_entry() |
|
|
public function form_is_validated_on_invalid_project_entry() |
|
|
{ |
|
|
{ |
|
|
$users = factory(User::class, 2)->create(); |
|
|
|
|
|
$users[0]->assignRole('admin'); |
|
|
|
|
|
$this->actingAs($users[0]); |
|
|
|
|
|
|
|
|
$user = $this->adminUserSigningIn(); |
|
|
|
|
|
|
|
|
$users[1]->assignRole('customer'); |
|
|
|
|
|
|
|
|
$customer = factory(Customer::class)->create(); |
|
|
|
|
|
|
|
|
$this->visit(route('projects.index')); |
|
|
$this->visit(route('projects.index')); |
|
|
$this->seePageIs(route('projects.index')); |
|
|
$this->seePageIs(route('projects.index')); |
|
|
$this->click(trans('project.create')); |
|
|
$this->click(trans('project.create')); |
|
|
$this->seePageIs(route('projects.create')); |
|
|
$this->seePageIs(route('projects.create')); |
|
|
$this->type('', 'name'); |
|
|
$this->type('', 'name'); |
|
|
$this->select($users[1]->id, 'customer_id'); |
|
|
|
|
|
|
|
|
$this->select($customer->id, 'customer_id'); |
|
|
$this->type('2016-04-15aa', 'proposal_date'); |
|
|
$this->type('2016-04-15aa', 'proposal_date'); |
|
|
$this->type('', 'proposal_value'); |
|
|
$this->type('', 'proposal_value'); |
|
|
$this->type('Deskripsi project baru', 'description'); |
|
|
$this->type('Deskripsi project baru', 'description'); |
|
|
@ -163,9 +163,9 @@ class ManageProjectsTest extends TestCase |
|
|
/** @test */ |
|
|
/** @test */ |
|
|
public function admin_can_update_project_status_on_project_detail_page() |
|
|
public function admin_can_update_project_status_on_project_detail_page() |
|
|
{ |
|
|
{ |
|
|
$user = $this->adminUserSigningIn(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$user = $this->adminUserSigningIn(); |
|
|
$project = factory(Project::class)->create(['owner_id' => $user->id, 'status_id' => 1]); |
|
|
$project = factory(Project::class)->create(['owner_id' => $user->id, 'status_id' => 1]); |
|
|
|
|
|
|
|
|
$this->visit(route('projects.show', $project->id)); |
|
|
$this->visit(route('projects.show', $project->id)); |
|
|
$this->seePageIs(route('projects.show', $project->id)); |
|
|
$this->seePageIs(route('projects.show', $project->id)); |
|
|
$this->select(2, 'status_id'); |
|
|
$this->select(2, 'status_id'); |
|
|
@ -174,7 +174,7 @@ class ManageProjectsTest extends TestCase |
|
|
$this->seePageIs(route('projects.show', $project->id)); |
|
|
$this->seePageIs(route('projects.show', $project->id)); |
|
|
|
|
|
|
|
|
$this->seeInDatabase('projects', [ |
|
|
$this->seeInDatabase('projects', [ |
|
|
'id' => $project->id, |
|
|
|
|
|
|
|
|
'id' => $project->id, |
|
|
'status_id' => 2, |
|
|
'status_id' => 2, |
|
|
]); |
|
|
]); |
|
|
} |
|
|
} |
|
|
|