assign example

$builder->leftJoin('payment.ruleSets', 'ruleSets');
            $builder->orderBy('payment.active', 'desc');
            $builder->addOrderBy('payment.id');

            $result = $builder->getQuery()->getArrayResult();
            $total = $this->get('models')->getQueryCount($builder->getQuery());

            // Translate the payment methods             $translationComponent = $this->get(Shopware_Components_Translation::class);
            $result = $translationComponent->translatePaymentMethods($result);

            $this->View()->assign(['success' => true, 'data' => $result, 'total' => $total]);
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'errorMsg' => $e->getMessage()]);
        }
    }

    /** * Function to delete a single rule. * It is called, when the user clicks on the delete button of a rule. */
    public function deleteRuleAction()
    {
        
try {
                $this->sitemapExporter->generate($this->get('shop'));
            } catch (AlreadyLockedException $exception) {
                // Silent catch, lock couldn't be acquired. Some other process already generates the sitemap.             }

            $sitemaps = $this->sitemapLister->getSitemaps($this->get('shop')->getId());
        }

        $this->Response()->headers->set('content-type', 'text/xml; charset=utf-8');
        $this->View()->assign('sitemaps', $sitemaps);
    }
}
$this->pageLoader = new AccountOverviewPageLoader(
            $this->createMock(GenericPageLoader::class),
            $this->eventDispatcher,
            $this->orderRoute,
            $this->createMock(CustomerRoute::class),
            $this->createMock(NewsletterAccountPageletLoader::class)
        );
    }

    public function testLoad(): void
    {
        $order = (new OrderEntity())->assign(['_uniqueIdentifier' => Uuid::randomHex()]);

        $orders = new OrderCollection([$order]);

        $orderResponse = new OrderRouteResponse(
            new EntitySearchResult(
                OrderDefinition::ENTITY_NAME,
                1,
                $orders,
                null,
                new Criteria(),
                Context::createDefaultContext()
            )
$configService = $this->createMock(SystemConfigService::class);
        $configService->method('getInt')->willReturn(10);
        $this->service = new ProductMaxPurchaseCalculator($configService);
    }

    /** * @dataProvider cases */
    public function testCalculate(array $entityData, int $expected): void
    {
        $entity = new PartialEntity();
        $entity->assign($entityData);

        static::assertSame($expected$this->service->calculate($entity$this->createMock(SalesChannelContext::class)));
    }

    public static function cases(): iterable
    {
        yield 'empty' => [
            [
            ],
            10,
        ];

        
public function testRuleMatching(string $operator, bool $isMatching, string $billingCity): void
    {
        $cityName = 'kyln123';
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $customerAddress = new CustomerAddressEntity();
        $customerAddress->setCity($billingCity);

        $customer = new CustomerEntity();
        $customer->setActiveBillingAddress($customerAddress);
        $salesChannelContext->method('getCustomer')->willReturn($customer);
        $scope = new CheckoutRuleScope($salesChannelContext);
        $this->rule->assign(['cityName' => $cityName, 'operator' => $operator]);

        $match = $this->rule->match($scope);
        if ($isMatching) {
            static::assertTrue($match);
        } else {
            static::assertFalse($match);
        }
    }

    public function testValidationWithMissingCityName(): void
    {
        


    public function testNestedLineItemCalculation(): void
    {
        $lineItemGrandChild1 = new LineItem(
            $this->ids->get('line-item-3'),
            LineItem::PRODUCT_LINE_ITEM_TYPE,
            $this->ids->get('line-item-3'),
            1,
        );

        $lineItemGrandChild1->assign(['uniqueIdentifier' => $this->ids->get('line-item-3')]);

        $lineItemGrandChild2 = new LineItem(
            $this->ids->get('line-item-4'),
            LineItem::PRODUCT_LINE_ITEM_TYPE,
            $this->ids->get('line-item-4'),
            1,
        );

        $lineItemGrandChild2->assign(['uniqueIdentifier' => $this->ids->get('line-item-4')]);

        $price = new CalculatedPrice(
            
/** * @dataProvider getMatchingRuleTestData */
    public function testIfMatchesCorrectWithLineItem(
        string $operator,
        float $height,
        ?float $lineItemHeight,
        bool $expected,
        bool $lineItemWithoutDeliveryInfo = false
    ): void {
        $this->rule->assign([
            'amount' => $height,
            'operator' => $operator,
        ]);

        $lineItem = $this->createLineItemWithHeight($lineItemHeight);
        if ($lineItemWithoutDeliveryInfo) {
            $lineItem = $this->createLineItem();
        }

        $match = $this->rule->match(new LineItemScope(
            $lineItem,
            


    /** * @dataProvider getCartRuleScopeTestData */
    public function testIfMatchesCorrectWithCartRuleScope(
        string $promotionCodeType,
        string $operator,
        ?string $typeOfPromotionCode,
        bool $expected
    ): void {
        $this->rule->assign(['promotionCodeType' => $promotionCodeType, 'operator' => $operator]);

        $lineItemCollection = new LineItemCollection();
        if ($typeOfPromotionCode !== null) {
            $lineItemCollection = new LineItemCollection([
                $this->createLineItem(LineItem::PROMOTION_LINE_ITEM_TYPE),
                $this->createLineItem(LineItem::PROMOTION_LINE_ITEM_TYPE)->setPayloadValue(
                    'promotionCodeType',
                    $typeOfPromotionCode
                ),
            ]);
        }

        
$ruleEntity->setPayload($rules);

        return $ruleEntity;
    }

    /** * Gets a minimum price rule with the provided price value. */
    private function getMinPriceRule(float $minPrice): LineItemUnitPriceRule
    {
        $rule = new LineItemUnitPriceRule();
        $rule->assign(['amount' => $minPrice, 'operator' => LineItemUnitPriceRule::OPERATOR_GTE]);

        return $rule;
    }

    /** * Gets a minimum quantity rule for the provided line item Id. */
    private function getMinQuantityRule(string $itemID, int $quantity): LineItemWithQuantityRule
    {
        $rule = new LineItemWithQuantityRule();
        $rule->assign(['id' => $itemID, 'quantity' => $quantity, 'operator' => LineItemWithQuantityRule::OPERATOR_GTE]);

        

    public function testDirty(
        ?array $lineItemTaxes,
        ?array $deliveryTaxes,
        ?CalculatedTaxCollection $cartPriceTaxes,
        bool $dirty
    ): void {
        $struct = (new TaxProviderResult())
            ->assign(['lineItemTaxes' => $lineItemTaxes])
            ->assign(['deliveryTaxes' => $deliveryTaxes])
            ->assign(['cartPriceTaxes' => $cartPriceTaxes]);

        static::assertSame($dirty$struct->declaresTaxes());
    }

    /** * @return \Generator */
    public static function structDataProvider(): iterable
    {
        
protected $trialPhaseIncluded = false;

    /** * @var DiscountCampaignStruct|null */
    protected $discountCampaign;

    public static function fromArray(array $data): StoreStruct
    {
        $variant = new self();

        return $variant->assign($data);
    }

    public function getId(): int
    {
        return $this->id;
    }

    public function getType(): string
    {
        return $this->type;
    }

    
public function testValidate(): void
    {
        $manifest = Manifest::createFromXmlFile($this->testAppDir . '/test/manifest.xml');

        $violations = $this->appNameValidator->validate($manifest, null);
        static::assertCount(0, $violations->getElements());
    }

    public function testValidateNonCaseSensitive(): void
    {
        $manifest = Manifest::createFromXmlFile($this->testAppDir . '/test/manifest.xml');
        $manifest->getMetadata()->assign(['name' => 'TeSt']);

        $violations = $this->appNameValidator->validate($manifest, null);
        static::assertCount(0, $violations->getElements());
    }

    public function testValidateReturnsErrors(): void
    {
        $manifest = Manifest::createFromXmlFile($this->testAppDir . '/invalidAppName/manifest.xml');

        $violations = $this->appNameValidator->validate($manifest, null);

        
$this->rule = new CartVolumeRule();
    }

    /** * @dataProvider getMatchingRuleTestData */
    public function testIfMatchesCorrect(
        string $operator,
        float $volume,
        bool $expected
    ): void {
        $this->rule->assign(['volume' => $volume, 'operator' => $operator]);

        $match = $this->rule->match(new CartRuleScope(
            $this->createCartDummy(),
            $this->createMock(SalesChannelContext::class)
        ));

        static::assertSame($expected$match);
    }

    /** * @dataProvider getMatchingRuleTestData */
$this->redirect($location['code' => Response::HTTP_MOVED_PERMANENTLY]);

            return;
        }

        $hasCustomerStreamEmotions = $this->customerStreamRepository
            ->hasCustomerStreamEmotions($requestCategoryId);

        if ($hasCustomerStreamEmotions && !$request->getParam('sPage')) {
            $assign = $this->View()->getAssign();
            $this->View()->loadTemplate('frontend/listing/customer_stream.tpl');
            $this->View()->assign($assign);

            return;
        }

        $this->View()->assign($emotionConfiguration);

        // Only show the listing if an emotion viewport is empty or the showListing option is active         if (!$this->loadListing($emotionConfiguration$request)) {
            return;
        }

        

            $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
        }
    }
    $smarty_math_result = null;
    eval("\$smarty_math_result = ".$equation.";");

    if (empty($params['format'])) {
        if (empty($params['assign'])) {
            return $smarty_math_result;
        } else {
            $template->assign($params['assign'],$smarty_math_result);
        }
    } else {
        if (empty($params['assign'])){
            printf($params['format'],$smarty_math_result);
        } else {
            $template->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
        }
    }
}

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