/**
  * @param Crawler           $crawler
  * @param string            $name
  * @param Account           $parent
  * @param AccountGroup      $group
  * @param AbstractEnumValue $internalRating
  */
 protected function assertAccountSave(Crawler $crawler, $name, Account $parent, AccountGroup $group, AbstractEnumValue $internalRating)
 {
     $form = $crawler->selectButton('Save and Close')->form(['orob2b_account_type[name]' => $name, 'orob2b_account_type[parent]' => $parent->getId(), 'orob2b_account_type[group]' => $group->getId(), 'orob2b_account_type[internal_rating]' => $internalRating->getId()]);
     $this->client->followRedirects(true);
     $crawler = $this->client->submit($form);
     $result = $this->client->getResponse();
     $this->assertHtmlResponseStatusCodeEquals($result, 200);
     $html = $crawler->html();
     $this->assertContains('Account has been saved', $html);
     $this->assertViewPage($html, $name, $parent, $group, $internalRating);
 }
 /**
  * @param AccountUser $accountUser
  * @param Account $account
  *
  * @throws BadRequestHttpException
  */
 protected function validateRelation(AccountUser $accountUser, Account $account)
 {
     if ($accountUser && $accountUser->getAccount() && $accountUser->getAccount()->getId() !== $account->getId()) {
         throw new BadRequestHttpException('AccountUser must belong to Account');
     }
 }
 /**
  * @Route("/info/{id}", name="orob2b_account_info", requirements={"id"="\d+"})
  * @Template("OroB2BAccountBundle:Account/widget:info.html.twig")
  * @AclAncestor("orob2b_account_view")
  *
  * @param Account $account
  * @return array
  */
 public function infoAction(Account $account)
 {
     return ['entity' => $account, 'treeData' => $this->get('orob2b_account.account_tree_handler')->createTree($account->getId())];
 }
 /**
  * @param Account $entity
  * @param int $rootId
  * @return array
  */
 protected function formatEntity(Account $entity, $rootId)
 {
     return ['id' => $entity->getId(), 'parent' => $entity->getParent() && $entity->getParent()->getId() !== $rootId ? $entity->getParent()->getId() : '#', 'text' => $entity->getName(), 'state' => ['opened' => !$entity->getChildren()->isEmpty()]];
 }
 /**
  * @param Account $entity
  * @return array
  */
 protected function getAddressBookOptions($entity)
 {
     $addressListUrl = $this->generateUrl('orob2b_api_account_get_account_addresses', ['entityId' => $entity->getId()]);
     $addressCreateUrl = $this->generateUrl('orob2b_account_address_create', ['entityId' => $entity->getId()]);
     $currentAddresses = $this->get('fragment.handler')->render($addressListUrl);
     return ['wid' => $this->getRequest()->get('_wid'), 'entityId' => $entity->getId(), 'addressListUrl' => $addressListUrl, 'addressCreateUrl' => $addressCreateUrl, 'addressUpdateRouteName' => 'orob2b_account_address_update', 'currentAddresses' => $currentAddresses];
 }
 public function testAccountView()
 {
     $this->client->request('GET', $this->getUrl('orob2b_account_view', ['id' => $this->account->getId()]));
     $result = $this->client->getResponse();
     $this->assertHtmlResponseStatusCodeEquals($result, 200);
 }