Created
April 11, 2013 16:34
-
-
Save dwaligora/5364952 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace Acme\Bundle\TranslationBundle\Tests\PHPUnit\Form\Type; | |
use Acme\Bundle\TranslationBundle\Form\Type\LocaleType; | |
/** | |
* Description of LocaleTypeTest | |
* | |
* @author Daniel Waligóra <danielwaligora@gmail.com> | |
*/ | |
class LocaleTypeTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testSetLocale() | |
{ | |
$data = array('en', 'pl'); | |
$translator_stub = $this->getTranslatorMock(); | |
$locale_type = new LocaleType($translator_stub); | |
$locale_type->setLocale($data); | |
$this->assertAttributeEquals($data, 'locale', $locale_type); | |
} | |
public function testConvertLocaleToCountryName() | |
{ | |
$data = array('en', 'pl'); | |
$translator_stub = $this->getTranslatorMock(); | |
$locale_type = new LocaleType($translator_stub); | |
$reflection = new \ReflectionClass(get_class($locale_type)); | |
$method = $reflection->getMethod('convertLocaleToCountryName'); | |
$method->setAccessible(true); | |
$this->assertEquals(array('English', 'Polish'), $method->invokeArgs($locale_type, array($data))); | |
} | |
protected function getTranslatorMock() | |
{ | |
$stub = $this->getMockBuilder('Acme\Component\Translation\Translator') | |
->disableOriginalConstructor() | |
->getMock(); | |
$stub->expects($this->any()) | |
->method('getLocale') | |
->will($this->returnValue('en')); | |
return $stub; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment