-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
154 additions
and
54 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
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,61 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Core\Repository\Values\Translation; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Translation\Message; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \Ibexa\Contracts\Core\Repository\Values\Translation\Message | ||
*/ | ||
final class MessageTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getDataForTestStringable | ||
*/ | ||
public function testStringable(Message $message, string $expectedString): void | ||
{ | ||
self::assertSame($expectedString, (string)$message); | ||
} | ||
|
||
/** | ||
* @return array<string, array{\Ibexa\Contracts\Core\Repository\Values\Translation\Message, string}> | ||
*/ | ||
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', | ||
]; | ||
} | ||
} |
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,63 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Core\Repository\Values\Translation; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Translation\Plural; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \Ibexa\Contracts\Core\Repository\Values\Translation\Plural | ||
*/ | ||
final class PluralTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getDataForTestStringable | ||
*/ | ||
public function testStringable(Plural $message, string $expectedString): void | ||
{ | ||
self::assertSame($expectedString, (string)$message); | ||
} | ||
|
||
/** | ||
* @return array<string, array{\Ibexa\Contracts\Core\Repository\Values\Translation\Plural, string}> | ||
*/ | ||
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', | ||
]; | ||
} | ||
} |