Ejemplo n.º 1
0
 /** @test */
 public function it_reads_dashboard()
 {
     $dbUserRepository = new DbUserRepository();
     $administrator = factory(User::class)->create();
     $dbUserRepository->assignAdministratorRole($administrator);
     $this->actingAs($administrator)->visit(route('cms.dashboard'))->seePageIs(route('cms.dashboard'))->see('<title>Dashboard | CmsChamb</title>');
 }
Ejemplo n.º 2
0
 /** @test */
 public function it_shows_invalidated_account_error()
 {
     $dbUserRepository = new DbUserRepository();
     $user = factory(User::class)->create(['password' => Hash::make('some-password'), 'verified' => 0]);
     $dbUserRepository->assignCompanyRepresentativeRole($user);
     $this->visit(route('auth.sign_in'))->type($user->email, 'email')->type('some-password', 'password')->press(trans('ahk.sign_in'))->seePageIs(route('auth.sign_in'))->see(trans('ahk_messages.please_validate_your_email_first'));
 }
Ejemplo n.º 3
0
 /** @test */
 public function it_restricts_not_validated()
 {
     $dbUserRepository = new DbUserRepository();
     $user = factory(User::class)->create(['password' => Hash::make('some-password'), 'verified' => 0]);
     $dbUserRepository->assignAdministratorRole($user);
     $this->visit(route('cms.sessions.create'))->type($user->email, 'email')->type('some-password', 'password')->press('Sign In')->seePageIs(route('cms.sessions.create'))->see(trans('ahk_messages.please_validate_your_email_first'));
 }
Ejemplo n.º 4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dbUserRepository = new DbUserRepository();
     $dbWorkgroupRepository = new DbWorkgroupRepository();
     $authorUser = $dbUserRepository->findByEmail(env('COMPANY_REPRESENTATIVE_EMAIL'));
     $dbWorkgroupRepository->storeAndAssignCreatorByUser([Workgroup::NAME => "Work Group 1", Workgroup::DESCRIPTION => "Work Group Description"], $authorUser);
     $dbWorkgroupRepository->storeAndAssignCreatorByUser([Workgroup::NAME => "Work Group 2", Workgroup::DESCRIPTION => "Work Group Description"], $authorUser);
 }
Ejemplo n.º 5
0
 /** @test */
 public function it_reads_footer()
 {
     $utilities = new Utilities();
     $dbUserRepository = new DbUserRepository();
     $administrator = factory(User::class)->create();
     $dbUserRepository->assignAdministratorRole($administrator);
     $this->actingAs($administrator)->visit(route('cms.dashboard'))->see('<strong>Copyright © ' . $utilities->autoCopyright('2015'))->see('<a href="' . route('home_path') . '">Chamb.Net</a>.</strong> ' . trans('cms.all_rights_reserved'))->see('<img src="' . $administrator->avatar_url . '" class="user-image" alt="User Image">')->see('<span class="hidden-xs">' . $administrator->name or $administrator->username . '</span> </a>')->see('<small>Member since ' . $administrator->created_at . '</small>')->see('<button type="submit" class="btn btn-default btn-flat">' . trans('ahk.logout') . '</button>');
 }
Ejemplo n.º 6
0
 /** @test */
 public function it_reads_companies_index()
 {
     $dbUserRepository = new DbUserRepository();
     $administrator = factory(User::class)->create(['verified' => true]);
     $companies = factory(Company::class, 2)->create();
     $this->actingAs($administrator)->visit(route('cms.companies.index'))->seePageIs(route('cms.sessions.create'))->see(trans('cms.missing_required_role'));
     $dbUserRepository->assignAdministratorRole($administrator);
     //
     $this->actingAs($administrator)->visit(route('cms.companies.index'))->seePageIs(route('cms.companies.index'))->see('<title>' . trans('cms.companies') . ' | ' . 'CmsChamb</title>')->see('<h3 class="box-title">' . trans('cms.table') . '</h3>')->see('<th>' . trans('cms.name') . '</th>')->see('<th>' . trans('cms.logo') . '</th>')->see('<th>' . trans('cms.name_of_contact_partner') . '</th>')->see($companies->get(0)->name)->see(route('files.render', ['path' => $companies->get(0)->logo->path]))->see($companies->get(0)->name_of_contact_partner)->see($companies->get(1)->name)->see(route('files.render', ['path' => $companies->get(1)->logo->path]))->see($companies->get(1)->name_of_contact_partner);
 }
Ejemplo n.º 7
0
 /** @test */
 public function it_recovers_an_account()
 {
     $dbUserRepository = new DbUserRepository();
     $user = factory(User::class)->create();
     $dbUserRepository->assignCompanyRepresentativeRole($user);
     $this->visit(route('auth.sign_in'))->click(trans('ahk.forgot_your_password'))->seePageIs(route('auth.recover.get'))->see('<title> ' . trans('ahk.reset_password') . ' · Chamb.Net</title>')->type($user->email, 'email')->press(trans('ahk.send_password_reset_link'))->see(trans('ahk_messages.check_your_email_to_recover_account'));
     $user = factory(User::class)->create();
     $dbUserRepository->assignCompanyRepresentativeRole($user);
     $dbUserRepository->generateRecoveryToken($user);
     $this->visit(route('auth.recover.reset', ['slug' => $user->slug, 'recovery_token' => $user->recovery_token]))->seePageIs(route('auth.recover.reset', ['slug' => $user->slug, 'recovery_token' => $user->recovery_token]))->see('<title> ' . trans('ahk.reset_password') . ' · Chamb.Net</title>')->type('new-password', 'password')->type('new-password', 'password_confirmation')->press(trans('ahk.reset_password'))->seePageIs(route('auth.sign_in'))->see(trans('ahk_messages.you_updated_your_accounts_password'));
 }
Ejemplo n.º 8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dbIndustryRepository = new DbIndustryRepository();
     $dbUserRepository = new DbUserRepository();
     $authorUser = $dbUserRepository->findByEmail(env('COMPANY_REPRESENTATIVE_EMAIL'));
     $dbIndustryRepository->store($authorUser, ['name' => 'Health', 'fontawesome' => 'fa fa-heartbeat']);
     $dbIndustryRepository->store($authorUser, ['name' => 'Logistics', 'fontawesome' => 'fa fa-bar-chart']);
     $dbIndustryRepository->store($authorUser, ['name' => 'Energy', 'fontawesome' => 'fa fa-sun-o']);
     $dbIndustryRepository->store($authorUser, ['name' => 'Trade', 'fontawesome' => 'fa fa-exchange']);
     $dbIndustryRepository->store($authorUser, ['name' => 'Law', 'fontawesome' => 'fa fa-university']);
 }
Ejemplo n.º 9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dbUserRepository = new DbUserRepository();
     $administrator = $dbUserRepository->store(['email' => env('ADMIN_EMAIL'), 'password' => Hash::make(env('ADMIN_PASSWORD'))]);
     $companyRepresentative = $dbUserRepository->store(['email' => env('COMPANY_REPRESENTATIVE_EMAIL'), 'password' => Hash::make(env('COMPANY_REPRESENTATIVE_PASSWORD'))]);
     $dbUserRepository = new DbUserRepository();
     $dbUserRepository->assignCompanyRepresentativeRole($companyRepresentative);
     $dbUserRepository->assignAdministratorRole($administrator);
     $dbUserRepository->confirmEmail($administrator->token);
     $dbUserRepository->confirmEmail($companyRepresentative->token);
 }
Ejemplo n.º 10
0
 /** @test */
 public function read_published_articles()
 {
     $dbUserRepository = new DbUserRepository();
     $administrator = factory(User::class)->create(['verified' => true]);
     $dbUserRepository->assignAdministratorRole($administrator);
     $dbArticleRepository = new DbArticleRepository();
     $articles = factory(Article::class, 2)->create(['publish' => true]);
     $tags = factory(Tag::class, 6)->create();
     $dbArticleRepository->assignTags($articles->get(0), [$tags->get(0)->id, $tags->get(1)->id]);
     $dbArticleRepository->assignTags($articles->get(1), [$tags->get(2)->id, $tags->get(3)->id]);
     $unPublishedArticle = factory(Article::class)->create(['publish' => false]);
     $this->actingAs($administrator)->visit(route('cms.articles.published'))->seePageIs(route('cms.articles.published'))->see('<title>' . trans('cms.articles') . ' | ' . 'CmsChamb</title>')->see('<th>Actions</th>')->see(route('cms.articles.edit', $articles->get(0)))->see(route('cms.articles.edit', $articles->get(1)))->dontSee(route('cms.articles.edit', $unPublishedArticle))->see('<th>Title</th>')->see('<td>' . $articles->get(0)->title . '</td>')->see('<td>' . $articles->get(1)->title . '</td>')->dontSee('<td>' . $unPublishedArticle->title . '</td>')->see('<th>Industry</th>')->see('<td>' . $articles->get(0)->industry->name . '</td>')->see('<td>' . $articles->get(1)->industry->name . '</td>')->dontSee('<td>' . $unPublishedArticle->industry->name . '</td>')->see('<th>Tags</th>')->see($tags->get(0)->name)->see($tags->get(1)->name)->see($tags->get(2)->name)->see($tags->get(3)->name)->dontSee($tags->get(4)->name)->dontSee($tags->get(5)->name)->see('<th>Author</th>')->see('<td>' . $articles->get(0)->author->name . '</td>')->see('<td>' . $articles->get(1)->author->name . '</td>')->dontSee('<td>' . $unPublishedArticle->author->name . '</td>')->see('<th>Created at / Updated at</th>')->see($articles->get(0)->created_at)->see($articles->get(0)->updated_at)->see($articles->get(1)->created_at)->see($articles->get(1)->updated_at)->dontSee($unPublishedArticle->created_at)->dontSee($unPublishedArticle->updated_at);
 }
Ejemplo n.º 11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dbIndustryRepository = new DbIndustryRepository();
     $dbCountryRepository = new DbCountryRepository();
     $dbUserRepository = new DbUserRepository();
     $healthIndustry = $dbIndustryRepository->findByName('Health');
     $countries = $dbCountryRepository->all()->toArray();
     $companyRepresentativeUsers = $dbUserRepository->withCompanyRepresentativeRole()->get()->toArray();
     $faker = Factory::create();
     foreach ($this->popularCompanies as $company) {
         factory(Company::class, 'relationless')->create(['name' => $company['name'], 'description' => $company['description'], 'industry_id' => $healthIndustry->id, 'country_id' => $faker->randomElement($countries)['id'], 'user_id' => $faker->randomElement($companyRepresentativeUsers)['id'], 'logo_id' => factory(File::class)->create()->id]);
     }
 }
Ejemplo n.º 12
0
 /** @test */
 public function it_stores_workgroup()
 {
     $dbUserRepository = new DbUserRepository();
     $user = factory(User::class)->create();
     $companyRepresentativeUser = $dbUserRepository->assignCompanyRepresentativeRole($user);
     $dbWorkgroupRepository = new DbWorkgroupRepository();
     $workgroupModel = new Workgroup();
     $workgroupFillableKeys = $workgroupModel->getFillable();
     $expectedWorkgroupData = array_only(factory(Workgroup::class, 'relationless')->make()->toArray(), $workgroupFillableKeys);
     $this->dontSeeInDatabase('workgroups', $expectedWorkgroupData);
     $workgroup = $dbWorkgroupRepository->storeAndAssignCreatorByUser($expectedWorkgroupData, $companyRepresentativeUser);
     $this->assertNotFalse($workgroup);
     $this->seeInDatabase('workgroups', $expectedWorkgroupData);
 }
Ejemplo n.º 13
0
 /** @test */
 public function it_creates_company()
 {
     $dbUserRepository = new DbUserRepository();
     $companyRepresentativeUser = factory(User::class)->create();
     $dbUserRepository->assignCompanyRepresentativeRole($companyRepresentativeUser);
     factory(Industry::class, 2)->create();
     factory(Country::class, 2)->create();
     $expectedCompany = factory(Company::class, 'relationless')->make(['user_id' => $companyRepresentativeUser->id]);
     $expectedIndustry = factory(Industry::class)->create();
     $expectedCountry = factory(Country::class)->create();
     $expectedLogoPath = FilesStorage::getFilesDirectory() . 'dummy_logo.png';
     $this->actingAs($companyRepresentativeUser)->visit(route('my.companies.create'))->type($expectedCompany->name, 'name')->select($expectedIndustry->id, 'industry_id')->select($expectedCountry->id, 'country_id')->type($expectedCompany->business_leader, 'business_leader')->type($expectedCompany->address, 'address')->type($expectedCompany->email, 'email')->type($expectedCompany->phone_number, 'phone_number')->type($expectedCompany->focus, 'focus')->type($expectedCompany->description, 'description')->attach(storage_path('app/testing/dummy_logo.png'), 'logo_path')->press(trans('ahk.create'))->see(trans('ahk_messages.company_successfully_stored'))->see($expectedCompany->name)->seeIsSelected('industry_id', $expectedIndustry->id)->seeIsSelected('country_id', $expectedCountry->id)->see($expectedCompany->business_leader)->see($expectedCompany->address)->see($expectedCompany->email)->see($expectedCompany->phone_number)->see($expectedCompany->focus)->see($expectedCompany->description)->see(route('files.render', ['path' => $expectedLogoPath]));
 }
Ejemplo n.º 14
0
 /** @test */
 public function it_assigns_user()
 {
     $dbCompanyRepository = new DbCompanyRepository();
     $dbUserRepository = new DbUserRepository();
     $user = factory(User::class)->create();
     $dbUserRepository->assignCompanyRepresentativeRole($user);
     $company = factory(Company::class)->create();
     $this->assertNotSame($company->user->id, $user->id);
     $dbCompanyRepository->assignRepresentativeUser($company, $user);
     $this->assertSame($company->user->id, $user->id);
 }
Ejemplo n.º 15
0
 /** @test */
 public function it_updates_password()
 {
     $dbUserRepository = new DbUserRepository();
     $oldPassword = '******';
     $newPassword = '******';
     $user = factory(User::class)->create(['password' => Hash::make($oldPassword)]);
     $user = $dbUserRepository->updatePassword($user, $newPassword);
     $this->assertNotTrue(Hash::check($oldPassword, $user->password));
     $this->assertTrue(Hash::check($newPassword, $user->password));
 }