You are here

public function SearchApiBackendUnitTest::addIndexFieldDataProvider in Search API Solr 8.3

Same name and namespace in other branches
  1. 8 tests/src/Unit/SearchApiBackendUnitTest.php \Drupal\Tests\search_api_solr\Unit\SearchApiBackendUnitTest::addIndexFieldDataProvider()
  2. 8.2 tests/src/Unit/SearchApiBackendUnitTest.php \Drupal\Tests\search_api_solr\Unit\SearchApiBackendUnitTest::addIndexFieldDataProvider()
  3. 4.x tests/src/Unit/SearchApiBackendUnitTest.php \Drupal\Tests\search_api_solr\Unit\SearchApiBackendUnitTest::addIndexFieldDataProvider()

Data provider for testIndexField method.

File

tests/src/Unit/SearchApiBackendUnitTest.php, line 145

Class

SearchApiBackendUnitTest
Tests functionality of the backend.

Namespace

Drupal\Tests\search_api_solr\Unit

Code

public function addIndexFieldDataProvider() {
  return [
    // addIndexField() should be called.
    [
      '0',
      'boolean',
      'false',
    ],
    [
      '1',
      'boolean',
      'true',
    ],
    [
      0,
      'boolean',
      'false',
    ],
    [
      1,
      'boolean',
      'true',
    ],
    [
      FALSE,
      'boolean',
      'false',
    ],
    [
      TRUE,
      'boolean',
      'true',
    ],
    [
      '2016-05-25T14:00:00+10',
      'date',
      '2016-05-25T04:00:00Z',
    ],
    [
      '1465819200',
      'date',
      '2016-06-13T12:00:00Z',
    ],
    [
      new DateRangeValue('2016-05-25T14:00:00+10', '2017-05-25T14:00:00+10'),
      'solr_date_range',
      '[2016-05-25T04:00:00Z TO 2017-05-25T04:00:00Z]',
    ],
    [
      -1,
      'integer',
      -1,
    ],
    [
      0,
      'integer',
      0,
    ],
    [
      1,
      'integer',
      1,
    ],
    [
      -1.0,
      'decimal',
      -1.0,
    ],
    [
      0.0,
      'decimal',
      0.0,
    ],
    [
      1.3,
      'decimal',
      1.3,
    ],
    [
      'foo',
      'string',
      'foo',
    ],
    [
      new TextValue('foo bar'),
      'text',
      'foo bar',
    ],
    [
      (new TextValue(''))
        ->setTokens([
        new TextToken('bar'),
      ]),
      'text',
      'bar',
    ],
    // addIndexField() should not be called.
    [
      NULL,
      'boolean',
      NULL,
    ],
    [
      NULL,
      'date',
      NULL,
    ],
    [
      NULL,
      'solr_date_range',
      NULL,
    ],
    [
      NULL,
      'integer',
      NULL,
    ],
    [
      NULL,
      'decimal',
      NULL,
    ],
    [
      NULL,
      'string',
      NULL,
    ],
    [
      '',
      'string',
      NULL,
    ],
    [
      new TextValue(''),
      'text',
      NULL,
    ],
    [
      (new TextValue(''))
        ->setTokens([
        new TextToken(''),
      ]),
      'text',
      NULL,
    ],
  ];
}