setType example


    public function testLineItemType(): void
    {
        $currencyFactor = random_int(0, mt_getrandmax()) / mt_getrandmax();

        $builder = new PromotionItemBuilder();

        $discount = new PromotionDiscountEntity();
        $discount->setId('D5');
        $discount->setType(PromotionDiscountEntity::TYPE_PERCENTAGE);
        $discount->setValue(50);
        $discount->setScope(PromotionDiscountEntity::SCOPE_CART);

        $item = $builder->buildDiscountLineItem('', $this->promotion, $discount, 'C1', $currencyFactor);

        static::assertEquals(PromotionProcessor::LINE_ITEM_TYPE, $item->getType());
    }

    /** * This test verifies that we always use the id of the * discount and not from the promotion for the item key. * If we have multiple discounts in a single promotion and use the promotion * id for the key, then we get duplicate key entries which leads to * errors like "line item not stackable". * * @group promotions * * @throws CartException * @throws UnknownPromotionDiscountTypeException */
private FormDataExtractor $dataExtractor;

    protected function setUp(): void
    {
        $this->dataExtractor = new FormDataExtractor();
    }

    public function testExtractConfiguration()
    {
        $form = $this->createBuilder('name')
            ->setType(new ResolvedFormType(new HiddenType()))
            ->getForm();

        $this->assertSame([
            'id' => 'name',
            'name' => 'name',
            'type_class' => HiddenType::class,
            'synchronized' => true,
            'passed_options' => [],
            'resolved_options' => [],
        ]$this->dataExtractor->extractConfiguration($form));
    }

    
return $this->value;
    }

    /** * @param Text|null $text * * @return Container */
    public function setText($text)
    {
        $return = $this->setOneToOne($text, Text::class, 'text', 'container');
        $this->setType(self::TYPE_TEXT);

        return $return;
    }

    /** * @return Text|null */
    public function getText()
    {
        return $this->text;
    }

    

class IndividualStatesRuleTypeFilterTest extends TestCase
{
    public function testMatchesNotWithWrongType(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName('not me');

        $rule = new TaxRuleEntity();
        $rule->setActiveFrom(new \DateTime('2020-01-01'));
        $rule->setType($type);

        $filter = new IndividualStatesRuleTypeFilter();
        static::assertFalse($filter->match($rule, null, new ShippingLocation(new CountryEntity(), null, null)));
    }

    public function testMatchesNotWithWithoutState(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName(IndividualStatesRuleTypeFilter::TECHNICAL_NAME);

        $rule = new TaxRuleEntity();
        

class EntireCountryRuleTypeFilterTest extends TestCase
{
    public function testMatchesNotWithWrongType(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName('not me');

        $rule = new TaxRuleEntity();
        $rule->setActiveFrom(new \DateTime('2020-01-01'));
        $rule->setType($type);

        $filter = new EntireCountryRuleTypeFilter();
        static::assertFalse($filter->match($rule, null, new ShippingLocation(new CountryEntity(), null, null)));
    }

    public function testMatchesNotWithWrongCountry(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName(EntireCountryRuleTypeFilter::TECHNICAL_NAME);

        $rule = new TaxRuleEntity();
        
public function testGetType(): void
    {
        static::assertSame('buy-box', $this->buyBoxResolver->getType());
    }

    public function testCollectWithEmptyConfig(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('buy-box');
        $slot->setConfig([]);
        $slot->setFieldConfig(new FieldConfigCollection());

        $criteriaCollection = $this->buyBoxResolver->collect($slot$resolverContext);

        static::assertNull($criteriaCollection);
    }

    public function testCollectWithStaticConfig(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());

        
public function testType(): void
    {
        static::assertSame('image', $this->imageResolver->getType());
    }

    public function testCollectWithEmptyConfig(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('image');
        $slot->setConfig([]);
        $slot->setFieldConfig(new FieldConfigCollection());

        $criteriaCollection = $this->imageResolver->collect($slot$resolverContext);

        static::assertNull($criteriaCollection);
    }

    public function testCollectWithMediaId(): void
    {
        $resolverContext = new ResolverContext($this->createMock(SalesChannelContext::class)new Request());

        

        imagefill($res, 0, 0, $fill_color);
        break;

      case IMAGETYPE_JPEG:
        imagefill($res, 0, 0, imagecolorallocate($res, 255, 255, 255));
        break;

    }

    // Update the toolkit properties.     $this->getToolkit()->setType($type);
    $this->getToolkit()->setResource($res);

    // Destroy the original resource if it is not needed by other operations.     if (!$arguments['is_temp'] && is_resource($original_res)) {
      imagedestroy($original_res);
    }

    return TRUE;
  }

}
/** @var CmsSlotEntity $lastSlot */
        $lastSlot = $collection->getSlots()->last();

        static::assertEquals(['overwrite' => true]$lastSlot->getConfig());
    }

    private function getBlock(): CmsBlockEntity
    {
        $block = new CmsBlockEntity();
        $block->setUniqueIdentifier(Uuid::randomHex());
        $block->setType('block');

        $block->setSlots(new CmsSlotCollection([
            $this->getSlot(),
            $this->getSlot(),
            $this->getSlot(),
            $this->getSlot(),
            $this->getSlot(),
        ]));

        return $block;
    }

    
return $cart;
    }

    private function getOrder(string $toManipulate = ''): OrderEntity
    {
        // Order line items         $orderLineItem = new OrderLineItemEntity();
        $orderLineItem->setIdentifier('order-line-item-identifier');
        $orderLineItem->setId('order-line-item-id');
        $orderLineItem->setQuantity(1);
        $orderLineItem->setType('order-line-item-type');
        $orderLineItem->setLabel('order-line-item-label');
        $orderLineItem->setGood(true);
        $orderLineItem->setRemovable(false);
        $orderLineItem->setStackable(true);

        if ($toManipulate === 'order-add-line-item-download') {
            $orderLineItemDownload = new OrderLineItemDownloadEntity();
            $orderLineItemDownload->setId(Uuid::randomHex());
            $orderLineItemDownload->setMediaId(Uuid::randomHex());

            $orderLineItemDownloadCollection = new OrderLineItemDownloadCollection();
            

class ZipCodeRuleTypeFilterTest extends TestCase
{
    public function testMatchesNotWithWrongType(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName('not me');

        $rule = new TaxRuleEntity();
        $rule->setActiveFrom(new \DateTime('2020-01-01'));
        $rule->setType($type);

        $filter = new ZipCodeRuleTypeFilter();
        static::assertFalse($filter->match($rule, null, new ShippingLocation(new CountryEntity(), null, null)));
    }

    public function testMatchesNotWithWithoutAddress(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName(ZipCodeRuleTypeFilter::TECHNICAL_NAME);

        $rule = new TaxRuleEntity();
        


    public function addMethod(string $name, string $body, array $params = []): void
    {
        $this->methods[] = new Method(strtr($body['NAME' => $this->camelCase($name)] + $params));
    }

    public function addProperty(string $name, string $classType = null, string $defaultValue = null): Property
    {
        $property = new Property($name, '_' !== $name[0] ? $this->camelCase($name) : $name);
        if (null !== $classType) {
            $property->setType($classType);
        }
        $this->properties[] = $property;
        $defaultValue = null !== $defaultValue ? sprintf(' = %s', $defaultValue) : '';
        $property->setContent(sprintf('private $%s%s;', $property->getName()$defaultValue));

        return $property;
    }

    public function getProperties(): array
    {
        return $this->properties;
    }
/** * Provides a rearrange form for Views handlers. * * @internal */
class Rearrange extends ViewsFormBase {

  /** * Constructs a new Rearrange object. */
  public function __construct($type = NULL) {
    $this->setType($type);
  }

  /** * {@inheritdoc} */
  public function getFormKey() {
    return 'rearrange';
  }

  /** * {@inheritdoc} */

        $this->form->addError(new FormError('Error!'));
        $this->form->submit('foobar');

        $this->assertCount(0, $this->form->getErrors());
    }

    public function testCreateView()
    {
        $type = $this->createMock(ResolvedFormTypeInterface::class);
        $view = new FormView();
        $form = $this->getBuilder()->setType($type)->getForm();

        $type->expects($this->once())
            ->method('createView')
            ->with($form)
            ->willReturn($view);

        $this->assertSame($view$form->createView());
    }

    public function testCreateViewWithParent()
    {
        
/** * @param string $type * @param string $name * @param array<string, mixed> $options * * @return Form */
    public function setElement($type$name$options = null)
    {
        foreach ($this->elements as $element) {
            if ($element->getName() === $name) {
                $element->setType($type);
                if ($options !== null) {
                    $element->setOptions($options);
                }

                return $this;
            }
        }
        $this->addElement($type$name$options);

        return $this;
    }

    
Home | Imprint | This part of the site doesn't use cookies.