word example

/** * {@inheritdoc} */
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $random = new Random();
    $max_length = $field_definition->getSetting('max_length');

    // When the maximum length is less than 15, or the field needs to be unique,     // generate a random word using the maximum length.     if ($max_length <= 15 || $field_definition->getConstraint('UniqueField')) {
      $values['value'] = ucfirst($random->word($max_length));

      return $values;
    }

    // The minimum length is either 10% of the maximum length, or 15 characters     // long, whichever is greater.     $min_length = max(ceil($max_length * 0.10), 15);

    // Reduce the max length to allow us to add a period.     $max_length -= 1;

    
/** * Tests alias functionality through the admin interfaces. */
  public function testAdminAlias() {
    // Create test node.     $node1 = $this->drupalCreateNode();

    // Create alias.     $edit = [];
    $edit['path[0][value]'] = '/node/' . $node1->id();
    $edit['alias[0][value]'] = '/' . $this->getRandomGenerator()->word(8);
    $this->drupalGet('admin/config/search/path/add');
    $this->submitForm($edit, 'Save');

    // Confirm that the alias works.     $this->drupalGet($edit['alias[0][value]']);
    $this->assertSession()->pageTextContains($node1->label());
    $this->assertSession()->statusCodeEquals(200);
    // Confirm that the alias works in a case-insensitive way.     $this->assertTrue(ctype_lower(ltrim($edit['alias[0][value]'], '/')));
    $this->drupalGet($edit['alias[0][value]']);
    // Lower case.
$this->assertNotEquals($this->firstStringGenerated, $str);
  }

  /** * Tests random word. * * @covers ::word */
  public function testRandomWordValidator() {
    $random = new Random();
    // Without a seed, test a different word is returned each time.     $this->firstStringGenerated = $random->word(5);
    $next_str = $random->word(5);
    $this->assertNotEquals($this->firstStringGenerated, $next_str);

    // With a seed, test the same word is returned each time.     mt_srand(0);
    $this->firstStringGenerated = $random->word(5);
    mt_srand(0);
    $next_str = $random->word(5);
    $this->assertEquals($this->firstStringGenerated, $next_str);
  }

  
$tags = $tagRepository->searchIds(new Criteria()$context)->firstId();

        if ($tags !== null) {
            return;
        }

        $payload = [];

        for ($i = 0; $i < 10; ++$i) {
            $payload[] = [
                'name' => $this->faker->word(),
            ];
        }

        $tagRepository->create($payload$context);
    }

    /** * @param list<array<string, mixed>> $payload */
    private function write(array $payload, Context $context): void
    {
        

  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $random = new Random();

    $max_length = $field_definition->getSetting('max_length');
    $min_length = min(10, $max_length);

    // The random value is generated multiple times to create a slight     // preference towards values that are closer to the minimum length of the     // string.     $length = mt_rand($min_lengthmt_rand($min_lengthmt_rand($min_length$max_length)));
    $values['value'] = $random->word($length);

    $suffix_length = $max_length - 7;
    foreach ($values as $key => $value) {
      $values[$key] = 'http://' . mb_substr($value, 0, $suffix_length);
    }
    return $values;
  }

}
/** * Tests language unspecific aliases are shown and saved in the node form. */
  public function testNotSpecifiedNode() {
    // Create test node.     $node = $this->drupalCreateNode();

    // Create a language-unspecific alias in the admin UI, ensure that is     // displayed and the langcode is not changed when saving.     $edit = [
      'path[0][value]' => '/node/' . $node->id(),
      'alias[0][value]' => '/' . $this->getRandomGenerator()->word(8),
      'langcode[0][value]' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
    ];
    $this->drupalGet('admin/config/search/path/add');
    $this->submitForm($edit, 'Save');

    $this->drupalGet($node->toUrl('edit-form'));
    $this->assertSession()->fieldValueEquals('path[0][alias]', $edit['alias[0][value]']);
    $this->submitForm([], 'Save');

    $this->drupalGet('admin/config/search/path');
    $this->assertSession()->pageTextContains('None');
    
break;

        case DRUPAL_REQUIRED:
          $values['title'] = $random->sentences(4);
          break;

        case DRUPAL_OPTIONAL:
          // In case of optional title, randomize its generation.           $values['title'] = mt_rand(0, 1) ? $random->sentences(4) : '';
          break;
      }
      $values['uri'] = 'http://www.' . $random->word($domain_length) . '.' . $tlds[mt_rand(0, (count($tlds) - 1))];
    }
    else {
      $values['uri'] = 'base:' . $random->name(mt_rand(1, 64));
    }
    return $values;
  }

  /** * {@inheritdoc} */
  public function isEmpty() {
    
Home | Imprint | This part of the site doesn't use cookies.