/**
  * @param string $title
  * @param int    $parentId
  *
  * @return int
  */
 protected function assertCreate($title, $parentId)
 {
     $crawler = $this->client->request('GET', $this->getUrl('orob2b_catalog_category_create', ['id' => $parentId]));
     /** @var Form $form */
     $form = $crawler->selectButton('Save and Close')->form();
     $form['orob2b_catalog_category[titles][values][default]'] = $title;
     if ($parentId === $this->masterCatalog->getId()) {
         $appendProducts = $this->getProductBySku(LoadProductData::TEST_PRODUCT_01)->getId() . ', ' . $this->getProductBySku(LoadProductData::TEST_PRODUCT_02)->getId();
     } else {
         $appendProducts = $this->getProductBySku(LoadProductData::TEST_PRODUCT_04)->getId();
     }
     $form['orob2b_catalog_category[appendProducts]'] = $appendProducts;
     $form->setValues(['input_action' => 'save_and_stay']);
     $this->client->followRedirects(true);
     $crawler = $this->client->submit($form);
     $result = $this->client->getResponse();
     $this->assertHtmlResponseStatusCodeEquals($result, 200);
     $this->assertContains('Category has been saved', $crawler->html());
     return $this->getCategoryIdByUri($this->client->getRequest()->getRequestUri());
 }
 /**
  * Returns an array formatted as:
  * array(
  *     'id'     => int,    // tree item id
  *     'parent' => int,    // tree item parent id
  *     'text'   => string  // tree item label
  * )
  *
  * @param Category $entity
  * @return array
  */
 protected function formatEntity($entity)
 {
     return ['id' => $entity->getId(), 'parent' => $entity->getParentCategory() ? $entity->getParentCategory()->getId() : '#', 'text' => $entity->getDefaultTitle()->getString(), 'state' => ['opened' => $entity->getParentCategory() === null]];
 }