/** * Test related methods */ public function testGuessUpdates() { $category = new Category(); $translation = new CategoryTranslation(); $translation->setLocale('en_US'); $translation->setForeignKey($category); $guesser = new TranslationsUpdateGuesser(array('Pim\\Bundle\\CatalogBundle\\Entity\\Category')); $em = $this->getEntityManagerMock(); $updates = $guesser->guessUpdates($em, $translation, UpdateGuesserInterface::ACTION_UPDATE_ENTITY); $this->assertEquals(1, count($updates)); $this->assertEquals($category, $updates[0]); }
function it_normalizes_category_variations(Category $category, Category $parentCategory, CategoryTranslation $translation, $categoryMapping, $storeViewMapping, $categoryMappingManager) { $this->globalContext = array_merge($this->globalContext, ['magentoStoreViews' => [['code' => 'fr_fr']], 'magentoStoreView' => 'default']); $category->getParent()->willReturn($parentCategory); $category->getLabel()->willReturn('category_label'); $category->setLocale('default_locale')->shouldBeCalled(); $category->getTranslations()->willReturn([$translation]); $category->getCode()->willReturn('category_code'); $translation->getLocale()->willReturn('fr_FR'); $storeViewMapping->getTarget('fr_FR')->willReturn('fr_fr'); $category->setLocale('fr_FR')->shouldBeCalled(); $category->getLabel()->willReturn('Libélé de la catégorie'); $categoryMappingManager->getIdFromCategory($category, 'soap_url')->willReturn(null); $categoryMappingManager->getIdFromCategory($parentCategory, 'soap_url', $categoryMapping)->willReturn(3); $categoryMapping->getTarget('category_code')->willReturn('category_code'); $this->normalize($category, 'MagentoArray', $this->globalContext)->shouldReturn(['create' => [['magentoCategory' => ['3', ['name' => 'Libélé de la catégorie', 'is_active' => 1, 'include_in_menu' => 1, 'available_sort_by' => 1, 'default_sort_by' => 1], 'default'], 'pimCategory' => $category]], 'update' => [], 'move' => [], 'variation' => [['magentoCategory' => [null, ['name' => 'Libélé de la catégorie', 'available_sort_by' => 1, 'default_sort_by' => 1], 'fr_fr'], 'pimCategory' => $category]]]); }
function it_returns_no_pending_updates_if_not_given_versionable_class(CategoryTranslation $translation, $em, LocaleInterface $locale) { $translation->getForeignKey()->willReturn($locale); $this->guessUpdates($em, $translation, UpdateGuesserInterface::ACTION_UPDATE_ENTITY)->shouldReturn([]); }
/** * {@inheritDoc} */ public function getForeignKey() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getForeignKey', array()); return parent::getForeignKey(); }