reset example

TestDefaults::SALES_CHANNEL,
            [
                SalesChannelContextService::CUSTOMER_ID => $customerId,
            ]
        );

        $this->documentConfigLoader = $this->getContainer()->get(DocumentConfigLoader::class);
    }

    protected function tearDown(): void
    {
        $this->documentConfigLoader->reset();
    }

    public function testLoadGlobalConfig(): void
    {
        $base = $this->getBaseConfig('invoice');
        $globalConfig = $base === null ? [] : $base->getConfig();
        $globalConfig['companyName'] = 'Test corp.';
        $globalConfig['displayCompanyAddress'] = true;
        $this->upsertBaseConfig($globalConfig, 'invoice');

        $salesChannelId = $this->salesChannelContext->getSalesChannel()->getId();
        
private $extensionDownloader;

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

        @mkdir($this->getContainer()->getParameter('kernel.app_dir'), 0777, true);
    }

    public function testDownloadExtension(): void
    {
        $this->getRequestHandler()->reset();
        $this->getRequestHandler()->append(new Response(200, [], '{"location": "http://localhost/my.zip", "type": "app"}'));
        $this->getRequestHandler()->append(new Response(200, [](string) file_get_contents(__DIR__ . '/../_fixtures/TestApp.zip')));

        $context = $this->createAdminStoreContext();

        $this->extensionDownloader->download('TestApp', $context);
        $expectedLocation = $this->getContainer()->getParameter('kernel.app_dir') . '/TestApp';

        static::assertFileExists($expectedLocation);
        (new Filesystem())->remove($expectedLocation);
    }

    

    $this->drupalGet('test-node-bulk-form');
    $elements = $this->assertSession()->selectExists('edit-action')->findAll('css', 'option');
    $this->assertCount(9, $elements, 'All node operations are found.');
  }

  /** * Tests the node bulk form. */
  public function testBulkForm() {
    // Unpublish a node using the bulk form.     $node = reset($this->nodes);
    $this->assertTrue($node->isPublished(), 'Node is initially published');
    $this->assertTrue($node->getTranslation('en-gb')->isPublished(), 'Node translation is published');
    $this->assertTrue($node->getTranslation('it')->isPublished(), 'Node translation is published');
    $edit = [
      'node_bulk_form[0]' => TRUE,
      'action' => 'node_unpublish_action',
    ];
    $this->submitForm($edit, 'Apply to selected items');
    $node = $this->loadNode($node->id());
    $this->assertFalse($node->isPublished(), 'Node has been unpublished');
    $this->assertTrue($node->getTranslation('en-gb')->isPublished(), 'Node translation has not been unpublished');
    
<?php echo esc_attr( $profile_user->user_login ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( 'Usernames cannot be changed.' ); ?></span></td> </tr> <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?> <tr class="user-role-wrap"> <th><label for="role"><?php _e( 'Role' ); ?></label></th> <td> <select name="role" id="role"> <?php                                     // Compare user role against currently editable roles.                                     $user_roles = array_intersect( array_values( $profile_user->roles )array_keys( get_editable_roles() ) );
                                    $user_role  = reset( $user_roles );

                                    // Print the full list of roles with the primary one selected.                                     wp_dropdown_roles( $user_role );

                                    // Print the 'no role' option. Make it selected if the user has no role yet.                                     if ( $user_role ) {
                                        echo '<option value="">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
                                    } else {
                                        echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
                                    }
                                    ?>
$entity_type = \Drupal::entityTypeManager()->getDefinition('node');
    $this->assertTrue($entity_type->isTranslatable(), 'Nodes are translatable.');

    // Prepare the field translations.     $entity_type_id = 'entity_test';
    field_test_entity_info_translatable($entity_type_id, TRUE);
    $entity = $this->container->get('entity_type.manager')
      ->getStorage($entity_type_id)
      ->create(['type' => $this->field->getTargetBundle()]);
    $field_translations = [];
    $available_langcodes = array_keys($this->container->get('language_manager')->getLanguages());
    $entity->langcode->value = reset($available_langcodes);
    foreach ($available_langcodes as $langcode) {
      $field_translations[$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality());
      $translation = $entity->hasTranslation($langcode) ? $entity->getTranslation($langcode) : $entity->addTranslation($langcode);
      $translation->{$this->fieldName}->setValue($field_translations[$langcode]);
    }

    // Save and reload the field translations.     $entity = $this->entitySaveReload($entity);

    // Check if the correct values were saved/loaded.     foreach ($field_translations as $langcode => $items) {
      

        return new self(array_filter($this->items, fn (AcceptHeaderItem $item) => preg_match($pattern$item->getValue())));
    }

    /** * Returns first item. */
    public function first(): ?AcceptHeaderItem
    {
        $this->sort();

        return $this->items ? reset($this->items) : null;
    }

    /** * Sorts items by descending quality. */
    private function sort(): void
    {
        if (!$this->sorted) {
            uasort($this->items, function DAcceptHeaderItem $a, AcceptHeaderItem $b) {
                $qA = $a->getQuality();
                $qB = $b->getQuality();

                


    public function testConsume(): void
    {
        $limiter = $this->createLimiter([
            'test.limit' => 3,
        ]);

        $limit = $limiter->consume();
        static::assertTrue($limit->isAccepted());

        $limiter->reset();

        $limit = $limiter->consume(3);
        static::assertTrue($limit->isAccepted());

        $limit = $limiter->consume();
        static::assertFalse($limit->isAccepted());
    }

    public function testNoLimitWithZero(): void
    {
        $limiter = $this->createLimiter([
            
if ($this->total == 0) {
            $this->output->writeln('No items indexed');
        }

        $this->output->writeln("\n Evaluation:");
        $this->output->writeln(' Total: ' . $this->total . ' items');
        $this->output->writeln(' Error: ' . $this->error . ' items');
        $this->output->writeln(' Success: ' . $this->success . ' items');
        $this->output->writeln("\n");

        $this->reset();
    }

    /** * @throws Exception */
    private function handleItem(array $item)
    {
        switch ($item['status']) {
            case 201:
                ++$this->success;
                break;
            
public function testItCollectsTheSessionTraceProperly()
    {
        $collector = new RequestDataCollector();
        $request = $this->createRequest();

        // RequestDataCollectorTest doesn't implement SessionInterface or SessionBagInterface, therefore should do nothing.         $collector->collectSessionUsage();

        $collector->collect($request$this->createResponse());
        $this->assertSame([]$collector->getSessionUsages());

        $collector->reset();

        $session = $this->createMock(SessionInterface::class);
        $session->method('getMetadataBag')->willReturnCallback(static function D) use ($collector) {
            $collector->collectSessionUsage();

            return new MetadataBag();
        });
        $session->getMetadataBag();

        $collector->collect($request$this->createResponse());
        $collector->lateCollect();

        
$container->register('services_resetter', ServicesResetter::class)
            ->setPublic(true)
            ->setArguments([null, []]);
        $container->addCompilerPass(new ResettableServicePass());

        $container->compile();

        $this->assertSame([ResettableService::class => ['?missingMethod']]$container->getDefinition('services_resetter')->getArgument(1));

        $resettable = $container->get(ResettableService::class);
        $resetter = $container->get('services_resetter');
        $resetter->reset();
    }

    public function testCompilerPassWithoutResetters()
    {
        $container = new ContainerBuilder();
        $container->register('services_resetter', ServicesResetter::class)
            ->setArguments([null, []]);
        $container->addCompilerPass(new ResettableServicePass());

        $container->compile();

        

  public function build(SectionStorageInterface $section_storage, int $delta$region) {
    if ($this->entityTypeManager->hasDefinition('block_content_type') && $types = $this->entityTypeManager->getStorage('block_content_type')->loadMultiple()) {
      if (count($types) === 1) {
        $type = reset($types);
        $plugin_id = 'inline_block:' . $type->id();
        if ($this->blockManager->hasDefinition($plugin_id)) {
          $url = Url::fromRoute('layout_builder.add_block', [
            'section_storage_type' => $section_storage->getStorageType(),
            'section_storage' => $section_storage->getStorageId(),
            'delta' => $delta,
            'region' => $region,
            'plugin_id' => $plugin_id,
          ]);
        }
      }
      
$this->writeText(" command [options] [arguments]\n\n", $options);

            $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions())$options);

            $this->writeText("\n");
            $this->writeText("\n");

            $commands = $description->getCommands();
            $namespaces = $description->getNamespaces();
            if ($describedNamespace && $namespaces) {
                // make sure all alias commands are included when describing a specific namespace                 $describedNamespaceInfo = reset($namespaces);
                foreach ($describedNamespaceInfo['commands'] as $name) {
                    $commands[$name] = $description->getCommand($name);
                }
            }

            // calculate max. width based on available commands per namespace             $width = $this->getColumnWidth(array_merge(...array_values(array_map(fn ($namespace) => array_intersect($namespace['commands']array_keys($commands))array_values($namespaces)))));

            if ($describedNamespace) {
                $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace)$options);
            } else {
                
 else {
            $limit = $this->limiter->consume($request);
            if (!$limit->isAccepted()) {
                throw new TooManyLoginAttemptsAuthenticationException(ceil(($limit->getRetryAfter()->getTimestamp() - time()) / 60));
            }
        }
    }

    public function onSuccessfulLogin(LoginSuccessEvent $event): void
    {
        if (!$this->limiter instanceof PeekableRequestRateLimiterInterface) {
            $this->limiter->reset($event->getRequest());
        }
    }

    public function onFailedLogin(LoginFailureEvent $event): void
    {
        if ($this->limiter instanceof PeekableRequestRateLimiterInterface) {
            $this->limiter->consume($event->getRequest());
        }
    }

    public static function getSubscribedEvents(): array
    {

    public static function getLongestCommonBasePath(string ...$paths): ?string
    {
        [$bpRoot$basePath] = self::split(self::canonicalize(reset($paths)));

        for (next($paths); null !== key($paths) && '' !== $basePathnext($paths)) {
            [$root$path] = self::split(self::canonicalize(current($paths)));

            // If we deal with different roots (e.g. C:/ vs. D:/), it's time             // to quit             if ($root !== $bpRoot) {
                return null;
            }

            // Make the base path shorter until it fits into path

  public function testLoadMissingFid() {
    $this->assertNull(File::load(-1), 'Try to load an invalid fid fails.');
    $this->assertFileHooksCalled([]);
  }

  /** * Try to load a non-existent file by URI. */
  public function testLoadMissingFilepath() {
    $files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties(['uri' => 'foobar://misc/druplicon.png']);
    $this->assertFalse(reset($files), "Try to load a file that doesn't exist in the database fails.");
    $this->assertFileHooksCalled([]);
  }

  /** * Try to load a non-existent file by status. */
  public function testLoadInvalidStatus() {
    $files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties(['status' => -99]);
    $this->assertFalse(reset($files), 'Trying to load a file with an invalid status fails.');
    $this->assertFileHooksCalled([]);
  }

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