diff --git a/Classes/Domain/Model/Dto/AbstractDemand.php b/Classes/Domain/Model/Dto/AbstractDemand.php index 58a7fc99..cd09f415 100644 --- a/Classes/Domain/Model/Dto/AbstractDemand.php +++ b/Classes/Domain/Model/Dto/AbstractDemand.php @@ -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 diff --git a/Tests/Unit/Domain/Model/AbstractDemandTest.php b/Tests/Unit/Domain/Model/AbstractDemandTest.php index 7e1e14b7..2817522f 100644 --- a/Tests/Unit/Domain/Model/AbstractDemandTest.php +++ b/Tests/Unit/Domain/Model/AbstractDemandTest.php @@ -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