PHP Classes

File: tests/FuzzySearch/IncludeIdAndScoreTest.php

Recommend this page to a friend!
  Classes of AccountKiller   Fuse   tests/FuzzySearch/IncludeIdAndScoreTest.php   Download  
File: tests/FuzzySearch/IncludeIdAndScoreTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Fuse
Fuzzy search of arrays using the Bitap algorithm
Author: By
Last change:
Date: 27 days ago
Size: 801 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
Fuse\Fuse;

it('returns a result with the correct ISBN and score when searching for "Stve"', function () {
   
$fuse = new Fuse(
        [
            [
               
'ISBN' => '0765348276',
               
'title' => 'Old Man\'s War',
               
'author' => 'John Scalzi',
            ],
            [
               
'ISBN' => '0312696957',
               
'title' => 'The Lock Artist',
               
'author' => 'Steve Hamilton',
            ],
        ],
        [
           
'keys' => ['title', 'author'],
           
'includeScore' => true,
        ],
    );

   
$result = $fuse->search('Stve');

   
expect($result)->toHaveCount(1);
   
expect($result[0]['item']['ISBN'])->toBe('0312696957');
   
expect($result[0]['score'])->not()->toBe(0);
});