getTranslation( 'This is a translatable string' ); self::assertEquals( 'Dit is een vertaalbare zin', $string ); } public function testGetNonExistingString() { $obj = new ezcTranslation( ezcTranslationTest::setUpTestArray() ); try { $string = $obj->getTranslation( 'Unknown string' ); self::fail( 'Expected exception "Key not available" was not thrown' ); } catch ( ezcTranslationKeyNotAvailableException $e ) { self::assertEquals( "The key 'Unknown string' does not exist in the translation map.", $e->getMessage() ); } } public function testGetStringWithParameters() { $obj = new ezcTranslation( ezcTranslationTest::setUpTestArray() ); $string = $obj->getTranslation( '%Apples are not %pears', array( 'apples' => 'appelen', 'pears' => 'peren' ) ); self::assertEquals( 'Peren zijn niet hetzelfde als appelen', $string ); } public function testGetStringWithMissingParameters() { $obj = new ezcTranslation( ezcTranslationTest::setUpTestArray() ); try { $string = $obj->getTranslation( '%Apples are not %pears', array( 'apples' => 'appelen' ) ); self::fail( 'Expected exception "Parameter missing" was not thrown' ); } catch ( ezcTranslationParameterMissingException $e ) { self::assertEquals( "The parameter '%Pears' does not exist.", $e->getMessage() ); } } public function testGetStringWithNumericalParameters() { $obj = new ezcTranslation( ezcTranslationTest::setUpTestArray() ); $string = $obj->getTranslation( 'A %1 is not a %2', array( 1 => 'koe', 2 => 'paard' ) ); self::assertEquals( 'Een koe is geen paard', $string ); } public function testGetStringWithMissingNumericalParameters() { $obj = new ezcTranslation( ezcTranslationTest::setUpTestArray() ); try { $string = $obj->getTranslation( 'A %1 is not a %2', array( 1 => 'koe' ) ); self::fail( 'Expected exception "Parameter missing" was not thrown' ); } catch ( ezcTranslationParameterMissingException $e ) { self::assertEquals( "The parameter '%2' does not exist.", $e->getMessage() ); } } public static function suite() { return new PHPUnit_Framework_TestSuite( "ezcTranslationTest" ); } } ?>