You are here

public function PropertyTypeBase::testDefaultValue in Schema.org Metatag 8.2

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.

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

1 call to PropertyTypeBase::testDefaultValue()
PropertyTypeBase::testValue in src/Plugin/schema_metatag/PropertyTypeBase.php
Provide a test input value for the property that will validate.

File

src/Plugin/schema_metatag/PropertyTypeBase.php, line 370

Class

PropertyTypeBase
Base class for Property type plugins.

Namespace

Drupal\schema_metatag\Plugin\schema_metatag

Code

public function testDefaultValue($count = NULL, $delimiter = NULL) {
  $items = [];
  $min = 1;
  $max = isset($count) ? $count : 2;
  $delimiter = isset($delimiter) ? $delimiter : ' ';
  for ($i = $min; $i <= $max; $i++) {
    $items[] = $this
      ->schemaMetatagManager()
      ->randomMachineName();
  }
  return implode($delimiter, $items);
}