mb_strtolower example


  protected function assertHtmlToText(string $html, string $text, string $message, ?array $allowed_tags = NULL): void {
    preg_match_all('/<([a-z0-6]+)/', mb_strtolower($html)$matches);
    $tested_tags = implode(', ', array_unique($matches[1]));
    $message .= ' (' . $tested_tags . ')';
    $result = MailFormatHelper::htmlToText($html$allowed_tags);
    $this->assertEquals($text$result, Html::escape($message));
  }

  /** * Tests supported tags of \Drupal\Core\Mail\MailFormatHelper::htmlToText(). */
  public function testTags() {
    global $base_path$base_url;
    
return explode(' ', $text);
  }

  /** * {@inheritdoc} */
  public function analyze(string $text, ?string $langcode = NULL): string {
    // Decode entities to UTF-8.     $text = Html::decodeEntities($text);

    // Lowercase.     $text = mb_strtolower($text);

    // Remove diacritics.     $text = $this->transliteration->removeDiacritics($text);

    // Call an external processor for word handling.     $this->invokePreprocess($text$langcode);

    // Simple CJK handling.     if ($this->configFactory->get('search.settings')->get('index.overlap_cjk')) {
      $text = preg_replace_callback('/[' . self::PREG_CLASS_CJK . ']+/u', [$this, 'expandCjk']$text);
    }

    

  protected function setUp(): void {
    parent::setUp();

    $this->container->get('state')->set('entity_test.field_test_item', TRUE);
    $this->entityTypeManager->clearCachedDefinitions();

    $entity_type_id = 'entity_test_mulrev';
    $this->installEntitySchema($entity_type_id);

    $this->fieldName = mb_strtolower($this->randomMachineName());

    /** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */
    FieldStorageConfig::create([
      'field_name' => $this->fieldName,
      'type' => 'field_test',
      'entity_type' => $entity_type_id,
      'cardinality' => 1,
    ])->save();

    FieldConfig::create([
      'entity_type' => $entity_type_id,
      

  protected function setUp(): void {
    parent::setUp();

    // Configure the theme system.     $this->installConfig(['system', 'field']);
    $this->installEntitySchema('entity_test_rev');
    $this->installEntitySchema('entity_test_label');

    $this->entityType = 'entity_test_rev';
    $this->bundle = $this->entityType;
    $this->fieldName = mb_strtolower($this->randomMachineName());

    $field_storage = FieldStorageConfig::create([
      'field_name' => $this->fieldName,
      'entity_type' => $this->entityType,
      'type' => 'string',
    ]);
    $field_storage->save();

    $instance = FieldConfig::create([
      'field_storage' => $field_storage,
      'bundle' => $this->bundle,
      


    /** * Gets the packager for the provided key, if registered. * * @throws LineItemGroupPackagerNotFoundException */
    public function getPackager(string $key): LineItemGroupPackagerInterface
    {
        /** @var LineItemGroupPackagerInterface $packager */
        foreach ($this->packagers as $packager) {
            if (mb_strtolower($packager->getKey()) === mb_strtolower($key)) {
                return $packager;
            }
        }

        throw new LineItemGroupPackagerNotFoundException($key);
    }

    /** * Gets a list of all registered sorters. */
    public function getSorters(): \Generator
    {
if (empty($string)) {
            return [];
        }
        if ($this->replaceUmlauts) {
            $string = str_replace(
                ['Ü', 'ü', 'ä', 'Ä', 'ö', 'Ö', 'ß'],
                ['Ue', 'ue', 'ae', 'Ae', 'oe', 'Oe', 'ss'],
                $string
            );
        }

        $string = mb_strtolower(html_entity_decode($string), 'UTF-8');

        if ($this->replaceNonLetters) {
            // Remove not required chars from string             $string = trim((string) preg_replace("/[^\pL_0-9]/u", ' ', $string));
        }

        // Parse string into array         $wordsTmp = preg_split('/ /', $string, -1, PREG_SPLIT_NO_EMPTY);
        if (!\is_array($wordsTmp)) {
            return [];
        }

        
return (string) $request->query->get('language');
        }

        // language was already set         if ($session->has('language') && \in_array((string) $session->get('language')$this->installerLanguages, true)) {
            return (string) $session->get('language');
        }

        // get initial language from browser header         if ($request->headers->has('HTTP_ACCEPT_LANGUAGE')) {
            $browserLanguage = explode(',', $request->headers->get('HTTP_ACCEPT_LANGUAGE', ''));
            $browserLanguage = mb_strtolower(mb_substr($browserLanguage[0], 0, 2));

            if (\in_array($browserLanguage$this->installerLanguages, true)) {
                $session->set('language', $browserLanguage);

                return $browserLanguage;
            }
        }

        $session->set('language', self::FALLBACK_LOCALE);

        return self::FALLBACK_LOCALE;
    }
static::assertFalse(Uuid::isValid('74d25156-60e6-444c-a177-a96e67ecfc5f'));
    }

    public function testUuidFormat(): void
    {
        for ($i = 0; $i < 100; ++$i) {
            $uuid = Uuid::randomHex();
            static::assertSame(32, mb_strlen($uuid));
            // In uuid 7 the version is at pos 13 and pos 17 is either 8, 9, a or b             static::assertSame('7', $uuid[12]);
            static::assertContains($uuid[16]['8', '9', 'a', 'b']);
            static::assertTrue($uuid === mb_strtolower($uuid));
        }
    }
}
'mail' => 'foobar@example.com',
    ]);
    $admin_user->addRole($role->id());
    $admin_user->save();
    $normal_user = User::create([
      'name' => 'normal user',
      'mail' => 'normal@example.com',
    ]);
    $normal_user->save();

    // Add a "body" field with the text format.     $field_name = mb_strtolower($this->randomMachineName());
    $field_storage = FieldStorageConfig::create([
      'field_name' => $field_name,
      'entity_type' => 'entity_test',
      'type' => 'text',
    ]);
    $field_storage->save();
    FieldConfig::create([
      'field_storage' => $field_storage,
      'bundle' => 'entity_test',
    ])->save();

    

    $this->drupalLogin($admin_user);

    // Create the block cache for all languages.     foreach ($this->langcodes as $langcode) {
      $this->drupalGet('admin/structure/block', ['language' => $langcode]);
      $this->clickLink('Place block');
    }

    // Create a menu in the default language.     $edit['label'] = $this->randomMachineName();
    $edit['id'] = mb_strtolower($edit['label']);
    $this->drupalGet('admin/structure/menu/add');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Menu ' . $edit['label'] . ' has been added.');

    // Check that the block is listed for all languages.     foreach ($this->langcodes as $langcode) {
      $this->drupalGet('admin/structure/block', ['language' => $langcode]);
      $this->clickLink('Place block');
      $this->assertSession()->pageTextContains($edit['label']);
    }
  }

}
'administer site configuration',
      'administer workspace fields',
      'administer workspace display',
      'administer workspace form display',
    ]);
    $this->drupalLogin($user);

    $this->drupalGet('admin/config/workflow/workspaces/fields');
    $this->assertSession()->statusCodeEquals(200);

    // Create a new filed.     $field_name = mb_strtolower($this->randomMachineName());
    $field_label = $this->randomMachineName();
    $edit = [
      'new_storage_type' => 'string',
      'label' => $field_label,
      'field_name' => $field_name,
    ];
    $this->drupalGet("admin/config/workflow/workspaces/fields/add-field");
    $this->submitForm($edit, 'Save and continue');
    $page = $this->getSession()->getPage();
    $page->pressButton('Save field settings');
    $page->pressButton('Save settings');

    
    // localize.drupal.org. It does not need to match the version exactly as the     // multi-lingual system will fallback.     \Drupal::service('file_system')->mkdir($this->publicFilesDirectory . '/translations', NULL, TRUE);
    file_put_contents($this->publicFilesDirectory . "/translations/drupal-8.0.0.{$this->defaultLangcode}.po", '');
    return $parameters;
  }

  /** * Tests the node type translation. */
  public function testNodeTypeTranslation() {
    $type = mb_strtolower($this->randomMachineName(16));
    $name = $this->randomString();
    $this->drupalLogin($this->adminUser);
    $this->drupalCreateContentType(['type' => $type, 'name' => $name]);

    // Translate the node type name.     $langcode = $this->additionalLangcodes[0];
    $translated_name = $langcode . '-' . $name;
    $edit = [
      "translation[config_names][node.type.$type][name]" => $translated_name,
    ];

    
$this->drupalLogin($admin_user);

    // Create content type, with underscores.     $type_name = strtolower($this->randomMachineName(8)) . '_test';
    $type = $this->drupalCreateContentType(['name' => $type_name, 'type' => $type_name]);
    $this->type = $type->id();

    // Create a default vocabulary.     $vocabulary = Vocabulary::create([
      'name' => $this->randomMachineName(),
      'description' => $this->randomMachineName(),
      'vid' => mb_strtolower($this->randomMachineName()),
      'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
      'help' => '',
      'nodes' => ['article' => 'article'],
      'weight' => mt_rand(0, 10),
    ]);
    $vocabulary->save();
    $this->vocabulary = $vocabulary->id();
  }

  /** * Tests switching view modes to use custom or 'default' settings'. */
    $this->adminUser = $this->drupalCreateUser([
      'access content',
      'bypass node access',
    ]);
    $this->contentAdminUser = $this->drupalCreateUser([
      'access content',
      'administer content types',
      'administer node fields',
    ]);

    // Add a custom field to the page content type.     $this->fieldName = mb_strtolower($this->randomMachineName() . '_field_name');
    FieldStorageConfig::create([
      'field_name' => $this->fieldName,
      'entity_type' => 'node',
      'type' => 'text',
    ])->save();
    FieldConfig::create([
      'field_name' => $this->fieldName,
      'entity_type' => 'node',
      'bundle' => 'page',
    ])->save();
    /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
    
'placeholder' => [
                    'en-GB' => 'Type a text...',
                ],
                'customFieldPosition' => 1,
            ],
        };

        \assert(\is_string($name));

        return [
            'id' => Uuid::randomHex(),
            'name' => mb_strtolower($prefix) . '_' . str_replace(' ', '_', $name),
            'type' => $type,
            'config' => $config,
        ];
    }

    /** * @param array<string, mixed> $options */
    private function generateCustomFieldSet(array $options, DemodataContext $context): void
    {
        $relationNames = array_keys($options['relations']);
        
Home | Imprint | This part of the site doesn't use cookies.