当前位置: 首页>>代码示例>>PHP>>正文


PHP Terminus::is_test方法代码示例

本文整理汇总了PHP中Terminus::is_test方法的典型用法代码示例。如果您正苦于以下问题:PHP Terminus::is_test方法的具体用法?PHP Terminus::is_test怎么用?PHP Terminus::is_test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Terminus的用法示例。


在下文中一共展示了Terminus::is_test方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Instantiates object, sets cache and session
  *
  * @return [TerminusCommand] $this
  */
 public function __construct()
 {
     //Load commonly used data from cache
     $this->cache = Terminus::get_cache();
     $this->logger = Terminus::get_logger();
     $this->outputter = Terminus::get_outputter();
     $this->session = Session::instance();
     if (!Terminus::is_test()) {
         $this->checkForUpdate();
     }
 }
开发者ID:nataliejeremy,项目名称:cli,代码行数:16,代码来源:class-terminus-command.php

示例2: request

 /**
  * Make a request to the Dashbord's internal API.
  *
  * @param $realm
  *    Permissions realm for data request: currently "user" or "site" but in the
  *    future this could also be "organization" or another high-level business
  *    object (e.g. "product" for managing your app). Can also be "public" to
  *    simply pull read-only data that is not privileged.
  *
  * @param $uuid
  *    The UUID of the item in the realm you want to access.
  *
  * @param $method
  *    HTTP method (verb) to use.
  *
  * @param $data
  *    A native PHP data structure (int, string, arary or simple object) to be
  *    sent along with the request. Will be encoded as JSON for you.
  */
 public static function request($realm, $uuid, $path = FALSE, $method = 'GET', $options = NULL)
 {
     if (!in_array($realm, array('login', 'user', 'public')) and !Terminus::is_test()) {
         Auth::loggedIn();
     }
     try {
         $cache = Terminus::get_cache();
         // combine session realm uuid and path to get a unique key
         // @todo need cache "groups"
         $cachekey = md5(Session::getValue('user_uuid') . $uuid . $realm . $path);
         $data = $cache->get_data($cachekey);
         // check the request cache
         if ("GET" == $method and !Terminus::get_config('nocache') and !getenv('CLI_TEST_MODE') and !empty($data)) {
             if (Terminus::get_config('debug')) {
                 Logger::debug('CacheKey: ' . $cachekey);
             }
             return (array) $data;
         }
         // for some methods we'll assume the cache should be invalidated
         if (in_array($method, array("POST", "PUT", "DELETE"))) {
             $cache->flush(null, 'session');
         }
         if (!in_array($realm, array('login', 'user'))) {
             $options['cookies'] = array('X-Pantheon-Session' => Session::getValue('session'));
             $options['verify'] = false;
         }
         $url = Endpoint::get(array('realm' => $realm, 'uuid' => $uuid, 'path' => $path));
         if (Terminus::get_config('debug')) {
             Logger::debug('Request URL: ' . $url);
         }
         $resp = Request::send($url, $method, $options);
         $json = $resp->getBody(TRUE);
         $data = array('info' => $resp->getInfo(), 'headers' => $resp->getRawHeaders(), 'json' => $json, 'data' => json_decode($json), 'status_code' => $resp->getStatusCode());
         $cache->put_data($cachekey, $data);
         return $data;
     } catch (Guzzle\Http\Exception\BadResponseException $e) {
         $response = $e->getResponse();
         \Terminus::error("%s", $response->getBody(TRUE));
     } catch (Guzzle\Http\Exception\HttpException $e) {
         $request = $e->getRequest();
         //die(Terminus_Command::stripSensitiveData());
         $sanitized_request = Terminus_Command::stripSensitiveData((string) $request, Terminus_Command::$_blacklist);
         \Terminus::error("Request %s had failed: %s", array($sanitized_request, $e->getMessage()));
     } catch (Exception $e) {
         \Terminus::error("Unrecognised request failure: %s", $e->getMessage());
     }
 }
开发者ID:xwp,项目名称:pantheon-cli,代码行数:66,代码来源:class-terminus-command.php

示例3: launch_self

 /**
  * Launch another Terminus command using the runtime arguments for the current process
  *
  * @param string Command to call
  * @param array $args Positional arguments to use
  * @param array $assoc_args Associative arguments to use
  * @param bool Whether to exit if the command returns an error status
  *
  * @return int The command exit status
  */
 static function launch_self($command, $args = array(), $assoc_args = array(), $exit_on_error = true)
 {
     $reused_runtime_args = array('path', 'url', 'user', 'allow-root');
     foreach ($reused_runtime_args as $key) {
         if (array_key_exists($key, self::get_runner()->config)) {
             $assoc_args[$key] = self::get_runner()->config[$key];
         }
     }
     $php_bin = self::get_php_binary();
     if (Terminus::is_test()) {
         $script_path = __DIR__ . '/boot-fs.php';
     } else {
         $script_path = $GLOBALS['argv'][0];
     }
     $args = implode(' ', array_map('escapeshellarg', $args));
     $assoc_args = \Terminus\Utils\assoc_args_to_str($assoc_args);
     $full_command = "{$php_bin} {$script_path} {$command} {$args} {$assoc_args}";
     return self::launch($full_command, $exit_on_error);
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:29,代码来源:class-terminus.php

示例4: testIsTest

 function testIsTest()
 {
     $this->assertTrue(\Terminus::is_test());
 }
开发者ID:nataliejeremy,项目名称:cli,代码行数:4,代码来源:test-utils.php

示例5: doLogin

 /**
  * Execute the login based on email,password
  *
  * @param $email string (required)
  * @param $password string (required)
  * @package Terminus
  * @version 0.04-alpha
  * @return string
  */
 private function doLogin($email, $password)
 {
     if (Terminus::is_test()) {
         $data = array('user_uuid' => '77629472-3050-457c-8c3d-32b2cabf992b', 'session' => '77629472-3050-457c-8c3d-32b2cabf992b:7dc42f40-65f8-11e4-b314-bc764e100eb1:ZHR0TgtQYsKcOOwMOd0tk', 'session_expire_time' => '1417727066', 'email' => 'wink@getpantheon.com');
         return $data;
     }
     $options = array('body' => json_encode(array('email' => $email, 'password' => $password)), 'headers' => array('Content-type' => 'application/json'));
     $response = Terminus_Command::request('login', '', '', 'POST', $options);
     if (!$response or '200' != @$response['info']['http_code']) {
         \Terminus::error("[auth_error]: unsuccessful login");
     }
     // Prepare credentials for storage.
     $data = array('user_uuid' => $response['data']->user_id, 'session' => $response['data']->session, 'session_expire_time' => $response['data']->expires_at, 'email' => $email);
     // creates a session instance
     Session::instance()->setData($data);
     return $data;
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:26,代码来源:auth.php


注:本文中的Terminus::is_test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。