public function setUp() { $apiKey = 'abc123'; $this->client = new \Box\View\Client($apiKey); $this->requestMock = m::mock('\\Box\\View\\Request'); $this->client->setRequestHandler($this->requestMock); }
/** * @runInSeparateProcess */ public function testUploadFUrlWithParams() { $documentMock = m::mock('alias:\\Box\\View\\Document'); $url = 'http://crocodoc.github.io/php-box-view/examples/files/sample.doc'; $document = new \Box\View\Document(['id' => 123]); $newName = 'Updated Name'; $documentMock->shouldReceive('uploadUrl')->with($this->client, $url, ['name' => $newName])->andReturn($document); $response = $this->client->uploadUrl($url, ['name' => $newName]); $this->assertEquals($document, $response); }
/** * Send a new request to the API. * * @param \Box\View\Client $client The client instance to make requests from. * @param string $requestPath The path to add after the base path. * @param array|null $getParams Optional. An associative array of GET params * to be added to the URL. * @param array|null $postParams Optional. An associative array of POST * params to be sent in the body. * @param array|null $requestOptions Optional. An associative array of * request options that may modify the way * the request is made. * * @return array|string The response is pass-through from Box\View\Request. * @throws \Box\View\BoxViewException */ protected static function request($client, $requestPath, $getParams = [], $postParams = [], $requestOptions = []) { return $client->getRequestHandler()->send(static::$path . $requestPath, $getParams, $postParams, $requestOptions); }