Skip to content

Commit

Permalink
[BUGFIX] prevent NULL value for limit in EventRepository
Browse files Browse the repository at this point in the history
Closes: #30
  • Loading branch information
dwenzel committed Sep 2, 2015
1 parent 6c84721 commit c80ece6
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 92 deletions.
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/EventRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function buildQuery($demand, $respectEnableFields = TRUE){
$query->setOrderings(array($demand->getSortBy() => $sortOrder));
}
// limit
if ($demand->getLimit()) {
if ($demand->getLimit() !== NULL) {
$query->setLimit($demand->getLimit());
}
if ($demand->getStoragePages()) {
Expand Down
188 changes: 97 additions & 91 deletions Tests/Unit/Domain/Model/AbstractDemandTest.php
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
<?php
namespace Webfox\T3events\Tests\Unit\Domain\Model;
/***************************************************************
* Copyright notice
*
* (c) 2012 Dirk Wenzel <wenzel@webfox01.de>, Agentur Webfox
* Michael Kasten <kasten@webfox01.de>, Agentur Webfox
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.

/***************************************************************
* Copyright notice
* (c) 2012 Dirk Wenzel <wenzel@webfox01.de>, Agentur Webfox
* Michael Kasten <kasten@webfox01.de>, Agentur Webfox
* All rights reserved
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Test case for class \Webfox\T3events\Domain\Model\Dto\AbstractDemand.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
* Test case for class \Webfox\T3events\Domain\Model\Dto\AbstractDemand.
*
* @version $Id$
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
* @package TYPO3
* @subpackage Events
*
* @author Dirk Wenzel <wenzel@webfox01.de>
* @author Michael Kasten <kasten@webfox01.de>
* @coversDefaultClass \Webfox\T3events\Domain\Model\Dto\AbstractDemand
*/
class AbstractDemandTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
* @version $Id$
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
* @package TYPO3
* @subpackage Events
* @author Dirk Wenzel <wenzel@webfox01.de>
* @author Michael Kasten <kasten@webfox01.de>
* @coversDefaultClass \Webfox\T3events\Domain\Model\Dto\AbstractDemand
*/
class AbstractDemandTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {

/**
* @var \Webfox\T3events\Domain\Model\Dto\AbstractDemand
*/
protected $fixture;

public function setUp(){
public function setUp() {
$this->fixture = new \Webfox\T3events\Domain\Model\Dto\AbstractDemand();
}

Expand All @@ -57,98 +51,110 @@ public function tearDown() {
* @test
* @covers ::getPeriod
*/
public function getPeriodReturnsInitialValueForString(){
public function getPeriodReturnsInitialValueForString() {
$this->assertNull($this->fixture->getPeriod());
}

/**
* @test
* @covers ::setPeriod
*/
public function setPeriodForStringSetsDefaultEmptyString(){
public function setPeriodForStringSetsDefaultEmptyString() {
$this->fixture->setPeriod();
$this->assertSame(
'',
$this->fixture->getPeriod()
'',
$this->fixture->getPeriod()
);
}

/**
* @test
* @covers ::setPeriod
*/
public function setPeriodForStringSetsPeriod(){
public function setPeriodForStringSetsPeriod() {
$this->fixture->setPeriod('foo');
$this->assertSame(
'foo',
$this->fixture->getPeriod()
'foo',
$this->fixture->getPeriod()
);
}

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

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

/**
* @test
* @covers ::getOffset
*/
public function getOffsetReturnsInitialNull(){
* @test
* @covers ::setLimit
*/
public function setLimitCastsStringToInteger () {
$this->fixture->setLimit('2');
$this->assertInternalType(
'int',
$this->fixture->getLimit()
);
}

/**
* @test
* @covers ::getOffset
*/
public function getOffsetReturnsInitialNull() {
$this->assertNull($this->fixture->getOffset());
}

/**
* @test
* @covers ::setOffset
*/
public function setOffsetSetsDefaultValueZeroForInteger(){
* @test
* @covers ::setOffset
*/
public function setOffsetSetsDefaultValueZeroForInteger() {
$this->fixture->setOffset();
$this->assertSame(
0,
$this->fixture->getOffset());
0,
$this->fixture->getOffset());
}

/**
* @test
* @covers ::setOffset
*/
public function setOffsetSetsOffsetForInteger(){
* @test
* @covers ::setOffset
*/
public function setOffsetSetsOffsetForInteger() {
$this->fixture->setOffset(99);
$this->assertSame(
99,
$this->fixture->getOffset());
99,
$this->fixture->getOffset());
}

/**
* @test
* @covers ::getSortDirection
*/
public function getSortDirectionReturnsInitialNull(){
* @test
* @covers ::getSortDirection
*/
public function getSortDirectionReturnsInitialNull() {
$this->assertNull($this->fixture->getSortDirection());
}

/**
* @test
* @covers ::setSortDirection
*/
public function setSortDirectionForStringSetsSort(){
* @test
* @covers ::setSortDirection
*/
public function setSortDirectionForStringSetsSort() {
$this->fixture->setSortDirection('baz');
$this->assertSame(
'baz',
$this->fixture->getSortDirection()
'baz',
$this->fixture->getSortDirection()
);
}

Expand All @@ -161,22 +167,22 @@ public function getSortByReturnsInitiallyNull() {
}

/**
* @test
* @covers ::setSortBy
*/
* @test
* @covers ::setSortBy
*/
public function setSortByForStringSetsSortBy() {
$this->fixture->setSortBy('my.sort.string.with.dots');
$this->assertSame(
'my.sort.string.with.dots',
$this->fixture->getSortBy()
'my.sort.string.with.dots',
$this->fixture->getSortBy()
);
}

/**
* @test
* @covers ::getPeriodType
*/
public function getPeriodTypeReturnsInitialNull(){
public function getPeriodTypeReturnsInitialNull() {
$this->assertNull($this->fixture->getPeriodType());
}

Expand All @@ -185,7 +191,7 @@ public function getPeriodTypeReturnsInitialNull(){
* @covers ::setPeriodType
*/
public function setPeriodTypeForStringSetsPeriodType() {
$type= 'aType';
$type = 'aType';
$this->fixture->setPeriodType($type);
$this->assertSame($type, $this->fixture->getPeriodType());
}
Expand All @@ -194,15 +200,15 @@ public function setPeriodTypeForStringSetsPeriodType() {
* @test
* @covers ::getStoragePages
*/
public function getStoragePagesReturnsInitialNull(){
public function getStoragePagesReturnsInitialNull() {
$this->assertNull($this->fixture->getStoragePages());
}

/**
* @test
* @covers ::setStoragePages
*/
public function setStoragePagesForStringSetsStoragePages(){
public function setStoragePagesForStringSetsStoragePages() {
$this->fixture->setStoragePages('15,78,39');
$this->assertSame('15,78,39', $this->fixture->getStoragePages());
}
Expand Down Expand Up @@ -263,15 +269,15 @@ public function setStartDateForDateTimeSetsStartDate() {
* @test
* @covers ::getEndDate
*/
public function getEndDateReturnsInitialNull(){
public function getEndDateReturnsInitialNull() {
$this->assertNull($this->fixture->getEndDate());
}

/**
* @test
* @covers ::setEndDate
*/
public function setEndDateForDateTimeSetsEndDate(){
public function setEndDateForDateTimeSetsEndDate() {
$date = new \DateTime();
$this->fixture->setEndDate($date);
$this->assertSame($date, $this->fixture->getEndDate());
Expand All @@ -281,15 +287,15 @@ public function setEndDateForDateTimeSetsEndDate(){
* @test
* @covers ::getUidList
*/
public function getUidListReturnsInitialNull(){
public function getUidListReturnsInitialNull() {
$this->assertNull($this->fixture->getUidList());
}

/**
* @test
* @covers ::setUidList
*/
public function setUidListForStringSetsUidList(){
public function setUidListForStringSetsUidList() {
$this->fixture->setUidList('1,3,5');
$this->assertSame('1,3,5', $this->fixture->getUidList());
}
Expand Down

0 comments on commit c80ece6

Please sign in to comment.