Sales - InvoiceControllerTests - fixed leap year handling
authorPaul Mehrer <p.mehrer@metaways.de>
Mon, 4 Jan 2016 13:12:07 +0000 (14:12 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 4 Jan 2016 13:30:42 +0000 (14:30 +0100)
Change-Id: I32fb768ff6b7e65267bb1254fa81d884598a6e00
Reviewed-on: http://gerrit.tine20.com/customers/2537
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Sales/InvoiceControllerTests.php
tests/tine20/Sales/InvoiceTestCase.php

index f5670c5..f3e1132 100644 (file)
@@ -541,7 +541,7 @@ class Sales_InvoiceControllerTests extends Sales_InvoiceTestCase
             $index = $month - 1;
             
             $this->assertEquals('01', $invoice->start_date->format('d'));
-            $this->assertEquals($this->_lastMonthDays[$index], $invoice->end_date->format('d'), print_r($invoice->toArray(), 1));
+            $this->assertEquals($invoice->end_date->format('t'), $invoice->end_date->format('d'), print_r($invoice->toArray(), 1));
             
             $this->assertEquals(1, $invoice->start_date->format('d'));
             
index 0eca25e..dcc0741 100644 (file)
@@ -217,7 +217,7 @@ class Sales_InvoiceTestCase extends TestCase
         $this->_lastMonthDays = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
         
         // find out if year is a leap year
-        if (($this->_referenceYear % 400) == 0 || (($this->_referenceYear % 4) == 0 && ($this->_referenceYear % 100) != 0)) {
+        if ((bool)$this->_referenceDate->format('L')) {
             $this->_isLeapYear = TRUE;
             $this->_lastMonthDays[1] = 29;
         }