$totalReviews =
$matrix->
getTotalReviewCount();
static::
assertCount(5,
$matrix->
getMatrix());
/** @var MatrixElement[] $matrixElements */
$matrixElements =
$matrix->
getMatrix();
for ($i = 1;
$i <=
$matrix->
getMaxPoints(); ++
$i) { $matrixElement =
$matrixElements[$i];
$expected =
round($ratingCounts[$i] * 100 /
$totalReviews, 4
);
static::
assertEquals($i,
$matrixElement->
getPoints(),
sprintf('The rating with %d points has errors!',
$i));
static::
assertEquals($ratingCounts[$i],
$matrixElement->
getCount(),
sprintf('The count of reviews with %d points has errors!',
$i));
static::
assertEquals($expected,
round($matrixElement->
getPercent(), 4
),
sprintf('Calculation of percentage with %d points has errors!',
$i));
} } /**
* function tests that every MatrixElement struct is generated correctly by matrix constructor using float values
*
* @group reviews
*/
public function testMatrixElementsWithFloatValues(): void
{