getContainer example

new \DateTime()],
            [1.1],
        ];
    }

    /** * @dataProvider emptyInputProvider */
    public function testEncodeWithEmptyInput(mixed $input): void
    {
        $this->expectException(UnsupportedEncoderInputException::class);
        $encoder = $this->getContainer()->get(JsonEntityEncoder::class);
        $encoder->encode(new Criteria()$this->getContainer()->get(ProductDefinition::class)$input, SerializationFixture::API_BASE_URL);
    }

    /** * @return list<array{0: class-string, 1: SerializationFixture}> */
    public static function complexStructsProvider(): array
    {
        return [
            [MediaDefinition::classnew TestBasicStruct()],
            [UserDefinition::classnew TestBasicWithToManyRelationships()],
            [
private string $currencyId = '0fa91ce3e96a4bc2be4bd9ce752c3425';

    private string $anotherCurrencyId = '2c962ddb7b3346f29c748a9d3b884302';

    private AbstractElasticsearchDefinition $definition;

    private Context $context;

    protected function setUp(): void
    {
        $this->definition = $this->getContainer()->get(ElasticsearchProductDefinition::class);

        $this->getContainer()->get(AbstractKeyValueStorage::class)->set(ElasticsearchIndexer::ENABLE_MULTILINGUAL_INDEX_KEY, Feature::isActive('ES_MULTILINGUAL_INDEX'));

        $this->helper = $this->getContainer()->get(ElasticsearchHelper::class);
        $this->client = $this->getContainer()->get(Client::class);
        $this->productDefinition = $this->getContainer()->get(ProductDefinition::class);
        $this->languageRepository = $this->getContainer()->get('language.repository');

        $this->connection = $this->getContainer()->get(Connection::class);

        $this->navigationId = $this->connection->fetchOne(
            

    use KernelTestBehaviour;

    private DeliveryCalculator $deliveryCalculator;

    private DeliveryTime $deliveryTime;

    private DeliveryTimeEntity $deliveryTimeEntity;

    protected function setUp(): void
    {
        $this->deliveryCalculator = $this->getContainer()->get(DeliveryCalculator::class);
        $this->deliveryTime = (new DeliveryTime())->assign([
            'min' => 1,
            'max' => 3,
            'unit' => 'day',
            'name' => '1-3 days',
        ]);
        $this->deliveryTimeEntity = new DeliveryTimeEntity();
        $this->deliveryTimeEntity->assign([
            'min' => 1,
            'max' => 3,
            'unit' => 'day',
            

    use IntegrationTestBehaviour;

    private OrderPersister $orderPersister;

    private Processor $cartProcessor;

    private OrderConverter $orderConverter;

    protected function setUp(): void
    {
        $this->orderPersister = $this->getContainer()->get(OrderPersister::class);
        $this->cartProcessor = $this->getContainer()->get(Processor::class);
        $this->orderConverter = $this->getContainer()->get(OrderConverter::class);
    }

    public function testSave(): void
    {
        $cart = new Cart(Uuid::randomHex());
        $cart->add(
            (new LineItem('test', 'test'))
                ->setPrice(new CalculatedPrice(1, 1, new CalculatedTaxCollection()new TaxRuleCollection()))
                ->setLabel('test')
        )
use KernelTestBehaviour;
    use QueueTestBehaviour;
    use SalesChannelApiTestBehaviour;
    use SessionTestBehaviour;

    private EntityRepository $productRepository;

    private Connection $connection;

    protected function setUp(): void
    {
        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->connection = $this->getContainer()->get(Connection::class);
        $this->getContainer()->get(AbstractKeyValueStorage::class)->set(ElasticsearchIndexer::ENABLE_MULTILINGUAL_INDEX_KEY, Feature::isActive('ES_MULTILINGUAL_INDEX'));
    }

    /** * @beforeClass */
    public static function startTransactionBefore(): void
    {
        $connection = KernelLifecycleManager::getKernel()
            ->getContainer()
            

    private $stringTemplateRenderer;

    /** * @var Environment */
    private $twig;

    protected function setUp(): void
    {
        $this->stringTemplateRenderer = $this->getContainer()->get(StringTemplateRenderer::class);
        $this->twig = $this->getContainer()->get('twig');
    }

    public function testRender(): void
    {
        $templateMock = '{{ foo }}';
        $dataMock = ['foo' => 'bar'];
        $rendered = $this->stringTemplateRenderer->render($templateMock$dataMock, Context::createDefaultContext());
        static::assertEquals('bar', $rendered);
    }

    
    $other_service_class = $this->containerDefinition['services']['other.service']['class'];
    $other_service = $this->container->get('other.service');
    $this->assertInstanceOf($other_service_class$other_service);

    $some_parameter = $this->containerDefinition['parameters']['some_config'];
    $some_other_parameter = $this->containerDefinition['parameters']['some_other_config'];

    $service = $this->container->get('service.provider');

    $this->assertEquals($other_service$service->getSomeOtherService(), '@other.service was injected via constructor.');
    $this->assertEquals($some_parameter$service->getSomeParameter(), '%some_config% was injected via constructor.');
    $this->assertEquals($this->container, $service->getContainer(), 'Container was injected via setter injection.');
    $this->assertEquals($some_other_parameter$service->getSomeOtherParameter(), '%some_other_config% was injected via setter injection.');
    $this->assertEquals('foo', $service->someProperty, 'Service has added properties.');
  }

  /** * Tests that Container::get() for non-shared services works properly. * * @covers ::get * @covers ::createService */
  public function testGetForNonSharedService() {
    
public function testRemoteAddressSerializerAnonymize(): void
    {
        $this->setConfig();

        $remoteAddress = '127.0.0.1';
        $orderId = $this->createOrderWithRemoteAddress($remoteAddress);

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('orderId', $orderId));

        $result = $this->getContainer()->get('order_customer.repository')
            ->search($criteria, Context::createDefaultContext())
            ->first();

        static::assertNotEmpty($result);
        static::assertNotSame($remoteAddress$result->getRemoteAddress());
        static::assertSame(IPUtils::anonymize($remoteAddress)$result->getRemoteAddress());
    }

    public function testRemoteAddressSerializerNoAnonymize(): void
    {
        $this->setConfig(true);

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

    abstract protected static function getContainer(array $array);

    public static function getValidPropertyPaths(): array
    {
        return [
            [static::getContainer(['firstName' => 'Bernhard']), '[firstName]', 'Bernhard'],
            [static::getContainer(['person' => static::getContainer(['firstName' => 'Bernhard'])]), '[person][firstName]', 'Bernhard'],
        ];
    }

    public static function getInvalidPropertyPaths(): array
    {
        return [
            [static::getContainer(['firstName' => 'Bernhard']), 'firstName', 'Bernhard'],
            [static::getContainer(['person' => static::getContainer(['firstName' => 'Bernhard'])]), 'person.firstName', 'Bernhard'],
        ];
    }

    

    private $customerRepository;

    protected function setUp(): void
    {
        $this->ids = new TestDataCollection();

        $this->browser = $this->createCustomSalesChannelBrowser([
            'id' => $this->ids->create('sales-channel'),
        ]);
        $this->assignSalesChannelContext($this->browser);
        $this->customerRepository = $this->getContainer()->get('customer.repository');
    }

    public function testWithInvalidHash(): void
    {
        $this->browser
            ->request(
                'POST',
                '/store-api/account/recovery-password-confirm',
                [
                    'hash' => 'lol@lol.de',
                    'newPassword' => 'password123456',
                    
/** * @internal */
class DisabledTwigCacheWarmupTest extends TestCase
{
    use KernelTestBehaviour;

    public function testServiceIsRemoved(): void
    {
        static::expectException(ServiceNotFoundException::class);
        $this->getContainer()->get('twig.template_cache_warmer');
    }
}
class SnippetsFindMissingCommand extends ShopwareCommand implements CompletionAwareInterface
{
    /** * {@inheritdoc} */
    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'target') {
            return $this->completeDirectoriesInDirectory();
        } elseif ($optionName === 'fallback') {
            $localeRepository = $this->getContainer()->get(ModelManager::class)->getRepository(Locale::class);
            $queryBuilder = $localeRepository->createQueryBuilder('locale');

            if ($context->getCurrentWord() !== '') {
                $queryBuilder->andWhere($queryBuilder->expr()->like('locale.locale', ':search'))
                    ->setParameter('search', addcslashes($context->getCurrentWord(), '_%') . '%');
            }

            $result = $queryBuilder->select(['locale.locale'])
                ->getQuery()
                ->getArrayResult();

            

        $this->ids = new TestDataCollection();

        $this->createData();
    }

    public function testCmsPageLoadedHookScriptsAreExecuted(): void
    {
        $response = $this->request('GET', '/widgets/cms/' . $this->ids->get('page')[]);
        static::assertEquals(200, $response->getStatusCode());

        $traces = $this->getContainer()->get(ScriptTraces::class)->getTraces();

        static::assertArrayHasKey(CmsPageLoadedHook::HOOK_NAME, $traces);
    }

    public function testCmsPageLoadedHookScriptsAreExecutedForCategory(): void
    {
        $response = $this->request('GET', '/widgets/cms/navigation/' . $this->ids->get('category')[]);
        static::assertEquals(200, $response->getStatusCode());

        $traces = $this->getContainer()->get(ScriptTraces::class)->getTraces();

        


        return static::bootKernel();
    }

    /** * Create a web client with the default kernel and disabled reboots */
    public static function createBrowser(KernelInterface $kernel, bool $enableReboot = false): TestBrowser
    {
        /** @var TestBrowser $apiBrowser */
        $apiBrowser = $kernel->getContainer()->get('test.browser');

        if ($enableReboot) {
            $apiBrowser->enableReboot();
        } else {
            $apiBrowser->disableReboot();
        }

        return $apiBrowser;
    }

    /** * Boots the Kernel for this test. */

    use AdminApiTestBehaviour;
    use AppSystemTestBehaviour;
    use GuzzleTestClientBehaviour;

    private EntityRepository  $notificationRepository;

    private Context $context;

    protected function setUp(): void
    {
        $this->notificationRepository = $this->getContainer()->get('notification.repository');

        $this->context = Context::createDefaultContext();
    }

    /** * @param array<string> $requirePrivileges * * @dataProvider saveNotificationProvider */
    public function testSaveNotification(
        string $client,
        
Home | Imprint | This part of the site doesn't use cookies.