public function testCount()
 {
     $account = Account::create([]);
     $this->repository->save($account);
     $account->delete();
     $this->assertSame(2, $this->repository->getCount());
 }
Example #2
0
 /**
  * Unfortunately we need to do an Integrated test for this particular use-case.
  */
 public function testSlugRetrieval()
 {
     $account = Account::create([]);
     App::make(AccountRepositoryInterface::class)->save($account);
     $this->assertNotEmpty($account->slug);
     $this->assertInstanceOf(Slug::class, $account->slug);
 }
Example #3
0
 /**
  * Configures the database for the default account.
  */
 public function setupAccount()
 {
     $accountRepository = App::make(AccountRepositoryInterface::class);
     $this->account = Account::create([]);
     $accountRepository->save($this->account);
     CurrentAccount::set($this->account);
     $this->account->addTranslation('en', 'name', 'Account');
 }
 /**
  * Creates a new account record, assigns
  *
  * @param $command
  */
 public function handle($command)
 {
     // Create account
     $account = Account::create([]);
     $this->accountRepository->save($account);
     $language = $this->languageRepository->getByCode($command->defaultLanguageCode);
     $account->addLanguage($language);
     $account->addTranslation($language->code, 'name', $command->name);
     $account->addDomain($command->domain);
     $this->dispatcher->dispatch($account->releaseEvents());
 }
Example #5
0
 /**
  * Returns the default language for the account.
  *
  * @return \Tectonic\Shift\Modules\Localisation\Languages\Language
  */
 public function defaultLanguage()
 {
     return $this->account->defaultLanguage();
 }
 /**
  * Retrieves the total count for the number of accounts added to the system (both deleted and not).
  *
  * @return integer
  */
 public function getCount()
 {
     return Account::withTrashed()->count();
 }
Example #7
0
 /**
  * Determine whether or not the user is an owner of the provided account.
  *
  * @param Account $account
  */
 public function ownerOf(Account $account)
 {
     if (is_null($this->ownedAccounts)) {
         return false;
     }
     $ownedAccountIds = $this->ownedAccounts->lists('id');
     return in_array($account->getId(), $ownedAccountIds);
 }
Example #8
0
 protected function seedAccount()
 {
     $account = Account::install();
     $this->accounts->save($account);
     $this->translationService->sync($account, ['name' => ['en_GB' => 'Tectonic']]);
 }
 public function addLanguage(Account $account, $languageCode)
 {
     $language = $this->languageRepository->getByCode($languageCode);
     $account->addLanguage($language);
     return $language;
 }
Example #10
0
 /**
  * Transfers an account's ownership to another user.
  *
  * @param Account $account
  * @param UserInterface $user
  * @returns Account
  */
 public function transferOwnership(Account $account, User $user)
 {
     $account->setOwner($user);
     $this->accountRepository->save($account);
     $this->dispatcher->dispatch($account->releaseEvents());
 }