[BUGFIX] Allow empty values in start/stop filter of belog 28/26728/2
authorSteffen Müller <typo3@t3node.com>
Thu, 9 Jan 2014 14:48:28 +0000 (15:48 +0100)
committerSteffen Müller <typo3@t3node.com>
Thu, 9 Jan 2014 19:55:39 +0000 (20:55 +0100)
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/26728
Reviewed-by: Steffen Müller
Tested-by: Steffen Müller
typo3/sysext/belog/Classes/Domain/Model/Constraint.php
typo3/sysext/belog/Tests/Unit/Domain/Model/ConstraintTest.php [new file with mode: 0644]

index 01a509a..64c6db0 100644 (file)
@@ -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;
        }
 
@@ -380,4 +380,4 @@ class Constraint extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
 
 }
 
-?>
\ No newline at end of file
+?>
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 (file)
index 0000000..07a6573
--- /dev/null
@@ -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);
+       }
+}