-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump minimum version of PHPUnit to v10.5 and support v11 (#6)
- Loading branch information
Showing
5 changed files
with
87 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
cacheResultFile=".tmp/PHPUnit/.phpunit.result.cache" | ||
cacheDirectory=".tmp/PHPUnit" | ||
cacheResult="true" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage cacheDirectory=".tmp/PHPUnit"> | ||
<source> | ||
<include> | ||
<directory>src</directory> | ||
</include> | ||
</coverage> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Realodix\ReadTime\Test; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use Realodix\ReadTime\ReadTime; | ||
|
||
class ConfigurationTest extends TestCase | ||
{ | ||
/** | ||
* Words Per Minut must be able to be changed as needed, and must be in accordance | ||
* with the language. Param 1 must be for counting latin script, param 2 must be for | ||
* counting Chinese/Japanese/Korean script. | ||
*/ | ||
#[Test] | ||
public function readingSpeedMustAdjustToTheLanguage() | ||
{ | ||
$wpm = 1; | ||
$content = str_repeat('a ', $wpm); | ||
$actual = (new ReadTime($content, $wpm))->toArray(); | ||
$this->assertSame($wpm, $actual['word_time']); | ||
|
||
$content = str_repeat('陳る김', $wpm); | ||
$actual = (new ReadTime($content, $wpm, 12, 3))->toArray(); | ||
$this->assertSame(1, $actual['word_time_cjk']); | ||
} | ||
|
||
/** | ||
* Translation must be able to be changed as needed | ||
*/ | ||
#[Test] | ||
public function setTranslation() | ||
{ | ||
$customTranslation = 'foo'; | ||
$actual = (new ReadTime('word')) | ||
->setTranslation(['less_than' => $customTranslation]) | ||
->get(); | ||
|
||
$this->assertSame($customTranslation, $actual); | ||
} | ||
|
||
/** | ||
* Set translation with wrong key, and it should return default translation | ||
*/ | ||
#[Test] | ||
public function setTranslationWithWrongKey() | ||
{ | ||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); | ||
|
||
(new ReadTime('word')) | ||
->setTranslation(['foo' => 'bar']) | ||
->get(); | ||
} | ||
|
||
/** | ||
* Translation must be in accordance with data type | ||
*/ | ||
#[Test] | ||
public function setTranslationWithWrongDataType() | ||
{ | ||
$this->expectException(\Symfony\Component\OptionsResolver\Exception\InvalidOptionsException::class); | ||
|
||
(new ReadTime('word')) | ||
->setTranslation(['less_than' => true]) | ||
->get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters