You are here

public static function SchemaNameBase::testDefaultValue in Schema.org Metatag 8

Provide a random test value.

A helper function to create a random test value. Use the delimiter to create comma-separated values, or a few "words" separated by spaces.

Value must be static so the test can retrieve the value without instantiating the class.

Parameters

int $count: Number of "words".

int $delimiter: Delimiter used to connect "words".

Return value

mixed Return the test value, either a string or array, depending on the property.

Overrides SchemaMetatagTestTagInterface::testDefaultValue

30 calls to SchemaNameBase::testDefaultValue()
SchemaActionBase::testValue in src/Plugin/metatag/Tag/SchemaActionBase.php
Provide a test input value for the property that will validate.
SchemaAddressBase::testValue in src/Plugin/metatag/Tag/SchemaAddressBase.php
Provide a test input value for the property that will validate.
SchemaAnswerBase::testValue in src/Plugin/metatag/Tag/SchemaAnswerBase.php
Provide a test input value for the property that will validate.
SchemaBrandBase::testValue in src/Plugin/metatag/Tag/SchemaBrandBase.php
Provide a test input value for the property that will validate.
SchemaContactPointBase::testValue in src/Plugin/metatag/Tag/SchemaContactPointBase.php
Provide a test input value for the property that will validate.

... See full list

File

src/Plugin/metatag/Tag/SchemaNameBase.php, line 266

Class

SchemaNameBase
All Schema.org tags should extend this class.

Namespace

Drupal\schema_metatag\Plugin\metatag\Tag

Code

public static function testDefaultValue($count = NULL, $delimiter = NULL) {
  $items = [];
  $min = 1;
  $max = isset($count) ? $count : 2;
  $delimiter = isset($delimiter) ? $delimiter : ' ';
  for ($i = $min; $i <= $max; $i++) {

    // Call this value statically for static test value.
    $items[] = SchemaMetatagManager::randomMachineName();
  }
  return implode($delimiter, $items);
}