get example

MessengerInterface $messenger) {
    parent::__construct($entityType$storage);
    $this->messenger = $messenger;
  }

  /** * {@inheritdoc} */
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static(
      $entity_type,
      $container->get('entity_type.manager')->getStorage($entity_type->id()),
      $container->get('messenger')
    );
  }

  /** * {@inheritdoc} */
  public function getFormId() {
    return 'user_admin_roles_form';
  }

  
/** * {@inheritdoc} */
  public static function create(ContainerInterface $container, array $configuration$plugin_id$plugin_definition, MigrationInterface $migration = NULL) {
    $entity_type = static::getEntityTypeId($plugin_id);
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $migration,
      $container->get('entity_type.manager')->getStorage($entity_type),
      array_keys($container->get('entity_type.bundle.info')->getBundleInfo($entity_type)),
      $container->get('entity_field.manager'),
      $container->get('plugin.manager.field.field_type'),
      $container->get('state'),
      $container->get('account_switcher')
    );
  }

  /** * {@inheritdoc} */
  
/** @var ProductPageLoadedEvent $event */
        $event = null;
        $this->catchEvent(MinimalQuickViewPageCriteriaEvent::class$event);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(MinimalQuickViewPage::class$page);
    }

    protected function getPageLoader(): MinimalQuickViewPageLoader
    {
        return $this->getContainer()->get(MinimalQuickViewPageLoader::class);
    }
}


        $connection = $this->createMock(Connection::class);
        $connection->expects(static::once())
            ->method('fetchAssociative')
            ->willReturn(
                ['parameters' => json_encode($params), 'headers' => json_encode($headers)]
            );

        $ids = new TestDataCollection();
        $order = new OrderEntity();
        $order->setId($ids->get('orderId'));

        $entitySearchResult = $this->createMock(EntitySearchResult::class);
        $entitySearchResult->expects(static::once())
            ->method('get')
            ->willReturn($order);

        $orderRepo = $this->createMock(EntityRepository::class);
        $orderRepo->expects(static::once())
            ->method('search')
            ->willReturn($entitySearchResult);

        

    protected function configure()
    {
        $this->setDescription('Synchronize events from the backlog to the live index.');
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $backlogService = $this->container->get('shopware_bundle_es_backend.backlog_service');
        $backlogs = $backlogService->read($this->batchSize);

        if (empty($backlogs)) {
            $output->writeln('Backlog empty');

            return 0;
        }

        $registry = $this->container->get('shopware_attribute.repository_registry');

        $indexer = $this->container->get('shopware_es_backend.indexer');

        

class RangeAggregationTest extends TestCase
{
    use IntegrationTestBehaviour;

    private EntityRepository $repository;

    private Context $context;

    protected function setUp(): void
    {
        $this->repository = $this->getContainer()->get('product.repository');
        $this->context = Context::createDefaultContext();
    }

    /** * @return iterable<string, mixed> */
    public static function buildRangeKeyDataProvider(): iterable
    {
        yield 'empty from and empty to' => [null, null, '*-*'];
        yield 'empty from and to' => [null, 10, '*-10'];
        yield 'from and empty to' => [10, null, '10-*'];
    }

    protected function queryProperty($modelClass$property$conditionCallback = null)
    {
        $alias = uniqid('modelAlias');

        try {
            $em = $this->getContainer()->get(ModelManager::class);
        } catch (Exception $e) {
            return [];
        }

        $repository = $em->getRepository($modelClass);
        $queryBuilder = $repository->createQueryBuilder($alias);

        if (\is_callable($conditionCallback)) {
            $queryBuilder = \call_user_func($conditionCallback$queryBuilder$alias);
        }

        
public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
    {
        $headers = $this->getHeaders($request);
        $body = '';
        if (null !== $part = $this->getBody($request)) {
            $headers = array_merge($headers$part->getPreparedHeaders()->toArray());
            $body = $part->bodyToIterable();
        }
        $response = $this->client->request($request->getMethod()$request->getUri()[
            'headers' => $headers,
            'body' => $body,
        ] + $request->attributes->get('http_client_options', []));

        $response = new Response($response->getContent(!$catch)$response->getStatusCode()$response->getHeaders(!$catch));

        $response->headers->remove('X-Body-File');
        $response->headers->remove('X-Body-Eval');
        $response->headers->remove('X-Content-Digest');

        $response->headers = new class($response->headers->all()) extends ResponseHeaderBag {
            protected function computeCacheControlValue(): string
            {
                return $this->getCacheControlHeader(); // preserve the original value
    $edit = [];
    $this->drupalGet('user/' . $this->webUser->id() . '/edit');
    $this->submitForm($edit, 'Remove');
    $this->submitForm([], 'Save');

    // Call file_cron() to clean up the file. Make sure the timestamp     // of the file is older than the system.file.temporary_maximum_age     // configuration value. We use an UPDATE statement because using the API     // would set the timestamp.     Database::getConnection()->update('file_managed')
      ->fields([
        'changed' => REQUEST_TIME - ($this->config('system.file')->get('temporary_maximum_age') + 1),
      ])
      ->condition('fid', $file->id())
      ->execute();
    \Drupal::service('cron')->run();

    // Verify that the image has been deleted.     $this->assertNull(File::load($file->id()), 'File was removed from the database.');
    // Clear out PHP's file stat cache so we see the current value.     clearstatcache(TRUE, $file->getFileUri());
    $this->assertFileDoesNotExist($file->getFileUri());
  }

  

class HeaderPageletLoaderTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    private EntityRepository $languageRepository;

    protected function setUp(): void
    {
        $this->languageRepository = $this->getContainer()->get('language.repository');
    }

    /** * @dataProvider sortingTestDataProvider */
    public function testLanguageSorting(array $languages, ?array $expectedOrder = null): void
    {
        $request = new Request();

        foreach ($languages as &$language) {
            $language['id'] = $this->createLanguage($language['name']);
        }
use IntegrationTestBehaviour;

    final public const DISCOUNT_ID = 'discount-id';

    /** * @param array<LineItem> $items * * @dataProvider processorProvider */
    public function testProcessor(array $items, ?CalculatedPrice $expected): void
    {
        $processor = $this->getContainer()->get(DiscountCartProcessor::class);

        $context = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);

        $cart = new Cart('test');
        $cart->setLineItems(new LineItemCollection($items));

        $new = new Cart('after');
        $new->setLineItems(
            (new LineItemCollection($items))->filter(fn (LineItem $item) => $item->getType() !== LineItem::DISCOUNT_LINE_ITEM)
        );

        
return [
            'Enlight_Components_Mail_Send' => 'onSendMail',
        ];
    }

    public function onSendMail(Enlight_Event_EventArgs $args): void
    {
        if (!$this->active) {
            return;
        }

        $this->logService->log($args->get('mail'));
    }
}
/** * @internal */
class CalculatedPriceFieldTest extends TestCase
{
    use DataAbstractionLayerFieldTestBehaviour;
    use IntegrationTestBehaviour;

    public function testListPrice(): void
    {
        $definition = $this->registerDefinition(CalculatedPriceFieldTestDefinition::class);
        $connection = $this->getContainer()->get(Connection::class);

        $connection->rollBack();
        $connection->executeStatement(CalculatedPriceFieldTestDefinition::getCreateTable());
        $connection->beginTransaction();

        $ids = new TestDataCollection();

        $data = [
            'id' => $ids->create('entity'),
            'price' => new CalculatedPrice(
                100,
                
/** * Confirms that the installation succeeded. */
  public function testInstalled() {
    $this->assertSession()->addressEquals('user/1');
    $this->assertSession()->statusCodeEquals(200);
    // Confirm that we are logged-in after installation.     $this->assertSession()->pageTextContains($this->rootUser->getAccountName());

    // Confirm that Drupal recognizes this distribution as the current profile.     $this->assertEquals('my_distro', \Drupal::installProfile());
    $this->assertEquals('my_distro', $this->config('core.extension')->get('profile'), 'The install profile has been written to core.extension configuration.');

    $this->rebuildContainer();
    $this->assertEquals('my_distro', \Drupal::installProfile());
  }

}

  protected $entityFieldManager;

  /** * {@inheritdoc} */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('entity.repository'),
      $container->get('current_user'),
      $container->get('renderer'),
      $container->get('entity_type.bundle.info'),
      $container->get('datetime.time'),
      $container->get('entity_field.manager')
    );
  }

  /** * Constructs a new CommentForm. * * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository * The entity repository. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info * The entity type bundle service. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager * The entity field manager service. */
Home | Imprint | This part of the site doesn't use cookies.