本文整理匯總了PHP中Zend\Stdlib\Parameters::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP Parameters::set方法的具體用法?PHP Parameters::set怎麽用?PHP Parameters::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Stdlib\Parameters
的用法示例。
在下文中一共展示了Parameters::set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testWithProjectPathSet
/**
* Test with project path set
*/
public function testWithProjectPathSet()
{
$this->console->expects($this->never())->method('writeFailLine')->with($this->equalTo('task_check_working_path_mandatory'));
$this->parameters->set('workingPath', '/path/to/project/');
$task = new ProjectPathMandatory();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
}
示例2: initDefaults
/**
* @param Parameters $params
*
* @return Parameters
*/
protected function initDefaults(Parameters $params)
{
if (is_null($params->get('quality')) || !strlen(trim($params->get('quality')))) {
$params->set('quality', QualityInterface::QUALITY_THUMBNAIL);
}
if (is_null($params->get('source')) || !strlen(trim($params->get('source')))) {
$params->set('source', SourceNameInterface::SOURCE_USER);
}
return $params;
}
示例3: login
/**
* @param $request
* @return array|mixed|User
* @throws \Exception
*/
public function login($request)
{
$adapter = $this->getAuthPlugin()->getAuthAdapter();
$pin = $request->get('pin');
$accountId = $request->get('accountId');
if (!empty($pin)) {
$user = $this->getUserByPin($pin, $accountId);
$credentials = array('username' => $user->getUsername(), 'password' => $user->getPassword());
} else {
$credentials = array('username' => $request->get('username'), 'password' => $request->get('password'));
}
$params = new Parameters();
$params->set('identity', $credentials['username']);
$params->set('credential', $credentials['password']);
$emulatedRequest = new Request();
$emulatedRequest->setPost($params);
$result = $adapter->prepareForAuthentication($emulatedRequest);
if ($result instanceof Response) {
return $result;
}
$auth = $this->getAuthPlugin()->getAuthService()->authenticate($adapter);
if (!$auth->isValid()) {
$isRegistered = $this->isRegistered($credentials);
$accountUser = $this->getAccountUsersByParams($params);
if ($accountUser != null && !$isRegistered) {
if ($this->getAgencyIsDeleted($accountUser->getAccountId())) {
throw new \Exception(self::AGENCY_DELETED_MESSAGE);
}
return $this->createUserFromAccountUsers($accountUser);
}
$account = $this->getAccountByParams($params);
if ($account != null && !$isRegistered) {
return $this->createUserFromAccount($account);
}
if ($accountUser != null && $isRegistered) {
return $this->updateUser($accountUser);
}
$result = $auth->getMessages();
$message = "Bad request.";
if (isset($result[0])) {
$message = $result[0];
}
throw new \Exception($message);
}
$accountUser = $this->getAccountUsersByParams($params);
if ($this->getAgencyIsDeleted($accountUser->getAccountId())) {
throw new \Exception(self::AGENCY_DELETED_MESSAGE);
}
if ($this->getUserIsDeleted($credentials['username'])) {
throw new \Exception(self::USER_DELETED_MESSAGE);
}
$user = $this->getAuthPlugin()->getIdentity();
return $user;
}
示例4: testWithKnownHydrators
/**
* Test with controller existing
*/
public function testWithKnownHydrators()
{
$this->console->expects($this->never())->method('writeFailLine')->with($this->equalTo('task_check_base_hydrator_param_unknown'));
$this->console->expects($this->never())->method('colorize');
$knownHydrators = ['ArraySerializable', 'ClassMethods', 'ObjectProperty', 'Reflection'];
foreach ($knownHydrators as $hydrator) {
$this->parameters->set('paramBaseHydrator', $hydrator);
$task = new BaseHydratorParam();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
}
}
示例5: testRunActionWithParams
public function testRunActionWithParams()
{
$params = array('strict' => true, 'verbose' => true, 'debug' => true);
$runner = $this->getMockForAbstractClass('HumusPHPUnitModule\\RunnerInterface');
$runner->expects($this->once())->method('setParams')->with($params);
$runner->expects($this->once())->method('run');
$params = new Parameters();
$params->set('strict', true);
$params->set('verbose', true);
$params->set('debug', true);
$this->request->setParams($params);
$this->controller->setRunner($runner);
$response = new Response();
$this->controller->dispatch($this->request, $response);
}
示例6: testWithModulePathExisting
/**
* Test with module path existing
*/
public function testWithModulePathExisting()
{
$this->console->expects($this->never())->method('writeFailLine')->with($this->equalTo('task_check_working_path_not_exists'));
$this->console->expects($this->never())->method('colorize');
$this->parameters->set('projectModuleDir', $this->zf2rapidModuleDir);
$task = new ModulePathExists();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
}
示例7: testWithControllerPluginExisting
/**
* Test with controller plugin existing
*/
public function testWithControllerPluginExisting()
{
$this->console->expects($this->once())->method('writeTaskLine')->with($this->equalTo('task_check_checking_file'), ['controller plugin']);
$this->console->expects($this->never())->method('writeFailLine')->with($this->equalTo('task_check_file_exists_not_found'));
$this->console->expects($this->never())->method('colorize');
$this->parameters->set('controllerPluginDir', $this->zf2rapidControllerPluginDir);
$this->parameters->set('paramControllerPlugin', $this->zf2rapidControllerPluginName);
file_put_contents($this->zf2rapidControllerPluginDir . $this->zf2rapidControllerPluginFile, 'class TestPlugin {}');
$task = new ControllerPluginExists();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
}
示例8: testWithFormExisting
/**
* Test with form existing
*/
public function testWithFormExisting()
{
$this->console->expects($this->once())->method('writeTaskLine')->with($this->equalTo('task_check_checking_file'), ['form']);
$this->console->expects($this->never())->method('writeFailLine')->with($this->equalTo('task_check_file_exists_not_found'));
$this->console->expects($this->never())->method('colorize');
$this->parameters->set('formDir', $this->zf2rapidFormDir);
$this->parameters->set('paramForm', $this->zf2rapidFormName);
file_put_contents($this->zf2rapidFormDir . $this->zf2rapidFormFile, 'class TestForm {}');
$task = new FormExists();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
}
示例9: testWithValidatorExisting
/**
* Test with validator existing
*/
public function testWithValidatorExisting()
{
$this->console->expects($this->once())->method('writeTaskLine')->with($this->equalTo('task_check_checking_file'), array('validator'));
$this->console->expects($this->never())->method('writeFailLine')->with($this->equalTo('task_check_file_exists_not_found'));
$this->console->expects($this->never())->method('colorize');
$this->parameters->set('validatorDir', $this->zf2rapidValidatorDir);
$this->parameters->set('paramValidator', $this->zf2rapidValidatorName);
file_put_contents($this->zf2rapidValidatorDir . $this->zf2rapidValidatorFile, 'class TestValidator {}');
$task = new ValidatorExists();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
}
示例10: testWithExistingFile
/**
* Test with existing file
*/
public function testWithExistingFile()
{
$this->parameters->set('workingPath', $this->zf2rapidFileDir);
$expectedConfig = array('foo' => 'bar', 'one' => 'two');
file_put_contents($this->zf2rapidFileDir . $this->zf2rapidFileName, json_encode($expectedConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$task = new ConfigFile();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
$this->assertEquals($expectedConfig, $this->parameters->config);
$this->assertFileExists($this->zf2rapidFileDir . $this->zf2rapidFileName);
$this->assertEquals($expectedConfig, json_decode(file_get_contents($this->zf2rapidFileDir . $this->zf2rapidFileName), true));
}
示例11: testPagesActionCanBeAccessedByPost
public function testPagesActionCanBeAccessedByPost()
{
$this->routeMatch->setParam('action', 'pages');
$this->request->setMethod('POST');
$p = new Parameters();
$p->set('role_id', '1');
$this->request->setPost($p);
$result = $this->controller->dispatch($this->request);
$response = $this->controller->getResponse();
$this->assertInstanceOf('Zend\\Http\\Response', $result);
$this->assertEquals(302, $response->getStatusCode());
}
示例12: testHydratorParam
/**
* Test hydrator param
*/
public function testHydratorParam()
{
$this->parameters->set('moduleSrcDir', '/path/to/module/dir/testModule/src');
$this->parameters->set('config', ['namespaceHydrator' => 'Model\\Hydrator']);
$paramValueMap = [['hydrator', null, 'HydratorName'], ['baseHydrator', null, 'BaseHydrator']];
$this->route->method('getMatchedParam')->will($this->returnValueMap($paramValueMap));
$task = new Params();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
$this->assertEquals('HydratorName', $this->parameters->paramHydrator);
$this->assertEquals('BaseHydrator', $this->parameters->paramBaseHydrator);
$this->assertEquals('/path/to/module/dir/testModule/src/Model/Hydrator', $this->parameters->hydratorDir);
}
示例13: testWithExistingFile
/**
* Test with existing file
*/
public function testWithExistingFile()
{
$this->parameters->set('workingPath', $this->zf2rapidFileDir);
$setupConfig = ['foo' => 'bar', 'one' => 'two'];
file_put_contents($this->zf2rapidFileDir . $this->zf2rapidFileName, json_encode($setupConfig, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$expectedConfig = array_merge($setupConfig, ['configFileFormat' => 'php', 'flagAddDocBlocks' => 'true', 'fileDocBlockText' => 'ZF2 Application built by ZF2rapid', 'fileDocBlockCopyright' => '(c) 2015 John Doe', 'fileDocBlockLicense' => 'http://opensource.org/licenses/MIT The MIT License (MIT)', 'namespaceController' => 'Controller', 'namespaceControllerPlugin' => 'Controller\\Plugin', 'namespaceViewHelper' => 'View\\Helper', 'namespaceFilter' => 'Filter', 'namespaceValidator' => 'Validator', 'namespaceInputFilter' => 'InputFilter', 'namespaceForm' => 'Form', 'namespaceHydrator' => 'Hydrator', 'namespaceEntity' => 'Entity', 'namespaceTableGateway' => 'TableGateway', 'namespaceStorage' => 'Storage', 'namespaceRepository' => 'Repository']);
$task = new ConfigFile();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
$this->assertEquals($expectedConfig, $this->parameters->config);
$this->assertFileExists($this->zf2rapidFileDir . $this->zf2rapidFileName);
$this->assertEquals($expectedConfig, json_decode(file_get_contents($this->zf2rapidFileDir . $this->zf2rapidFileName), true));
}
示例14: testWithModuleDirCreatingSucceed
/**
* Test with module dir creating succeed
*/
public function testWithModuleDirCreatingSucceed()
{
$this->console->expects($this->once())->method('writeTaskLine')->with($this->equalTo('task_create_structure_module_root_created'));
$this->console->expects($this->once())->method('colorize');
$this->parameters->set('moduleDir', $this->zf2rapidModuleDir);
$this->parameters->set('moduleConfigDir', $this->zf2rapidModuleDir . 'config/');
$this->parameters->set('moduleSrcDir', $this->zf2rapidModuleDir . 'src/');
$this->parameters->set('moduleViewDir', $this->zf2rapidModuleDir . 'view/');
$task = new CreateModuleStructure();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(0, $result);
$this->assertFileExists($this->zf2rapidModuleDir);
$this->assertFileExists($this->zf2rapidModuleDir . 'config/');
$this->assertFileExists($this->zf2rapidModuleDir . 'src/');
$this->assertFileExists($this->zf2rapidModuleDir . 'view/');
}
示例15: testWithProjectPathNotAllowedFile
/**
* Test with project path not allowed file
*/
public function testWithProjectPathNotAllowedFile()
{
if (!file_exists($this->zf2rapidProjectPath)) {
mkdir($this->zf2rapidProjectPath);
}
if (!file_exists($this->zf2rapidProjectPath . $this->zf2rapidNotAllowedFile)) {
file_put_contents($this->zf2rapidProjectPath . $this->zf2rapidNotAllowedFile, 'test');
}
$this->console->expects($this->once())->method('writeFailLine')->with($this->equalTo('task_check_working_path_not_empty'));
$this->console->expects($this->once())->method('colorize');
$this->parameters->set('workingPath', $this->zf2rapidProjectPath);
$this->assertFileExists($this->zf2rapidProjectPath);
$task = new ProjectPathEmpty();
$result = $task($this->route, $this->console, $this->parameters);
$this->assertEquals(1, $result);
$this->assertFileExists($this->zf2rapidProjectPath);
}