From beb80664a9f446dd0c3a6c31326891ae6b144ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20M=C3=BCller?= <typo3@t3node.com> Date: Thu, 9 Jan 2014 15:48:28 +0100 Subject: [PATCH] [BUGFIX] Allow empty values in start/stop filter of belog One can limit records in the backend log module to a custom period of time using the "User defined" mode and a start and stop field. Leaving these fields empty is now supported in the corresponding domain model setters by adding default values to the DateTime arguments. Resolves: #53975 Releases: 6.1, 6.2 Change-Id: I944322bb3747a29fab33c3d32e17dd070c7cb6db Reviewed-on: https://review.typo3.org/26723 Reviewed-by: Markus Klein Tested-by: Markus Klein Reviewed-by: Wouter Wolters Tested-by: Wouter Wolters --- .../belog/Classes/Domain/Model/Constraint.php | 4 +- .../Unit/Domain/Model/ConstraintTest.php | 84 +++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 typo3/sysext/belog/Tests/Unit/Domain/Model/ConstraintTest.php diff --git a/typo3/sysext/belog/Classes/Domain/Model/Constraint.php b/typo3/sysext/belog/Classes/Domain/Model/Constraint.php index bdea85f1744c..0385673df5b0 100644 --- a/typo3/sysext/belog/Classes/Domain/Model/Constraint.php +++ b/typo3/sysext/belog/Classes/Domain/Model/Constraint.php @@ -251,7 +251,7 @@ class Constraint extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { * @param \DateTime $manualDateStart * @return void */ - public function setManualDateStart(\DateTime $manualDateStart) { + public function setManualDateStart(\DateTime $manualDateStart = NULL) { $this->manualDateStart = $manualDateStart; } @@ -270,7 +270,7 @@ class Constraint extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { * @param \DateTime $manualDateStop * @return void */ - public function setManualDateStop(\DateTime $manualDateStop) { + public function setManualDateStop(\DateTime $manualDateStop = NULL) { $this->manualDateStop = $manualDateStop; } diff --git a/typo3/sysext/belog/Tests/Unit/Domain/Model/ConstraintTest.php b/typo3/sysext/belog/Tests/Unit/Domain/Model/ConstraintTest.php new file mode 100644 index 000000000000..07a6573c3a2c --- /dev/null +++ b/typo3/sysext/belog/Tests/Unit/Domain/Model/ConstraintTest.php @@ -0,0 +1,84 @@ +<?php +namespace TYPO3\CMS\Belog\Tests\Unit\Domain\Model; + +/*************************************************************** + * Copyright notice + * + * (c) 2014 Steffen Müller <typo3@t3node.com> + * 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! + ***************************************************************/ + +/** + * Testcase for \TYPO3\CMS\Belog\Domain\Model\Constraint + * + * @author Steffen Müller <typo3@t3node.com> + */ +class ConstraintTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase { + + /** + * @var \TYPO3\CMS\Belog\Domain\Model\Constraint + */ + protected $subject = NULL; + + public function setUp() { + $this->subject = new \TYPO3\CMS\Belog\Domain\Model\Constraint(); + } + + public function tearDown() { + unset($this->subject); + } + + /** + * @test + */ + public function setManualDateStartForDateTimeSetsManualDateStart() { + $date = new \DateTime(); + $this->subject->setManualDateStart($date); + + $this->assertAttributeEquals($date, 'manualDateStart', $this->subject); + } + + /** + * @test + */ + public function setManualDateStartForNoArgumentSetsManualDateStart() { + $this->subject->setManualDateStart(); + + $this->assertAttributeEquals(NULL, 'manualDateStart', $this->subject); + } + + /** + * @test + */ + public function setManualDateStopForDateTimeSetsManualDateStop() { + $date = new \DateTime(); + $this->subject->setManualDateStop($date); + + $this->assertAttributeEquals($date, 'manualDateStop', $this->subject); + } + + /** + * @test + */ + public function setManualDateStopForNoArgumentSetsManualDateStop() { + $this->subject->setManualDateStop(); + + $this->assertAttributeEquals(NULL, 'manualDateStop', $this->subject); + } +} -- GitLab