function let(TranslationNormalizer $transnormalizer, AttributeInterface $attribute, AttributeGroupInterface $attributeGroup)
 {
     $this->beConstructedWith($transnormalizer);
     $transnormalizer->normalize(Argument::cetera())->willReturn([]);
     $attribute->getAttributeType()->willReturn('Yes/No');
     $attribute->getCode()->willReturn('attribute_size');
     $attribute->getGroup()->willReturn($attributeGroup);
     $attributeGroup->getCode()->willReturn('size');
     $attribute->isUnique()->willReturn(true);
     $attribute->isUseableAsGridFilter()->willReturn(false);
     $attribute->getAllowedExtensions()->willReturn(['csv', 'xml', 'json']);
     $attribute->getMetricFamily()->willReturn('Length');
     $attribute->getDefaultMetricUnit()->willReturn('Centimenter');
     $attribute->getReferenceDataName()->willReturn('color');
     $attribute->isLocalizable()->willReturn(true);
     $attribute->isScopable()->willReturn(false);
 }
 function it_removes_indexes_for_attribute_when_removing_it($indexPurger, AttributeInterface $name, LifecycleEventArgs $args)
 {
     $name->isUseableAsGridFilter()->willReturn(true);
     $name->getAttributeType()->willReturn('pim_catalog_text');
     $name->isUnique()->willReturn(false);
     $args->getEntity()->willReturn($name);
     $indexPurger->purgeIndexesFromAttribute($name)->shouldBeCalled();
     $this->postRemove($args);
 }
 function it_logs_error_when_the_maximum_number_of_indexes_is_reached($collection, AttributeInterface $description, $namingUtility, $logger)
 {
     $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_textarea');
     $namingUtility->getAttributeNormFields($description)->willReturn(['normalizedData.description-en_US', 'normalizedData.description-de_DE']);
     $indexes = array_fill(0, 64, 'fake_index');
     $collection->getIndexInfo()->willReturn($indexes);
     $logger->error(Argument::any())->shouldBeCalled();
     $collection->ensureIndex(Argument::any(), Argument::any())->shouldNotBeCalled();
     $this->ensureIndexesFromAttribute($description);
 }
 /**
  * Ensure indexes from attribute if needed
  *
  * @param AttributeInterface $attribute
  */
 public function ensureIndexesFromAttribute(AttributeInterface $attribute)
 {
     if ($attribute->isUseableAsGridFilter() || AttributeTypes::IDENTIFIER === $attribute->getAttributeType() || $attribute->isUnique()) {
         $this->indexCreator->ensureIndexesFromAttribute($attribute);
     }
 }