mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Fix incorrect reading time calculation for entries in languages with
non-latin chars subset.
This commit is contained in:
parent
625bb56181
commit
5b6888b13f
5 changed files with 54 additions and 1 deletions
28
tests/Wallabag/CoreBundle/Tools/UtilsTest.php
Normal file
28
tests/Wallabag/CoreBundle/Tools/UtilsTest.php
Normal file
|
@ -0,0 +1,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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue