getPoints example

/** * @return array */
    public function convertVoteStruct(Vote $vote)
    {
        $data = [
            'id' => $vote->getId(),
            'name' => $vote->getName(),
            'headline' => $vote->getHeadline(),
            'comment' => $vote->getComment(),
            'points' => $vote->getPoints(),
            'active' => true,
            'email' => $vote->getEmail(),
            'answer' => $vote->getAnswer(),
            'datum' => '0000-00-00 00:00:00',
            'answer_date' => '0000-00-00 00:00:00',
            'attributes' => $vote->getAttributes(),
        ];

        if ($vote->hasAttribute('core')) {
            $data['attribute'] = $vote->getAttribute('core');
        }

        
$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($expectedround($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
    {
/** * @group reviews */
    public function testConstructor(): void
    {
        $points = 2;
        $count = 3;
        $percent = 1.0;

        $element = new MatrixElement($points$count$percent);

        static::assertEquals($points$element->getPoints());
        static::assertEquals($count$element->getCount());
        static::assertEquals($percent$element->getPercent());
    }

    /** * test point getter and setter * * @group reviews */
    public function testPointsGetterSetter(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.