[TASK] Add test for GroupedForViewHelper to support DateTime Objects
authorKilian Hann <khann@fconnection.com>
Fri, 13 Apr 2012 09:43:27 +0000 (11:43 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 10 Feb 2013 13:49:54 +0000 (14:49 +0100)
The DateTime Object was fixed before, but the GroupedForViewHelperTest
still misses a test to demonstrate the possibility to group items
subsequently after a property defined as DateTime Object.

So the patch originally meant to apply is dropped, but we keep the test.

Change-Id: I658d99afd82e9572f070ac9daef25416031bc215
Fixes: #35412
Releases: 6.1
Reviewed-on: https://review.typo3.org/10440
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Markus Günther
Tested-by: Markus Günther
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/fluid/Tests/Unit/ViewHelpers/GroupedForViewHelperTest.php

index 8848a1b..d7c0f76 100644 (file)
@@ -216,6 +216,40 @@ class GroupedForViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\V
        /**
         * @test
         */
        /**
         * @test
         */
+       public function renderGroupsMultidimensionalObjectByDateTimeObject() {
+
+               $date1 = new \DateTime('2010-07-01');
+               $date2 = new \DateTime('2010-07-04');
+
+               $invoice1 = new \stdClass();
+               $invoice1->date = $date1;
+               $invoice1->id = 12340;
+
+               $invoice2 = new \stdClass();
+               $invoice2->date = $date1;
+               $invoice2->id = 12341;
+
+               $invoice3 = new \stdClass();
+               $invoice3->date = $date2;
+               $invoice3->id = 12342;
+
+               $invoices = array('invoice1' => $invoice1, 'invoice2' => $invoice2, 'invoice3' => $invoice3);
+
+               $this->templateVariableContainer->expects($this->at(0))->method('add')->with('myGroupKey', $date1);
+               $this->templateVariableContainer->expects($this->at(1))->method('add')->with('invoices', array('invoice1' => $invoice1, 'invoice2' => $invoice2));
+               $this->templateVariableContainer->expects($this->at(2))->method('remove')->with('myGroupKey');
+               $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('invoices');
+               $this->templateVariableContainer->expects($this->at(4))->method('add')->with('myGroupKey', $date2);
+               $this->templateVariableContainer->expects($this->at(5))->method('add')->with('invoices', array('invoice3' => $invoice3));
+               $this->templateVariableContainer->expects($this->at(6))->method('remove')->with('myGroupKey');
+               $this->templateVariableContainer->expects($this->at(7))->method('remove')->with('invoices');
+
+               $this->viewHelper->render($invoices, 'invoices', 'date', 'myGroupKey');
+       }
+
+       /**
+        * @test
+        */
        public function groupingByAKeyThatDoesNotExistCreatesASingleGroup() {
                $photoshop = array('name' => 'Adobe Photoshop', 'license' => 'commercial');
                $typo3 = array('name' => 'TYPO3', 'license' => 'GPL');
        public function groupingByAKeyThatDoesNotExistCreatesASingleGroup() {
                $photoshop = array('name' => 'Adobe Photoshop', 'license' => 'commercial');
                $typo3 = array('name' => 'TYPO3', 'license' => 'GPL');