X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=tests%2FWallabag%2FCoreBundle%2FTools%2FUtilsTest.php;h=c6ed74f07e35574e3432ab96ebd63f38ff107e23;hb=c73025ad8b684de1ac21ba7583f1af6f1d185159;hp=4521e485b1509c78cbc33994ff43d9c541acfb06;hpb=1953a872932a63792293b4aec087880265ba89f7;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php index 4521e485..c6ed74f0 100644 --- a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php +++ b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php @@ -2,17 +2,18 @@ namespace Tests\Wallabag\CoreBundle\Tools; +use PHPUnit\Framework\TestCase; use Symfony\Component\Finder\Finder; use Wallabag\CoreBundle\Tools\Utils; -class UtilsTest extends \PHPUnit_Framework_TestCase +class UtilsTest extends TestCase { /** * @dataProvider examples */ - public function testCorrectWordsCountForDifferentLanguages($text, $expectedCount) + public function testCorrectWordsCountForDifferentLanguages($filename, $text, $expectedCount) { - static::assertEquals((float) $expectedCount, Utils::getReadingTime($text)); + static::assertSame((float) $expectedCount, Utils::getReadingTime($text), 'Reading time for: ' . $filename); } public function examples() @@ -20,7 +21,17 @@ class UtilsTest extends \PHPUnit_Framework_TestCase $examples = []; $finder = (new Finder())->in(__DIR__ . '/samples'); foreach ($finder->getIterator() as $file) { - $examples[] = [$file->getContents(), 1]; + preg_match('/-----CONTENT-----\s*(.*?)\s*-----READING_TIME-----\s*(.*)/sx', $file->getContents(), $match); + + if (3 !== \count($match)) { + throw new \Exception('Sample file "' . $file->getRelativePathname() . '" as wrong definition, see README.'); + } + + $examples[] = [ + $file->getRelativePathname(), + $match[1], // content + $match[2], // reading time + ]; } return $examples;