Skip to content

Commit

Permalink
[BUGFIX] AbstractDemand-> setLimit doesn't allow zero value anymore.
Browse files Browse the repository at this point in the history
fixes #30
  • Loading branch information
dwenzel committed Sep 2, 2015
1 parent bfea646 commit 1b563ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Classes/Domain/Model/Dto/AbstractDemand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ class AbstractDemand extends AbstractEntity implements DemandInterface {
protected $search;

/**
* @param int $limit A limit for the demand
* @return void
*/
public function setLimit ($limit = 100) {
$this->limit = (int)$limit;
}
* Sets the limit
*
* @param int $limit A limit for the demand. Only values > 0 are allowed. Default 100
* @return void
*/
public function setLimit($limit = 100) {
if ($validatedLimit = (int) $limit > 0) {
$this->limit = (int) $limit;
}
}

/**
* @return \string The time limit for the demand
Expand Down
12 changes: 12 additions & 0 deletions Tests/Unit/Domain/Model/AbstractDemandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ public function setLimitCastsStringToInteger () {
);
}

/**
* @test
* @covers ::setLimit
*/
public function setLimitValidatesLimitGreatherThanZero() {
$this->fixture->setLimit(-1);
$this->assertSame(
100,
$this->fixture->getLimit()
);
}

/**
* @test
* @covers ::getOffset
Expand Down

0 comments on commit 1b563ef

Please sign in to comment.