|
|
|
@ -2,11 +2,11 @@ |
|
|
|
|
|
|
|
namespace Tests\Feature; |
|
|
|
|
|
|
|
use App\Entities\Partners\Customer; |
|
|
|
use App\Entities\Payments\Payment; |
|
|
|
use App\Entities\Projects\Feature; |
|
|
|
use App\Entities\Projects\Project; |
|
|
|
use App\Entities\Projects\Task; |
|
|
|
use App\Entities\Users\User; |
|
|
|
use Tests\TestCase; |
|
|
|
|
|
|
|
class ManageProjectsTest extends TestCase |
|
|
|
@ -14,18 +14,15 @@ class ManageProjectsTest extends TestCase |
|
|
|
/** @test */ |
|
|
|
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->seePageIs(route('projects.index')); |
|
|
|
$this->click(trans('project.create')); |
|
|
|
$this->seePageIs(route('projects.create')); |
|
|
|
$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('2000000', 'proposal_value'); |
|
|
|
$this->type('Deskripsi project baru', 'description'); |
|
|
|
@ -59,11 +56,19 @@ class ManageProjectsTest extends TestCase |
|
|
|
$this->type('Customer Baru', 'customer_name'); |
|
|
|
$this->type('email@customer.baru', 'customer_email'); |
|
|
|
$this->press(trans('project.create')); |
|
|
|
|
|
|
|
$this->see(trans('project.created')); |
|
|
|
$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 */ |
|
|
|
@ -105,12 +110,9 @@ class ManageProjectsTest extends TestCase |
|
|
|
/** @test */ |
|
|
|
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->seePageIs('projects/'.$project->id.'/edit'); |
|
|
|
@ -122,7 +124,7 @@ class ManageProjectsTest extends TestCase |
|
|
|
$this->type(2000000, 'proposal_value'); |
|
|
|
$this->type(2000000, 'project_value'); |
|
|
|
$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->press(trans('project.update')); |
|
|
|
|
|
|
|
@ -132,7 +134,7 @@ class ManageProjectsTest extends TestCase |
|
|
|
'proposal_date' => '2016-04-15', |
|
|
|
'start_date' => '2016-04-25', |
|
|
|
'end_date' => '2016-05-05', |
|
|
|
'customer_id' => $users[1]->id, |
|
|
|
'customer_id' => $customer->id, |
|
|
|
'description' => 'Edit deskripsi project', |
|
|
|
]); |
|
|
|
} |
|
|
|
@ -140,18 +142,16 @@ class ManageProjectsTest extends TestCase |
|
|
|
/** @test */ |
|
|
|
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->seePageIs(route('projects.index')); |
|
|
|
$this->click(trans('project.create')); |
|
|
|
$this->seePageIs(route('projects.create')); |
|
|
|
$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('', 'proposal_value'); |
|
|
|
$this->type('Deskripsi project baru', 'description'); |
|
|
|
@ -164,8 +164,8 @@ class ManageProjectsTest extends TestCase |
|
|
|
public function admin_can_update_project_status_on_project_detail_page() |
|
|
|
{ |
|
|
|
$user = $this->adminUserSigningIn(); |
|
|
|
|
|
|
|
$project = factory(Project::class)->create(['owner_id' => $user->id, 'status_id' => 1]); |
|
|
|
|
|
|
|
$this->visit(route('projects.show', $project->id)); |
|
|
|
$this->seePageIs(route('projects.show', $project->id)); |
|
|
|
$this->select(2, 'status_id'); |
|
|
|
|