mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-26 18:21:02 +00:00
Move test files directly under tests/ directory
This commit is contained in:
parent
a37b385c23
commit
24da70e338
117 changed files with 4 additions and 4 deletions
39
tests/Tools/UtilsTest.php
Normal file
39
tests/Tools/UtilsTest.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Wallabag\CoreBundle\Tools;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Wallabag\CoreBundle\Tools\Utils;
|
||||
|
||||
class UtilsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider examples
|
||||
*/
|
||||
public function testCorrectWordsCountForDifferentLanguages($filename, $text, $expectedCount)
|
||||
{
|
||||
static::assertSame((float) $expectedCount, Utils::getReadingTime($text), 'Reading time for: ' . $filename);
|
||||
}
|
||||
|
||||
public function examples()
|
||||
{
|
||||
$examples = [];
|
||||
$finder = (new Finder())->in(__DIR__ . '/samples');
|
||||
foreach ($finder->getIterator() as $file) {
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue