score([ 'title' => 'Some Other Title', 'author' => 'Unknown', 'isbn' => '9780321125217', 'publishdate' => '2020-01-01', 'publisher' => '', 'cover' => 0, ], $parsed); $this->assertSame(1.0, $score); } public function test_higher_score_for_better_title_author_match(): void { $parsed = new BookParseResult( rawName: 'Refactoring', title: 'Refactoring', author: 'Martin Fowler', year: 1999 ); $scorer = new BookMatchScorer; $good = $scorer->score([ 'title' => 'Refactoring: Improving the Design of Existing Code', 'author' => 'Martin Fowler', 'publishdate' => '1999-07-08', 'publisher' => 'Addison-Wesley', 'cover' => 1, ], $parsed); $bad = $scorer->score([ 'title' => 'Cooking for Beginners', 'author' => 'Random Author', 'publishdate' => '2018-01-01', 'publisher' => '', 'cover' => 0, ], $parsed); $this->assertGreaterThan($bad, $good); } }