aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Tools/UtilsTest.php
blob: 435c25cacfcf460d81966141b2995475d37e3e14 (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
<?php

namespace Tests\Wallabag\CoreBundle\Tools;

use Symfony\Component\Finder\Finder;
use Wallabag\CoreBundle\Tools\Utils;

class UtilsTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider examples
     */
    public function testCorrectWordsCountForDifferentLanguages($text, $expectedCount)
    {
        static::assertEquals((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;
    }
}