diff options
Diffstat (limited to 'tests/Wallabag/CoreBundle/Tools/UtilsTest.php')
-rw-r--r-- | tests/Wallabag/CoreBundle/Tools/UtilsTest.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php index 952d076d..c6ed74f0 100644 --- a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php +++ b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php | |||
@@ -11,9 +11,9 @@ class UtilsTest extends TestCase | |||
11 | /** | 11 | /** |
12 | * @dataProvider examples | 12 | * @dataProvider examples |
13 | */ | 13 | */ |
14 | public function testCorrectWordsCountForDifferentLanguages($text, $expectedCount) | 14 | public function testCorrectWordsCountForDifferentLanguages($filename, $text, $expectedCount) |
15 | { | 15 | { |
16 | static::assertSame((float) $expectedCount, Utils::getReadingTime($text)); | 16 | static::assertSame((float) $expectedCount, Utils::getReadingTime($text), 'Reading time for: ' . $filename); |
17 | } | 17 | } |
18 | 18 | ||
19 | public function examples() | 19 | public function examples() |
@@ -21,7 +21,17 @@ class UtilsTest extends TestCase | |||
21 | $examples = []; | 21 | $examples = []; |
22 | $finder = (new Finder())->in(__DIR__ . '/samples'); | 22 | $finder = (new Finder())->in(__DIR__ . '/samples'); |
23 | foreach ($finder->getIterator() as $file) { | 23 | foreach ($finder->getIterator() as $file) { |
24 | $examples[] = [$file->getContents(), 1]; | 24 | preg_match('/-----CONTENT-----\s*(.*?)\s*-----READING_TIME-----\s*(.*)/sx', $file->getContents(), $match); |
25 | |||
26 | if (3 !== \count($match)) { | ||
27 | throw new \Exception('Sample file "' . $file->getRelativePathname() . '" as wrong definition, see README.'); | ||
28 | } | ||
29 | |||
30 | $examples[] = [ | ||
31 | $file->getRelativePathname(), | ||
32 | $match[1], // content | ||
33 | $match[2], // reading time | ||
34 | ]; | ||
25 | } | 35 | } |
26 | 36 | ||
27 | return $examples; | 37 | return $examples; |