setOptions( array ( 'format' => '[LOCALE].xml' ) ); $trm = new ezcTranslationManager( $backend ); $context = $trm->getContext( 'nl-nl', 'contentstructuremenu/show_content_structure' ); $expected = new ezcTranslation( array( new ezcTranslationData( 'Node ID: %node_id Visibility: %visibility', 'Knoop ID: %node_id Zichtbaar: %visibility', false, ezcTranslationData::TRANSLATED ) ) ); self::assertEquals( $expected, $context ); } /** * Tests if a cached context works. * This one tests a cached context, the code is the same as the previous * test, but works because that one is run first and thus the context is * already cached. */ public function testGetContextCached() { $currentDir = dirname( __FILE__ ); $backend = new ezcTranslationTsBackend( "{$currentDir}/files/translations" ); $backend->setOptions( array ( 'format' => '[LOCALE].xml' ) ); $trm = new ezcTranslationManager( $backend ); $context = $trm->getContext( 'nl-nl', 'contentstructuremenu/show_content_structure' ); $expected = new ezcTranslation( array( new ezcTranslationData( 'Node ID: %node_id Visibility: %visibility', 'Knoop ID: %node_id Zichtbaar: %visibility', false, ezcTranslationData::TRANSLATED ) ) ); self::assertEquals( $expected, $context ); } public function testGetContextWithFilter() { $currentDir = dirname( __FILE__ ); $backend = new ezcTranslationTsBackend( "{$currentDir}/files/translations" ); $backend->setOptions( array ( 'format' => '[LOCALE].xml' ) ); $fillin = ezcTranslationFillinFilter::getInstance(); $trm = new ezcTranslationManager( $backend ); $trm->addFilter( $fillin ); $context = $trm->getContext( 'nl-nl', 'design/admin/collaboration/group/view/list' ); $expected = array(); $expected[] = new ezcTranslationData( "Group list for '%1'", "Groeplijst voor %1", false, ezcTranslationData::TRANSLATED ); $expected[] = new ezcTranslationData( 'No items in group.', 'No items in group.', false, ezcTranslationData::UNFINISHED ); $expected[] = new ezcTranslationData( "Group tree for '%1'", "Group tree for '%1'", false, ezcTranslationData::UNFINISHED ); $expected = new ezcTranslation( $expected ); self::assertEquals( $expected, $context ); } public function testGetContextWithObsolete() { $currentDir = dirname( __FILE__ ); $backend = new ezcTranslationTsBackend( "{$currentDir}/files/translations" ); $backend->setOptions( array ( 'format' => '[LOCALE].xml' ) ); $fillin = ezcTranslationFillinFilter::getInstance(); $trm = new ezcTranslationManager( $backend ); $trm->addFilter( $fillin ); $context = $trm->getContext( 'nl-nl', 'design/admin/collaboration/view/summary' ); $expected = array(); $expected[] = new ezcTranslationData( 'Item list', 'Lijst met items', false, ezcTranslationData::TRANSLATED ); $expected = new ezcTranslation( $expected ); self::assertEquals( $expected, $context ); } public function testGetContextMissing() { $currentDir = dirname( __FILE__ ); $backend = new ezcTranslationTsBackend( "{$currentDir}/files/translations" ); $backend->setOptions( array ( 'format' => '[LOCALE].xml' ) ); $fillin = ezcTranslationFillinFilter::getInstance(); $trm = new ezcTranslationManager( $backend ); $trm->addFilter( $fillin ); try { $context = $trm->getContext( 'nl-nl', 'design/admin/collaboration/admin/view/summary' ); self::fail( 'Expected Exception was not thrown' ); } catch ( ezcTranslationException $e ) { self::assertEquals( ezcTranslationException::CONTEXT_NOT_AVAILABLE, $e->getCode() ); } } public static function suite() { return new ezcTestSuite( "ezcTranslationManagerTest" ); } } ?>