lithium\tests\mocks\console\command\MockLibraryService::send PHP Method

send() public method

public send ( $method, $path = null, $data = [], array $options = [] )
$options array
    public function send($method, $path = null, $data = array(), array $options = array())
    {
        if ($this->_config['host'] === 'localhost') {
            return null;
        }
        if ($method === 'post') {
            $this->request = $this->_request($method, $path, $data, $options);
            if (!empty($this->request->username)) {
                $user = array('method' => 'Basic', 'username' => 'gwoo', 'password' => 'password');
                if ($this->request->username !== $user['username']) {
                    $this->last = (object) array('response' => new Response());
                    $this->last->response->status(401);
                    return json_encode(array('error' => 'Invalid username/password.'));
                }
            }
            $this->last = (object) array('response' => new Response());
            $this->last->response->status(201);
            return json_encode($this->_data('plugins', 1));
        }
        if ($path === 'lab/plugins') {
            return json_encode($this->_data('plugins'));
        }
        if ($path === 'lab/extensions') {
            return json_encode($this->_data('extensions'));
        }
        if (preg_match("/lab\\/plugins/", $path, $match)) {
            return json_encode($this->_data('plugins'));
        }
        if (preg_match("/lab\\/extensions/", $path, $match)) {
            return json_encode($this->_data('extensions'));
        }
        if (preg_match("/lab\\/li3_lab.json/", $path, $match)) {
            return json_encode($this->_data('plugins', 0));
        }
        if (preg_match("/lab\\/library_test_plugin.json/", $path, $match)) {
            return json_encode($this->_data('plugins', 1));
        }
        if (preg_match("/lab\\/li3_docs.json/", $path, $match)) {
            return json_encode($this->_data('plugins', 2));
        }
    }
MockLibraryService