9630: sanitize attender quantity
authorsstamer <s.stamer@metaways.de>
Mon, 17 Mar 2014 13:08:27 +0000 (14:08 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 20 Mar 2014 12:15:12 +0000 (13:15 +0100)
https://forge.tine20.org/mantisbt/view.php?id=9630
- If the given quantity is empty it should be set to 1
- Unittest

Change-Id: I5bab39d9a5acf14f02ab77cece98553cb570eb3a
Reviewed-on: http://gerrit.tine20.com/customers/447
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/JsonTests.php
tine20/Calendar/Model/Attender.php

index a1c07d8..7788edf 100644 (file)
@@ -1451,4 +1451,18 @@ class Calendar_JsonTests extends Calendar_TestCase
         $this->assertEquals('00:00:00', $event->dtstart->format('H:i:s'));
         $this->assertEquals('23:59:59', $event->dtend->format('H:i:s'));
     }
+    
+     /**
+     * testAttendeeChangeQuantityToInvalid
+     * 
+     * @see 9630: sanitize attender quantity
+     */
+    public function testAttendeeChangeQuantityToInvalid()
+    {
+        $eventData = $this->testCreateEvent();
+        $currentAttendee = $eventData['attendee'];
+        $eventData['attendee'][1]['quantity'] = '';
+        $event = $this->_uit->saveEvent($eventData);
+        $this->assertEquals(1, $event['attendee'][1]['quantity'], 'The invalid quantity should be saved as 1');
+    }
 }
index 14eaf48..f4000ba 100644 (file)
@@ -226,6 +226,10 @@ class Calendar_Model_Attender extends Tinebase_Record_Abstract
             }
         }
         
+        if (empty($_data['quantity'])) {
+            $_data['quantity'] = 1;
+        }
+        
         parent::setFromArray($_data);
     }