Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from MartialGeek/free_space
Browse files Browse the repository at this point in the history
Fix #7 : Add missing return statement in the freeSpace method
Martial Saunois authored and Martial Saunois committed Mar 8, 2016
2 parents b5509c2 + 063f49c commit 860496e
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/RpcClient.php
Original file line number Diff line number Diff line change
@@ -477,7 +477,9 @@ public function queueMoveBottom($sessionId, array $ids)
*/
public function freeSpace($sessionId, $path)
{
$this->sendRequest($sessionId, $this->buildRequestBody('free-space', ['path' => $path]));
$response = $this->sendRequest($sessionId, $this->buildRequestBody('free-space', ['path' => $path]));

return $response['arguments'];
}

/**
14 changes: 12 additions & 2 deletions tests/RpcClientTest.php
Original file line number Diff line number Diff line change
@@ -1713,14 +1713,24 @@ public function testQueueMoveBottomShouldThrowAnExceptionWithAnInvalidSessionId(
public function testFreeSpaceWithSuccess()
{
$requestBody = '{"method":"free-space","arguments":{"path":"/var/lib/transmission-daemon/downloads"}}';
$path = '/var/lib/transmission-daemon/downloads';
$size = 37548523520;

$this
->sendRequest($requestBody)
->andReturn($this->guzzleResponse);

$jsonResponse = '{"arguments":{"path":"/var/lib/transmission-daemon/downloads","size-bytes":37548523520},"result":"success"}';
$jsonResponse = sprintf(
'{"arguments":{"path":"%s","size-bytes":%d},"result":"success"}',
$path,
$size
);

$this->setResponseBody($jsonResponse);
$this->rpcClient->freeSpace($this->sessionId, '/var/lib/transmission-daemon/downloads');
$result = $this->rpcClient->freeSpace($this->sessionId, $path);
$this->assertInternalType('array', $result);
$this->assertSame($path, $result['path']);
$this->assertSame($size, $result['size-bytes']);
}

public function testFreeSpaceShouldThrowAnExceptionWhenThePathIsInvalid()

0 comments on commit 860496e

Please sign in to comment.