diff options
author | lizyn <zhiylin@outlook.com> | 2020-02-24 10:04:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-24 10:04:13 +0800 |
commit | b19df31d78d881a43bcf6b3215e5fc3781e8e8aa (patch) | |
tree | d0d9861694a4b5e5fbfdbeb53c255ecd15fe9328 /tests/Wallabag/CoreBundle/Tools/UtilsTest.php | |
parent | 4d0c632c70ea50d459c3c55ddda2e0f394dd51cb (diff) | |
parent | 04d918cae0227c06a41d27fb6533dddbf30dfe71 (diff) | |
download | wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.gz wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.zst wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.zip |
Merge pull request #1 from wallabag/master
Keep up with the master again
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; |