add example

$mappingCollection = new self();

        foreach ($data as $mapping) {
            if (\is_string($mapping)) {
                $mapping = new Mapping($mapping);
            } elseif (\is_array($mapping)) {
                $mapping = Mapping::fromArray($mapping);
            }

            if ($mapping instanceof Mapping) {
                $mappingCollection->add($mapping);
            }
        }

        return $mappingCollection;
    }

    /** * @return array<Mapping> */
    public function sortByPosition(): array
    {
        
new TaxRule(17),
        ]);
        static::assertEquals(
            new TaxRule(19),
            $collection->get(19)
        );
    }

    public function testTaxRateCanBeAddedToCollection(): void
    {
        $collection = new TaxRuleCollection();
        $collection->add(new TaxRule(19));

        static::assertEquals(
            new TaxRuleCollection([new TaxRule(19)]),
            $collection
        );
    }

    public function testCollectionCanBeCleared(): void
    {
        $collection = new TaxRuleCollection([
            new TaxRule(19),
            

        $this->options->removeElement($option);

        return $this;
    }

    /** * @return Group */
    public function addOption(Option $option)
    {
        $this->options->add($option);

        return $this;
    }

    /** * @param Option[] $options * * @return Group */
    public function setOptions(array $options)
    {
        
$action = $payment->getAction();
            $data = $this->Request()->getParams();
            $data['surcharge'] = str_replace(',', '.', $data['surcharge'] ?? '');
            $data['debitPercent'] = str_replace(',', '.', $data['debitPercent'] ?? '');

            $countries = new ArrayCollection();
            if (!empty($data['countries'])) {
                // Clear all countries, to save the old and new ones then                 $payment->getCountries()->clear();
                foreach ($data['countries'] as $country) {
                    $model = $this->get('models')->find(Country::class$country['id']);
                    $countries->add($model);
                }
                $data['countries'] = $countries;
            }

            $shops = new ArrayCollection();
            if (!empty($data['shops'])) {
                // Clear all shops, to save the old and new ones then                 $payment->getShops()->clear();
                foreach ($data['shops'] as $shop) {
                    $model = $this->get('models')->find(Shop::class$shop['id']);
                    $shops->add($model);
                }
$this->assertSame($expected_filtered_collectionarray_keys($collection->all()));
  }

  public function filterProvider() {
    $route_without_format = new Route('/test');
    $route_with_format = new Route('/test');
    $route_with_format->setRequirement('_format', 'json');
    $route_with_multiple_formats = new Route('/test');
    $route_with_multiple_formats->setRequirement('_format', 'json|xml');

    $collection = new RouteCollection();
    $collection->add('test_0', $route_without_format);
    $collection->add('test_1', $route_with_format);
    $collection->add('test_2', $route_with_multiple_formats);

    $sole_route_match_single_format = new RouteCollection();
    $sole_route_match_single_format->add('sole_route_single_format', $route_with_format);

    return [
      'nothing requested' => [clone $collection, '', ['test_0']],
      'xml requested' => [clone $collection, 'xml', ['test_2', 'test_0']],
      'json requested' => [clone $collection, 'json', ['test_1', 'test_2', 'test_0']],
      'html format requested' => [clone $collection, 'html', ['test_0']],
      
foreach ($data['paymentData'] as &$paymentDataData) {
            try {
                $paymentData = $this->getOneToManySubElement(
                    $paymentDataInstances,
                    $paymentDataData,
                    PaymentData::class,
                    ['id', 'paymentMeanId']
                );
            } catch (CustomValidationException $cve) {
                $paymentData = new PaymentData();
                $this->getManager()->persist($paymentData);
                $paymentDataInstances->add($paymentData);
            }

            if (isset($paymentDataData['paymentMeanId'])) {
                $paymentMean = $this->getManager()->getRepository(Payment::class)->find($paymentDataData['paymentMeanId']);
                if ($paymentMean === null) {
                    throw new CustomValidationException(sprintf('%s by %s %s not found', Payment::class, 'id', $paymentDataData['paymentMeanId']));
                }
                $paymentData->setPaymentMean($paymentMean);
                unset($paymentDataData['paymentMeanId']);
            }

            
$this->cache_add(
                'theme',
                array(
                    'block_theme' => $this->block_theme,
                    'headers'     => $this->headers,
                    'errors'      => $this->errors,
                    'stylesheet'  => $this->stylesheet,
                    'template'    => $this->template,
                )
            );
            if ( ! file_exists( $this->theme_root ) ) { // Don't cache this one.                 $this->errors->add( 'theme_root_missing', __( '<strong>Error:</strong> The themes directory is either empty or does not exist. Please check your installation.' ) );
            }
            return;
        } elseif ( ! is_readable( $this->theme_root . '/' . $theme_file ) ) {
            $this->headers['Name'] = $this->stylesheet;
            $this->errors          = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) );
            $this->template        = $this->stylesheet;
            $this->block_theme     = false;
            $this->cache_add(
                'theme',
                array(
                    'block_theme' => $this->block_theme,
                    

                'customerId' => $customer->getId(),
                'billingAddressId' => null,
                'shippingAddressId' => null,
            ],
            TestDefaults::SALES_CHANNEL,
            $customer->getId()
        );

        $cart = new Cart($contextToken);

        $cart->add(new LineItem('productId', LineItem::PRODUCT_LINE_ITEM_TYPE, $productId));

        $this->getContainer()->get(CartPersister::class)->save($cart$salesChannelContext);

        $this->getContainer()->get('product.repository')->delete([[
            'id' => $productId,
        ]]$context);

        $request = new Request();
        $session = $this->getSession();
        static::assertInstanceOf(Session::class$session);
        $request->setSession($session);
        
static::assertNull($collection->getStockForProductId('23456'));
    }

    public function testAdd(): void
    {
        $collection = new StockDataCollection([]);

        static::assertEmpty($collection->all());

        $stock1 = new StockData('12345', 10, true);

        $collection->add($stock1);

        static::assertCount(1, $collection->all());
        static::assertSame($stock1$collection->getStockForProductId('12345'));
    }
}
// Mock the view route names state.     $view_route_names = [];
    $view_route_names['example_view.page_1'] = 'view.example_view.page_1';
    $this->state->expects($this->exactly(2))
      ->method('get')
      ->with('views.view_route_names')
      ->willReturn($view_route_names);

    // Mock the route provider.     $route_collection = new RouteCollection();
    $route_collection->add('test_route', new Route('/path'));
    $this->routeProvider->expects($this->any())
      ->method('getRoutesByPattern')
      ->with('/path')
      ->willReturn($route_collection);

    // Setup the existing local task of the test_route.     $definitions['test_route_tab'] = $other_tab = [
      'route_name' => 'test_route',
      'title' => 'Test route',
      'base_route' => 'test_route',
    ];

    


    /** * Linearizes back a set of nested routes into a collection. */
    public function populateCollection(RouteCollection $routes): RouteCollection
    {
        foreach ($this->items as $route) {
            if ($route instanceof self) {
                $route->populateCollection($routes);
            } else {
                $routes->add(...$route);
            }
        }

        return $routes;
    }

    /** * Gets the full and static common prefixes between two route patterns. * * The static prefix stops at last at the first opening bracket. */
    
/** * @param string $a * @param string $b * @return string * @throws SodiumException */
    public static function scalar_add($a$b)
    {
        $a_ = $a . str_repeat("\x00", 32);
        $b_ = $b . str_repeat("\x00", 32);
        ParagonIE_Sodium_Compat::add($a_$b_);
        return self::sc_reduce($a_);
    }

    /** * @param string $x * @param string $y * @return string * @throws SodiumException */
    public static function scalar_sub($x$y)
    {
        
if ($event instanceof EntityWrittenEvent) {
                $list[$event->getName()] = $event->getIds();
            }
        }

        return $list;
    }

    public function addEvent(NestedEvent ...$events): void
    {
        foreach ($events as $event) {
            $this->events->add($event);
        }
    }

    public function getErrors(): array
    {
        return $this->errors;
    }

    public function getPrimaryKeys(string $entity): array
    {
        return $this->findPrimaryKeys($entity);
    }
public function testArgumentDefaultQueryParameter() {
    $view = Views::getView('test_argument_default_query_param');

    $request = Request::create(Url::fromUri('internal:/whatever', ['absolute' => TRUE])->toString());

    // Check the query parameter default argument fallback value.     $view->setRequest($request);
    $view->initHandlers();
    $this->assertEquals('all', $view->argument['type']->getDefaultArgument());

    // Check the query parameter default argument with a value.     $request->query->add(['the_node_type' => 'page']);
    $view->setRequest($request);
    $view->initHandlers();
    $this->assertEquals('page', $view->argument['type']->getDefaultArgument());
  }

}
public function testWithFutureDate(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);

        $rule = new IsNewCustomerRule();

        $cart = new Cart('test');

        $customer = new CustomerEntity();
        $customer->setFirstLogin(
            (new \DateTime())->add(
                new \DateInterval('P' . 10 . 'D')
            )
        );

        $context = $this->createMock(SalesChannelContext::class);

        $context
            ->method('getCustomer')
            ->willReturn($customer);

        static::assertFalse(
            
Home | Imprint | This part of the site doesn't use cookies.