aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Tools/UtilsTest.php
blob: 952d076d1b7c0f7a208fd561fb75a6d4da44ae11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

namespace Tests\Wallabag\CoreBundle\Tools;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Finder\Finder;
use Wallabag\CoreBundle\Tools\Utils;

class UtilsTest extends TestCase
{
    /**
     * @dataProvider examples
     */
    public function testCorrectWordsCountForDifferentLanguages($text, $expectedCount)
    {
        static::assertSame((float) $expectedCount, Utils::getReadingTime($text));
    }

    public function examples()
    {
        $examples = [];
        $finder = (new Finder())->in(__DIR__ . '/samples');
        foreach ($finder->getIterator() as $file) {
            $examples[] = [$file->getContents(), 1];
        }

        return $examples;
    }
}