diff --git a/tests/lib/Repository/Values/Translation/MessageTest.php b/tests/lib/Repository/Values/Translation/MessageTest.php new file mode 100644 index 0000000000..278847cb4b --- /dev/null +++ b/tests/lib/Repository/Values/Translation/MessageTest.php @@ -0,0 +1,61 @@ + + */ + public static function getDataForTestStringable(): iterable + { + yield 'message with substitution values' => [ + new Message( + 'Anna has some oranges in %object%', + [ + '%object%' => 'a basket', + ] + ), + 'Anna has some oranges in a basket', + ]; + + yield 'message with multiple substitution values' => [ + new Message( + '%first_name% has some data in %storage_type%', + [ + '%first_name%' => 'Anna', + '%storage_type%' => 'her database', + ] + ), + 'Anna has some data in her database', + ]; + + yield 'message with no substitution values' => [ + new Message( + 'This value is not correct', + [] + ), + 'This value is not correct', + ]; + } +} diff --git a/tests/lib/Repository/Values/Translation/PluralTest.php b/tests/lib/Repository/Values/Translation/PluralTest.php new file mode 100644 index 0000000000..d0d6e57f96 --- /dev/null +++ b/tests/lib/Repository/Values/Translation/PluralTest.php @@ -0,0 +1,63 @@ + + */ + public static function getDataForTestStringable(): iterable + { + yield 'singular form' => [ + new Plural( + 'John has %apple_count% apple', + 'John has %apple_count% apples', + [ + '%apple_count%' => 1, + ] + ), + 'John has 1 apple', + ]; + + yield 'plural form' => [ + new Plural( + 'John has %apple_count% apple', + 'John has %apple_count% apples', + [ + '%apple_count%' => 2, + ] + ), + 'John has 2 apples', + ]; + + yield 'no substitution values' => [ + new Plural( + 'John has some apples', + 'John has a lot of apples', + [] + ), + 'John has a lot of apples', + ]; + } +}