-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translation: Fix that null as count is still passed to the translator
- Loading branch information
Showing
2 changed files
with
61 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace ipl\Tests\I18n; | ||
|
||
use ipl\I18n\NoopTranslator; | ||
use ipl\I18n\StaticTranslator; | ||
use ipl\I18n\Translation; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class TranslationTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
StaticTranslator::$instance = new NoopTranslator(); | ||
} | ||
|
||
public function testNullCountsAreProperlyHandledByTranslatePlural() | ||
{ | ||
$this->assertSame( | ||
'not one', | ||
$this->createTestClassWithoutDomain() | ||
->translatePlural('one', 'not one', null) | ||
); | ||
$this->assertSame( | ||
'not one', | ||
$this->createTestClassWithDomain() | ||
->translatePlural('one', 'not one', null) | ||
); | ||
} | ||
|
||
public function testNullCountsAreProperlyHandledByTranslatePluralInDomain() | ||
{ | ||
$this->assertSame( | ||
'not one', | ||
$this->createTestClassWithoutDomain() | ||
->translatePluralInDomain('test', 'one', 'not one', null) | ||
); | ||
} | ||
|
||
private function createTestClassWithoutDomain() | ||
{ | ||
return new class { | ||
use Translation; | ||
}; | ||
} | ||
|
||
private function createTestClassWithDomain() | ||
{ | ||
return new class { | ||
use Translation; | ||
|
||
public function __construct() | ||
{ | ||
$this->translationDomain = 'test'; | ||
} | ||
}; | ||
} | ||
} |