You are here

public function UtilityTest::testGetBoostFactors in Search API 8

Tests obtaining a list of available boost factors.

@covers ::getBoostFactors

File

tests/src/Unit/UtilityTest.php, line 65

Class

UtilityTest
Tests the Search API utility class.

Namespace

Drupal\Tests\search_api\Unit

Code

public function testGetBoostFactors() {
  $expected = [
    '0.00' => '0.00',
    '0.10' => '0.10',
    '0.20' => '0.20',
    '0.30' => '0.30',
    '0.50' => '0.50',
    '0.60' => '0.60',
    '0.70' => '0.70',
    '0.80' => '0.80',
    '0.90' => '0.90',
    '1.00' => '1.00',
    '1.10' => '1.10',
    '1.20' => '1.20',
    '1.30' => '1.30',
    '1.40' => '1.40',
    '1.50' => '1.50',
    '2.00' => '2.00',
    '3.00' => '3.00',
    '5.00' => '5.00',
    '8.00' => '8.00',
    '13.00' => '13.00',
    '21.00' => '21.00',
  ];
  $this
    ->assertEquals($expected, Utility::getBoostFactors());
  $additional_factors = [
    4,
    '0.81',
    3,
    0.8100000000000001,
    '3',
    '8.2',
    '0.81',
    14.123,
    0.8110000000000001,
  ];
  $expected = [
    '0.00' => '0.00',
    '0.10' => '0.10',
    '0.20' => '0.20',
    '0.30' => '0.30',
    '0.50' => '0.50',
    '0.60' => '0.60',
    '0.70' => '0.70',
    '0.80' => '0.80',
    '0.81' => '0.81',
    '0.90' => '0.90',
    '1.00' => '1.00',
    '1.10' => '1.10',
    '1.20' => '1.20',
    '1.30' => '1.30',
    '1.40' => '1.40',
    '1.50' => '1.50',
    '2.00' => '2.00',
    '3.00' => '3.00',
    '4.00' => '4.00',
    '5.00' => '5.00',
    '8.00' => '8.00',
    '8.20' => '8.20',
    '13.00' => '13.00',
    '14.12' => '14.12',
    '21.00' => '21.00',
  ];
  $this
    ->assertEquals($expected, Utility::getBoostFactors($additional_factors));
}