set example

/** * @var array<string, string> */
    protected $reverseIndex = [];

    /** * @param Mapping $mapping */
    public function add($mapping): void
    {
        $this->validateType($mapping);
        $this->set($mapping->getKey()$mapping);
    }

    /** * @param string $key * @param Mapping $mapping */
    public function set($key$mapping): void
    {
        $this->validateType($mapping);
        $mappingKey = $mapping->getKey();
        if (empty($mappingKey)) {
            
$request = $event->getRequest();
        if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent', ''))
            && !$request->headers->has('X-FirePHP-Version')) {
            self::$sendHeaders = false;
            $this->headers = [];

            return;
        }

        $this->response = $event->getResponse();
        foreach ($this->headers as $header => $content) {
            $this->response->headers->set($header$content);
        }
        $this->headers = [];
    }

    protected function sendHeader($header$content): void
    {
        if (!self::$sendHeaders) {
            return;
        }

        if (null !== $this->response) {
            
#[Package('cause')] class AnnotatePackageProcessorTest extends TestCase
{
    public function testOnlyController(): void
    {
        $requestStack = new RequestStack();
        $inner = $this->createMock(AbstractHandler::class);
        $container = $this->createMock(ContainerInterface::class);
        $handler = new AnnotatePackageProcessor($requestStack$container);

        $request = new Request();
        $request->attributes->set('_controller', TestController::class D '::load');
        $requestStack->push($request);

        $record = new LogRecord(
            new \DateTimeImmutable(),
            'business events',
            Level::Error,
            'Some message'
        );

        $expected = new LogRecord(
            $record->datetime,
            
$this->expectExceptionMessage('Either specify at least one pool name, or provide the --all option to clear all pools.');

        $this->createCommandTester()->execute([]['decorated' => false]);
    }

    public function testClearFailed()
    {
        $tester = $this->createCommandTester();
        /** @var FilesystemAdapter $pool */
        $pool = static::getContainer()->get('cache.public_pool');
        $item = $pool->getItem('foo');
        $item->set('baz');
        $pool->save($item);
        $r = new \ReflectionObject($pool);
        $p = $r->getProperty('directory');
        $poolDir = $p->getValue($pool);

        /** @var SplFileInfo $entry */
        foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($poolDir)) as $entry) {
            // converts files into dir to make adapter fail             if ($entry->isFile()) {
                unlink($entry->getPathname());
                mkdir($entry->getPathname());
            }
'C:10:"serialized"'
        );

        $this->assertFalse($session->has('_security_session'));
    }

    public function testOnKernelResponseWithoutSession()
    {
        $tokenStorage = new TokenStorage();
        $tokenStorage->setToken(new UsernamePasswordToken(new InMemoryUser('test1', 'pass1'), 'phpunit', ['ROLE_USER']));
        $request = new Request();
        $request->attributes->set('_security_firewall_run', '_security_session');
        $session = new Session(new MockArraySessionStorage());
        $request->setSession($session);

        $event = new ResponseEvent(
            $this->createMock(HttpKernelInterface::class),
            $request,
            HttpKernelInterface::MAIN_REQUEST,
            new Response()
        );

        $listener = new ContextListener($tokenStorage[], 'session', null, new EventDispatcher());
        


  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    foreach ($form_state->getValues() as $key => $value) {
      // Only save values onto the view if they're actual view properties       // (as opposed to 'op' or 'form_build_id').       if (isset($form['details'][$key])) {
        $view->set($key$value);
      }
    }
    $bases = Views::viewsData()->fetchBaseTables();
    $page_title = $view->label();
    if (isset($bases[$view->get('base_table')])) {
      $page_title .= ' (' . $bases[$view->get('base_table')]['title'] . ')';
    }
    $form_state->set('page_title', $page_title);

    $view->cacheSet();
  }

}
$this->assertFalse($this->container->get('twig')->isDebug(), 'Twig debug disabled.');
  }

  /** * Ensures Twig template cache setting can be overridden. */
  public function testTwigCacheOverride() {
    $extension = twig_extension();
    $theme_installer = $this->container->get('theme_installer');
    $theme_installer->install(['test_theme']);
    $this->config('system.theme')->set('default', 'test_theme')->save();

    // The registry still works on theme globals, so set them here.     \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->getActiveThemeByName('test_theme'));

    // Reset the theme registry, so that the new theme is used.     $this->container->set('theme.registry', NULL);

    // Load array of Twig templates.     // reset() is necessary to invalidate caches tagged with 'theme_registry'.     $registry = $this->container->get('theme.registry');
    $registry->reset();
    
$this->assertSession()->pageTextNotContains('The following module is experimental: Experimental Dependency Test');

    // There should be no message about enabling dependencies.     $this->assertSession()->pageTextNotContains('You must enable');

    // Enable the module and confirm that it worked.     $this->submitForm([], 'Continue');
    $this->assertSession()->pageTextContains('2 modules have been enabled: Experimental Dependency Test, Experimental Test');

    // Try to enable an experimental module that can not be due to     // hook_requirements().     \Drupal::state()->set('experimental_module_requirements_test_requirements', TRUE);
    $edit = [];
    $edit["modules[experimental_module_requirements_test][enable]"] = TRUE;
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');

    // Verify that if the module can not be installed, we are not taken to the     // confirm form.     $this->assertSession()->addressEquals('admin/modules');
    $this->assertSession()->pageTextContains('The Experimental Test Requirements module can not be installed.');
  }

  
$container = new ContainerBuilder();
    \Drupal::setContainer($container);
  }

  /** * @covers ::viewsForm */
  public function testViewsForm(): void {
    $row = new ResultRow();

    $container = new ContainerBuilder();
    $container->set('string_translation', $this->createMock(TranslationInterface::class));
    \Drupal::setContainer($container);

    $field = $this->getMockBuilder(BulkForm::class)
      ->onlyMethods(['getEntityType', 'getEntity'])
      ->disableOriginalConstructor()
      ->getMock();
    $field->expects($this->any())
      ->method('getEntityType')
      ->willReturn('foo');
    $field->expects($this->any())
      ->method('getEntity')
      
// Add at least one link to the main menu.     $parent_menu_link_content = MenuLinkContent::create([
      'title' => 'Home',
      'menu_name' => 'main',
      'link' => ['uri' => 'route:<front>'],
    ]);
    $parent_menu_link_content->save();

    // Set branding color.     $system_theme_config = $this->container->get('config.factory')->getEditable('olivero.settings');
    $system_theme_config
      ->set('site_branding_bg_color', 'gray')
      ->save();

    $this->rebuildAll();
    $this->drupalLogin(
      $this->drupalCreateUser(['search content'])
    );

    // Confirm that search narrow and search wide libraries were added by     // preprocess.     $this->assertSession()->responseContains('olivero/css/components/header-search-wide.css');
    $this->assertSession()->responseContains('olivero/css/components/header-search-narrow.css');

    


        if (!$master->hasSession()) {
            return;
        }

        $session = $master->getSession();

        if (!$session->isStarted()) {
            $session->setName('session-');
            $session->start();
            $session->set('sessionId', $session->getId());
        }

        $salesChannelId = $master->attributes->get(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_ID);
        if ($salesChannelId === null) {
            /** @var SalesChannelContext|null $salesChannelContext */
            $salesChannelContext = $master->attributes->get(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT);
            if ($salesChannelContext !== null) {
                $salesChannelId = $salesChannelContext->getSalesChannel()->getId();
            }
        }

        
$langcode = language_get_default_langcode('entity_test', 'custom_bundle');
    $language_interface = \Drupal::languageManager()->getCurrentLanguage();
    $this->assertEquals($langcode$language_interface->getId());

    // Site's default.     $old_default = \Drupal::languageManager()->getDefaultLanguage();
    // Ensure the language entity default value is correct.     $configurable_language = ConfigurableLanguage::load($old_default->getId());
    $this->assertTrue($configurable_language->isDefault(), 'The en language entity is flagged as the default language.');

    $this->config('system.site')->set('default_langcode', 'cc')->save();
    ContentLanguageSettings::loadByEntityTypeBundle('entity_test', 'custom_bundle')
      ->setLanguageAlterable(TRUE)
      ->setDefaultLangcode(LanguageInterface::LANGCODE_SITE_DEFAULT)
      ->save();
    $langcode = language_get_default_langcode('entity_test', 'custom_bundle');
    $this->assertEquals('cc', $langcode);

    // Ensure the language entity default value is correct.     $configurable_language = ConfigurableLanguage::load($old_default->getId());
    $this->assertFalse($configurable_language->isDefault(), 'The en language entity is not flagged as the default language.');
    $configurable_language = ConfigurableLanguage::load('cc');
    
parent::setUp();

    $this->themeInstaller = $this->container->get('theme_installer');
    $this->themeManager = $this->container->get('theme.manager');
  }

  /** * Tests opting out of Stable 9 by setting the base theme to false. */
  public function testWildWest() {
    $this->themeInstaller->install(['test_wild_west']);
    $this->config('system.theme')->set('default', 'test_wild_west')->save();
    $theme = $this->themeManager->getActiveTheme();
    /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
    $base_themes = $theme->getBaseThemeExtensions();
    $this->assertEmpty($base_themes, 'No base theme is set when a theme has opted out of using Stable 9.');
  }

}
$container->get('plugin.manager.field.field_type'),
      $container->get('state'),
      $container->get('account_switcher')
    );
  }

  /** * {@inheritdoc} */
  public function import(Row $row, array $old_destination_id_values = []) {
    if ($row->isStub() && ($state = $this->state->get('comment.maintain_entity_statistics', 0))) {
      $this->state->set('comment.maintain_entity_statistics', 0);
    }
    $return = parent::import($row$old_destination_id_values);
    if ($row->isStub() && $state) {
      $this->state->set('comment.maintain_entity_statistics', $state);
    }
    return $return;
  }

  /** * {@inheritdoc} */
  

  public function testUserMailsSent($op, array $mail_keys) {
    $this->installConfig('user');
    $this->config('system.site')->set('mail', 'test@example.com')->save();
    $this->config('user.settings')->set('notify.' . $op, TRUE)->save();
    $return = _user_mail_notify($op$this->createUser());
    $this->assertTrue($return);
    foreach ($mail_keys as $key) {
      $filter = ['key' => $key];
      $this->assertNotEmpty($this->getMails($filter));
    }
    $this->assertSameSize($mail_keys$this->getMails());
  }

  /** * Tests mails are not sent when notify.$op is FALSE. * * @param string $op * The operation being performed on the account. * * @dataProvider userMailsProvider */
Home | Imprint | This part of the site doesn't use cookies.