/** * Test activate/deactivate locale and chech isActivated method */ public function testActivateDeactivate() { $this->assertFalse($this->locale->isActivated()); $channel = new Channel(); $this->assertEntity($this->locale->addChannel($channel)); $this->assertTrue($this->locale->isActivated()); $this->assertEntity($this->locale->removeChannel($channel)); $this->assertFalse($this->locale->isActivated()); }
function let(SecurityContextInterface $securityContext, LocaleManager $localeManager, ChannelManager $channelManager, CategoryManager $categoryManager, TokenInterface $token, User $user, Locale $en, Locale $fr, Locale $de, Channel $ecommerce, Channel $mobile, CategoryInterface $firstTree, CategoryInterface $secondTree) { $securityContext->getToken()->willReturn($token); $token->getUser()->willReturn($user); $en->getCode()->willReturn('en_US'); $fr->getCode()->willReturn('fr_FR'); $de->getCode()->willReturn('de_DE'); $en->isActivated()->willReturn(true); $fr->isActivated()->willReturn(true); $de->isActivated()->willReturn(true); $localeManager->getLocaleByCode('en_US')->willReturn($en); $localeManager->getLocaleByCode('fr_FR')->willReturn($fr); $localeManager->getLocaleByCode('de_DE')->willReturn($de); $localeManager->getActiveLocales()->willReturn([$en, $fr, $de]); $channelManager->getChannels()->willReturn([$mobile, $ecommerce]); $categoryManager->getTrees()->willReturn([$firstTree, $secondTree]); $this->beConstructedWith($securityContext, $localeManager, $channelManager, $categoryManager, 'en_US'); }
function it_generates_localizable_indexes_when_saving_enabled_locale($collection, $namingUtility, AbstractAttribute $description, Locale $en_US, Locale $de_DE, Channel $ecommerce) { $description->getCode()->willReturn('description'); $description->getBackendType()->willReturn('varchar'); $description->isLocalizable()->willReturn(true); $description->isScopable()->willReturn(false); $description->isUseableAsGridFilter()->willReturn(true); $description->getAttributeType()->willReturn('pim_catalog_text'); $en_US->getCode()->willReturn('en_US'); $en_US->isActivated()->willReturn(true); $de_DE->getCode()->willReturn('de_DE'); $de_DE->isActivated()->willReturn(true); $ecommerce->getCode()->willReturn('ecommerce'); $ecommerce->getLocales()->willReturn([$en_US, $de_DE]); $namingUtility->getChannels()->willReturn([$ecommerce]); $namingUtility->getLocalizableAttributes()->willReturn([$description]); $namingUtility->getAttributeNormFields($description)->willReturn(['normalizedData.description-en_US', 'normalizedData.description-de_DE']); $options = ['background' => true, 'w' => 0]; $collection->ensureIndex(['normalizedData.completenesses.ecommerce-en_US' => 1], $options)->shouldBeCalled(); $collection->ensureIndex(['normalizedData.completenesses.ecommerce-de_DE' => 1], $options)->shouldBeCalled(); $collection->ensureIndex(['normalizedData.description-en_US' => 1], $options)->shouldBeCalled(); $collection->ensureIndex(['normalizedData.description-de_DE' => 1], $options)->shouldBeCalled(); $this->ensureIndexesFromLocale($en_US); }
/** * Checks if a locale is activated * * @param Locale $locale * * @return boolean */ protected function isLocaleAvailable(Locale $locale) { return $locale->isActivated(); }
function it_removes_obsolete_localizable_indexes_when_locale_is_disabled($collection, Locale $en_US) { $en_US->getCode()->willReturn('en_US'); $en_US->isActivated()->willReturn(false); $collection->getIndexInfo()->willReturn([["key" => ["_id" => 1]], ["key" => ["normalizedData.title-ecommerce-en_US" => 1]], ["key" => ["normalizedData.title-ecommerce-de_DE" => 1]], ["key" => ["normalizedData.title-mobile-de_DE" => 1]], ["key" => ["normalizedData.manufacturer_title" => 1]], ["key" => ["normalizedData.title_left-en_US" => 1]], ["key" => ["normalizedData.title_left-de_DE" => 1]], ["key" => ["normalizedData.price-ecommerce.EUR.data" => 1]], ["key" => ["normalizedData.price-mobile.USD.data" => 1]], ["key" => ["normalizedData.name-mobile" => 1]], ["key" => ["normalizedData.name-ecommerce" => 1]], ["key" => ["normalizedData.mobile_support.id" => 1]], ["key" => ["normalizedData.cost-en_US.USD.data" => 1]], ["key" => ["normalizedData.color-ecommerce-en_US.id" => 1]], ["key" => ["normalizedData.completenesses-ecommerce-en_US" => 1]], ["key" => ["normalizedData.completenesses-ecommerce-de_DE" => 1]]]); $collection->deleteIndex('normalizedData.title-ecommerce-en_US')->shouldBeCalled(); $collection->deleteIndex('normalizedData.title_left-en_US')->shouldBeCalled(); $collection->deleteIndex('normalizedData.cost-en_US.USD.data')->shouldBeCalled(); $collection->deleteIndex('normalizedData.color-ecommerce-en_US.id')->shouldBeCalled(); $collection->deleteIndex('normalizedData.completenesses-ecommerce-en_US')->shouldBeCalled(); $this->purgeIndexesFromLocale($en_US); }
function it_removes_indexes_for_locale_when_disabling_it($indexPurger, Locale $en_US, LifecycleEventArgs $args) { $en_US->isActivated()->willReturn(false); $args->getEntity()->willReturn($en_US); $indexPurger->purgeIndexesFromLocale($en_US)->shouldBeCalled(); $this->postUpdate($args); }
/** * {@inheritDoc} */ public function isActivated() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'isActivated', array()); return parent::isActivated(); }