Skip to content

Commit

Permalink
Merge pull request #53 from popstas/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kleiram committed Jan 14, 2016
2 parents adca768 + d13ae3f commit 784a9ee
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 20 deletions.
78 changes: 59 additions & 19 deletions lib/Transmission/Model/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,19 @@ class Torrent extends AbstractModel
protected $uploadRatio;

/**
* @var string
*/
protected $downloadDir;
* @var string
*/
protected $downloadDir;

/**
* @var integer
*/
protected $downloadedEver;

/**
* @var integer
*/
protected $uploadedEver;

/**
* @param integer $id
Expand Down Expand Up @@ -248,8 +258,8 @@ public function setDownloadRate($rate)
{
$this->downloadRate = (integer) $rate;
}
/**

/**
* @param integer $peersConnected
*/
public function setPeersConnected($peersConnected)
Expand Down Expand Up @@ -409,20 +419,48 @@ public function isSeeding()
}

/**
* @return string
*/
public function getDownloadDir()
{
return $this->downloadDir;
}
* @return string
*/
public function getDownloadDir()
{
return $this->downloadDir;
}

/**
* @param string $downloadDir
*/
public function setDownloadDir($downloadDir)
{
$this->downloadDir = $downloadDir;
}

/**
* @return int
*/
public function getDownloadedEver() {
return $this->downloadedEver;
}

/**
* @param int $downloadedEver
*/
public function setDownloadedEver($downloadedEver) {
$this->downloadedEver = $downloadedEver;
}

/**
* @param string $downloadDir
*/
public function setDownloadDir($downloadDir)
{
$this->downloadDir = $downloadDir;
}
/**
* @return int
*/
public function getUploadedEver() {
return $this->uploadedEver;
}

/**
* @param int $uploadedEver
*/
public function setUploadedEver($uploadedEver) {
$this->uploadedEver = $uploadedEver;
}

/**
* {@inheritDoc}
Expand All @@ -447,7 +485,9 @@ public static function getMapping()
'startDate' => 'startDate',
'uploadRatio' => 'uploadRatio',
'hashString' => 'hash',
'downloadDir' => 'downloadDir'
'downloadDir' => 'downloadDir',
'downloadedEver' => 'downloadedEver',
'uploadedEver' => 'uploadedEver'
);
}
}
6 changes: 5 additions & 1 deletion tests/Transmission/Tests/Model/TorrentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public function shouldBeCreatedFromMapping()
'rateUpload' => 10,
'rateDownload' => 100,
'downloadDir' => '/home/foo',
'downloadedEver' => 1024000000,
'uploadedEver' => 1024000000000, // 1 Tb
'files' => array(
(object) array()
),
Expand Down Expand Up @@ -74,6 +76,8 @@ public function shouldBeCreatedFromMapping()
$this->assertEquals(10, $this->getTorrent()->getUploadRate());
$this->assertEquals(100, $this->getTorrent()->getDownloadRate());
$this->assertEquals('/home/foo', $this->getTorrent()->getDownloadDir());
$this->assertEquals(1024000000, $this->getTorrent()->getDownloadedEver());
$this->assertEquals(1024000000000, $this->getTorrent()->getUploadedEver());
$this->assertCount(1, $this->getTorrent()->getFiles());
$this->assertCount(2, $this->getTorrent()->getPeers());
$this->assertCount(3, $this->getTorrent()->getTrackers());
Expand Down Expand Up @@ -106,7 +110,7 @@ public function shouldBeDoneWhenPercentDoneIs100Percent()
public function shouldHaveConvenienceMethods($status, $method)
{
$methods = array('stopped', 'checking', 'downloading', 'seeding');
$accessor = PropertyAccess::getPropertyAccessor();
$accessor = PropertyAccess::createPropertyAccessor();
$this->getTorrent()->setStatus($status);

$methods = array_filter($methods, function ($value) use ($method) {
Expand Down

0 comments on commit 784a9ee

Please sign in to comment.