@ -82,4 +82,41 @@ final class MDPuqiTest extends TestCase {
|
||||
self::assertEquals($positive, $score > 0, "Expected score to be positive or negative, got the oppite result. Score is: " . $score);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for tag.
|
||||
* 0: Input number of tags.
|
||||
* 1: Expected score.
|
||||
*
|
||||
* @return Generator<array{0: int, 1: int}>
|
||||
*/
|
||||
public static function tagNoAndScoreProvider():Generator {
|
||||
|
||||
yield 'No tags' => [0, 0 + MDPuqi::QI_PENALTY_NO_TAG];
|
||||
yield 'One tag' => [1, 0 + MDPuqi::QI_PENALTY_ONLY_ONE_TAG];
|
||||
yield 'Two tag' => [2, 0 + MDPuqi::QI_PENALTY_ONLY_TWO_TAG];
|
||||
yield 'Regular number of tags' => [5, 0 + 5 * MDPuqi::QI_REWARD_TAGS_MULTIPLIER];
|
||||
yield 'Number of tags above threshold' => [MDPuqi::THRESHOLD_TAGS_TOO_MANY + 1, 0 + MDPuqi::THRESHOLD_TAGS_TOO_MANY * MDPuqi::QI_REWARD_TAGS_MULTIPLIER + 1 * MDPuqi::QI_REWARD_TAGS_MULTIPLIER_ABOVE_THRESHOLD];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for tag evaluation.
|
||||
*
|
||||
* @param integer $noOfTags Input number of tags.
|
||||
* @param integer $expectedScore Expected score.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[DataProvider('tagNoAndScoreProvider')]
|
||||
public function testTagEvaluation(int $noOfTags, int $expectedScore):void {
|
||||
|
||||
$puqi = new MDPuqi(new MDTlLoader("abc", "en"));
|
||||
$puqi->checkEvents([], [], [], [], $noOfTags);
|
||||
$msgs = $puqi->getMessages();
|
||||
|
||||
$score = $puqi->getScore();
|
||||
self::assertEquals(MDPuqi::QI_PENALTY_NO_EVENTS + $expectedScore, $score, "Tag eval: Score differs from expected. Messages: " . var_export($puqi->getMessages(), true));
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user