aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Tools/UtilsTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2019-01-15 09:41:18 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-01-15 09:41:18 +0100
commit5419a8368ebb4b4d57f481b842f1fcc576c9149d (patch)
treecd970bb8f3ec5e6487fc1e3bd2de1f89455d3d90 /tests/Wallabag/CoreBundle/Tools/UtilsTest.php
parent5c331bf0f9ef679aaf91ef29b13120272fcccbf5 (diff)
parentf6b9e883c01196d5aec249f6e8e02e07d0da4089 (diff)
downloadwallabag-5419a8368ebb4b4d57f481b842f1fcc576c9149d.tar.gz
wallabag-5419a8368ebb4b4d57f481b842f1fcc576c9149d.tar.zst
wallabag-5419a8368ebb4b4d57f481b842f1fcc576c9149d.zip
Merge remote-tracking branch 'origin/master' into 2.4
Diffstat (limited to 'tests/Wallabag/CoreBundle/Tools/UtilsTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Tools/UtilsTest.php16
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;