public function testIssuesNoticeOnMissingKey() { // key is missing from all checked translations _elgg_services()->logger->disable(); $this->assertEquals("{$this->key}b", $this->translator->translate("{$this->key}b")); $logged = _elgg_services()->logger->enable(); $this->assertEquals([['message' => "Missing English translation for \"{$this->key}b\" language key", 'level' => Logger::NOTICE]], $logged); // has fallback key $this->translator->addTranslation('en', ["{$this->key}b" => 'Dummy']); _elgg_services()->logger->disable(); $this->assertEquals('Dummy', $this->translator->translate("{$this->key}b", [], 'es')); $logged = _elgg_services()->logger->enable(); $this->assertEquals([['message' => "Missing es translation for \"{$this->key}b\" language key", 'level' => Logger::NOTICE]], $logged); }
public function testCheckLanguageKeyExists() { $translator = new Translator(); $translator->addTranslation('en', array('__elgg_php_unit:test_key' => 'Dummy')); $this->assertTrue($translator->languageKeyExists('__elgg_php_unit:test_key')); $this->assertFalse($translator->languageKeyExists('__elgg_php_unit:test_key:missing')); }
public function setUp() { $this->actionsDir = dirname(dirname(__FILE__)) . "/test_files/actions"; $session = ElggSession::getMock(); _elgg_services()->setValue('session', $session); _elgg_services()->session->start(); $config = $this->config(); _elgg_services()->setValue('config', $config); $this->input = new Input(); _elgg_services()->setValue('input', $this->input); $this->actions = new ActionsService($config, $session, _elgg_services()->crypto); _elgg_services()->setValue('actions', $this->actions); $this->request = $this->prepareHttpRequest(); _elgg_services()->setValue('request', $this->request); $this->translator = new Translator(); $this->translator->addTranslation('en', ['__test__' => 'Test']); $this->hooks = new PluginHooksService(); $this->system_messages = new SystemMessagesService(elgg_get_session()); _elgg_services()->logger->disable(); }
function setUp() { $this->pages = dirname(dirname(__FILE__)) . '/test_files/pages'; $this->fooHandlerCalls = 0; $session = ElggSession::getMock(); _elgg_services()->setValue('session', $session); _elgg_services()->session->start(); $config = $this->config(); _elgg_services()->setValue('config', $config); $this->input = new Input(); _elgg_services()->setValue('input', $this->input); $this->request = $this->prepareHttpRequest('', 'GET'); _elgg_services()->setValue('request', $this->request); $this->translator = new Translator(); $this->translator->addTranslation('en', ['__test__' => 'Test']); $this->hooks = new PluginHooksService(); $this->router = new Router($this->hooks); $this->system_messages = new SystemMessagesService(elgg_get_session()); $this->viewsDir = dirname(dirname(__FILE__)) . "/test_files/views"; $this->createService(); _elgg_services()->logger->disable(); }