2016-11-28 00:15:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Wallabag\CoreBundle\Tools;
|
|
|
|
|
2017-12-16 22:17:42 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-11-28 00:15:06 +01:00
|
|
|
use Symfony\Component\Finder\Finder;
|
|
|
|
use Wallabag\CoreBundle\Tools\Utils;
|
|
|
|
|
2017-12-16 22:17:42 +01:00
|
|
|
class UtilsTest extends TestCase
|
2016-11-28 00:15:06 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider examples
|
|
|
|
*/
|
|
|
|
public function testCorrectWordsCountForDifferentLanguages($text, $expectedCount)
|
|
|
|
{
|
2018-03-31 12:55:27 +02:00
|
|
|
static::assertSame((float) $expectedCount, Utils::getReadingTime($text));
|
2016-11-28 00:15:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function examples()
|
|
|
|
{
|
|
|
|
$examples = [];
|
2017-07-01 09:52:38 +02:00
|
|
|
$finder = (new Finder())->in(__DIR__ . '/samples');
|
2016-11-28 00:15:06 +01:00
|
|
|
foreach ($finder->getIterator() as $file) {
|
|
|
|
$examples[] = [$file->getContents(), 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $examples;
|
|
|
|
}
|
|
|
|
}
|