本文整理汇总了PHP中CMTest_TH::createLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::createLocation方法的具体用法?PHP CMTest_TH::createLocation怎么用?PHP CMTest_TH::createLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMTest_TH
的用法示例。
在下文中一共展示了CMTest_TH::createLocation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetValueByEnvironment
public function testSetValueByEnvironment()
{
$location = CMTest_TH::createLocation();
$locationCity = $location->get(CM_Model_Location::LEVEL_CITY);
$environment = new CM_Frontend_Environment();
$environment->setLocation(null);
$field = new CM_FormField_Location();
$field->setValueByEnvironment($environment);
$this->assertNull($field->getValue());
$environment->setLocation($location->get(CM_Model_Location::LEVEL_COUNTRY));
$field = new CM_FormField_Location(['levelMin' => CM_Model_Location::LEVEL_CITY]);
$field->setValueByEnvironment($environment);
$this->assertNull($field->getValue());
$environment->setLocation($location);
$field = new CM_FormField_Location(['levelMin' => CM_Model_Location::LEVEL_CITY, 'levelMax' => CM_Model_Location::LEVEL_CITY]);
$field->setValueByEnvironment($environment);
$value = $field->getValue();
/** @var CM_Model_Location $locationValue */
$locationValue = $value[0];
$this->assertSame($locationCity->getId(), $locationValue->getId());
$this->assertSame($locationCity->getLevel(), $locationValue->getLevel());
$environment->setLocation($locationCity);
$field = new CM_FormField_Location(['levelMin' => CM_Model_Location::LEVEL_CITY, 'levelMax' => CM_Model_Location::LEVEL_CITY]);
$field->setValueByEnvironment($environment);
$value = $field->getValue();
/** @var CM_Model_Location $locationValue */
$locationValue = $value[0];
$this->assertSame($locationCity->getId(), $locationValue->getId());
$this->assertSame($locationCity->getLevel(), $locationValue->getLevel());
}
示例2: setUp
public function setUp()
{
$smarty = new Smarty();
$this->_render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $this->_render);
$this->_location = CMTest_TH::createLocation();
}
示例3: testProcessHostRedirect_parameter
public function testProcessHostRedirect_parameter()
{
$site = CM_Site_Abstract::factory();
$location = CMTest_TH::createLocation();
$locationEncoded = CM_Params::encode($location, true);
$query = http_build_query(['location' => $locationEncoded]);
$response = CMTest_TH::createResponsePage('/mock5?' . $query, array('host' => 'incorrect-host.org'));
$response->process();
$siteUrl = 'http://' . $site->getHost();
$this->assertContains('Location: ' . $siteUrl . '/mock5?' . $query, $response->getHeaders());
}
示例4: testProcessLanguageRedirect_parameter
public function testProcessLanguageRedirect_parameter()
{
CMTest_TH::createLanguage('en');
$viewer = CMTest_TH::createUser();
$location = CMTest_TH::createLocation();
$locationEncoded = CM_Params::encode($location, true);
$query = http_build_query(['location' => $locationEncoded]);
$site = CM_Site_Abstract::factory();
$request = new CM_Http_Request_Get('/en/mock5?' . $query, ['host' => $site->getHost()], null, $viewer);
$response = CM_Http_Response_Page::createFromRequest($request, $site, $this->getServiceManager());
$response->process();
$siteUrl = $response->getSite()->getUrl();
$this->assertContains('Location: ' . $siteUrl . '/mock5?' . $query, $response->getHeaders());
}
示例5: testGetLocation
public function testGetLocation()
{
$location = CMTest_TH::createLocation();
$params = new CM_Params(['location' => $location, 'locationParameters' => ['id' => $location->getId(), 'level' => $location->getLevel()], 'insufficientParameters' => 1]);
$this->assertEquals($location, $params->getLocation('location'));
$this->assertEquals($location, $params->getLocation('locationParameters'));
try {
$params->getLocation('insufficientParameters');
$this->fail('Instantiating location with insufficient parameters');
} catch (CM_Exception_InvalidParam $ex) {
$this->assertSame('Not enough parameters', $ex->getMessage());
$this->assertSame(['parameters' => 1, 'className' => 'CM_Model_Location'], $ex->getMetaInfo());
}
}
示例6: testArrayConvertible
public function testArrayConvertible()
{
$location = CMTest_TH::createLocation();
$this->assertEquals($location, CM_Model_Location::fromArray($location->toArray()));
}