本文整理汇总了PHP中CMTest_TH::createLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::createLanguage方法的具体用法?PHP CMTest_TH::createLanguage怎么用?PHP CMTest_TH::createLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMTest_TH
的用法示例。
在下文中一共展示了CMTest_TH::createLanguage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProcessTranslationsEnableKey
public function testProcessTranslationsEnableKey()
{
$language = CMTest_TH::createLanguage('test');
$languageKey = CM_Model_LanguageKey::create('Hello World');
$this->assertSame(false, $languageKey->getJavascript());
$site = CM_Site_Abstract::factory();
$render = new CM_Frontend_Render(new CM_Frontend_Environment(null, null, $language));
// Check that key is *not* included in the JS translations list
$versionJavascript = CM_Model_Language::getVersionJavascript();
$request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
$response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$this->assertNotContains('Hello World', $response->getContent());
// Request JS-enabling of language key via RPC call
$body = CM_Params::jsonEncode(['method' => 'CM_Model_Language.requestTranslationJs', 'params' => ['Hello World']]);
$request = new CM_Http_Request_Post('/rpc', null, null, $body);
$response = CM_Http_Response_RPC::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
CMTest_TH::reinstantiateModel($languageKey);
$this->assertSame(true, $languageKey->getJavascript());
// Check that key *is* included in the JS translations list
$versionJavascript = CM_Model_Language::getVersionJavascript();
$request = new CM_Http_Request_Get($render->getUrlResource('library-js', "translations/{$versionJavascript}.js"));
$response = CM_Http_Response_Resource_Javascript_Library::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$this->assertContains('Hello World', $response->getContent());
}
示例2: setUp
protected function setUp()
{
CMTest_TH::createLanguage();
$this->_configInternalFile = new CM_File(DIR_ROOT . 'resources/config/js/internal.js');
$this->_configInternalFile->ensureParentDirectory();
$this->_configInternalFile->write('console.log("hello world")');
}
示例3: testCreate
public function testCreate()
{
$language = CMTest_TH::createLanguage('foo');
$this->assertCount(0, $language->getTranslations());
$languageKey = CM_Model_LanguageKey::create('foo', ['bar']);
$this->assertTrue(CM_Model_LanguageKey::exists('foo'));
$this->assertCount(1, $language->getTranslations());
$this->assertSame(['bar'], $languageKey->getVariables());
}
示例4: testProcessLanguageRedirect
public function testProcessLanguageRedirect()
{
CMTest_TH::createLanguage('en');
$response = CMTest_TH::createResponsePageEmbed('/en/mock7');
$response->process();
$this->assertNull($response->getRedirectUrl());
$response = CMTest_TH::createResponsePageEmbed('/en/mock7', null, CMTest_TH::createUser());
$response->process();
$this->assertSame($response->getSite()->getUrl() . '/mock7', $response->getRedirectUrl());
}
示例5: testGetLanguageByBrowser
public function testGetLanguageByBrowser()
{
$defaultLanguage = CMTest_TH::createLanguage('en');
$browserLanguage = CMTest_TH::createLanguage('de');
$this->assertEquals(CM_Model_Language::findDefault(), $defaultLanguage);
$request = $this->_prepareRequest('/', array('Accept-Language' => 'de'));
$this->assertEquals($request->getLanguage(), $browserLanguage);
$request = $this->_prepareRequest('/', array('Accept-Language' => 'pl'));
$this->assertEquals($request->getLanguage(), $defaultLanguage);
}
示例6: setUp
public function setUp()
{
$smarty = new Smarty();
$this->_render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $this->_render);
$language = CMTest_TH::createLanguage();
$language->setTranslation('.date.period.years', '{$count} years', ['count']);
$language->setTranslation('.date.period.hour', '1 hour');
$language->setTranslation('.date.period.day', '1 day');
}
示例7: testLoadPageRedirectLanguage
public function testLoadPageRedirectLanguage()
{
$site = CM_Site_Abstract::factory();
CMTest_TH::createLanguage('en');
$viewer = CMTest_TH::createUser();
$environment = new CM_Frontend_Environment(null, $viewer);
$component = new CM_Page_View_Ajax_Test_Mock();
$response = $this->getResponseAjax($component, 'loadPage', ['path' => '/en' . CM_Page_View_Ajax_Test_Mock::getPath()], $environment);
$this->assertViewResponseSuccess($response);
$responseDecoded = CM_Params::jsonDecode($response->getContent());
$this->assertSame($site->getUrl() . CM_Page_View_Ajax_Test_Mock::getPath(), $responseDecoded['success']['data']['url']);
}
示例8: testLanguageAlternatives
public function testLanguageAlternatives()
{
$site = $this->getMockSite('CM_Site_Abstract', null, array('url' => 'http://www.example.com'));
$language1 = CMTest_TH::createLanguage('en');
$language2 = CMTest_TH::createLanguage('de');
$environment = new CM_Frontend_Environment($site, null, $language2, null, true);
$render = new CM_Frontend_Render($environment, true);
$this->getMockForAbstractClass('CM_Layout_Abstract', array(), 'CM_Layout_Default');
$page = new CM_Page_Example();
$renderAdapter = new CM_RenderAdapter_Document($render, $page);
$html = $renderAdapter->fetch();
$this->assertContains('<link rel="alternate" href="http://www.example.com/example" hreflang="x-default">', $html);
$this->assertContains('<link rel="alternate" href="http://www.example.com/en/example" hreflang="en">', $html);
$this->assertContains('<link rel="alternate" href="http://www.example.com/de/example" hreflang="de">', $html);
}
示例9: testGetUrlPageLanguageRewrite
public function testGetUrlPageLanguageRewrite()
{
$page = $this->getMockForAbstractClass('CM_Page_Abstract', array(), 'CM_Page_Test', false);
$baseUrl = 'http://www.default.dev';
$render = new CM_Frontend_Render();
$this->assertSame($baseUrl . '/test', $render->getUrlPage($page));
$render = new CM_Frontend_Render(null, true);
// This should never happen in application, but lets test it
$this->assertSame($baseUrl . '/test', $render->getUrlPage($page));
$language = CMTest_TH::createLanguage('en');
$environment = new CM_Frontend_Environment(null, null, $language);
$render = new CM_Frontend_Render($environment);
$this->assertSame($baseUrl . '/test', $render->getUrlPage($page));
$render = new CM_Frontend_Render($environment, true);
$this->assertSame($baseUrl . '/en/test', $render->getUrlPage($page));
}
示例10: testProcessLanguageNoRedirect
public function testProcessLanguageNoRedirect()
{
$language = CMTest_TH::createLanguage('en');
$user = CMTest_TH::createUser();
$response = CMTest_TH::createResponsePage('/en/mock5');
$response->process();
$this->assertEquals($language, $response->getRequest()->getLanguageUrl());
$response = CMTest_TH::createResponsePage('/mock5');
$response->process();
$this->assertNull($response->getRequest()->getLanguageUrl());
$response = CMTest_TH::createResponsePage('/mock5', null, $user);
$response->process();
$this->assertNull($response->getRequest()->getLanguageUrl());
foreach ($response->getHeaders() as $header) {
$this->assertNotContains('Location:', $header);
}
}
示例11: testProcessLanguageNoRedirect
public function testProcessLanguageNoRedirect()
{
$language = CMTest_TH::createLanguage('en');
$site = CM_Site_Abstract::factory();
$request = new CM_Http_Request_Get('/en/mock5', ['host' => $site->getHost()]);
$response = CM_Http_Response_Page::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$this->assertEquals($language, $response->getRequest()->getLanguageUrl());
$request = new CM_Http_Request_Get('/mock5', ['host' => $site->getHost()]);
$response = CM_Http_Response_Page::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$this->assertNull($response->getRequest()->getLanguageUrl());
$viewer = CMTest_TH::createUser();
$request = new CM_Http_Request_Get('/mock5', ['host' => $site->getHost()], null, $viewer);
$response = CM_Http_Response_Page::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$this->assertNull($response->getRequest()->getLanguageUrl());
foreach ($response->getHeaders() as $header) {
$this->assertNotContains('Location:', $header);
}
}
示例12: testSetLanguage
public function testSetLanguage()
{
$language = CMTest_TH::createLanguage();
$user = CMTest_TH::createUser();
$this->assertNotEquals($language, $user->getLanguage());
$user->setLanguage($language);
$this->assertEquals($language, $user->getLanguage());
}
示例13: testSetName
public function testSetName()
{
$language = CMTest_TH::createLanguage();
$key = CM_Model_LanguageKey::create('foo');
$key->setName('bar');
$this->assertSame('bar', $key->getName());
$this->assertTrue(Functional\some($language->getTranslations()->getItems(), function ($translation) {
return $translation['key'] === 'bar';
}));
}
示例14: testLoadPageRedirectLanguage
public function testLoadPageRedirectLanguage()
{
$site = $this->getMockSite(null, null, ['url' => 'http://my-site.com']);
CMTest_TH::createLanguage('en');
$viewer = CMTest_TH::createUser();
$page = new CM_Page_View_Ajax_Test_Mock();
$env = new CM_Frontend_Environment($site, $viewer);
$params = ['path' => '/en' . $page::getPath(), 'currentLayout' => $page->getLayout($env)];
$request = $this->createRequestAjax($page, 'loadPage', $params, null, null, $site);
$request->mockMethod('getViewer')->set($viewer);
/** @var CM_Http_Response_View_Abstract $response */
$response = $this->processRequest($request);
$this->assertViewResponseSuccess($response);
$responseDecoded = CM_Params::jsonDecode($response->getContent());
$this->assertSame($site->getUrl() . CM_Page_View_Ajax_Test_Mock::getPath(), $responseDecoded['success']['data']['url']);
}