kopia lustrzana https://github.com/friendica/SG-iCalendar
Fixed some problems with the unit tests - specifically a mis-named file and a timezone problem (not everyone lives in Copenhagen :P ).
rodzic
047ea8e7b3
commit
7146d1cf6a
|
@ -125,7 +125,8 @@ class SG_iCal_Freq {
|
||||||
*/
|
*/
|
||||||
public function findNext($offset) {
|
public function findNext($offset) {
|
||||||
$echo = false;
|
$echo = false;
|
||||||
|
|
||||||
|
//make sure the offset is valid
|
||||||
if( $offset === false || (isset($this->rules['until']) && $this->rules['until'] <= $offset) ) {
|
if( $offset === false || (isset($this->rules['until']) && $this->rules['until'] <= $offset) ) {
|
||||||
if($echo) echo 'STOP: ' . date('r', $offset) . "\n";
|
if($echo) echo 'STOP: ' . date('r', $offset) . "\n";
|
||||||
return false;
|
return false;
|
||||||
|
@ -133,6 +134,8 @@ class SG_iCal_Freq {
|
||||||
|
|
||||||
$found = true;
|
$found = true;
|
||||||
|
|
||||||
|
//set the timestamp of the offset (ignoring hours and minutes unless we want them to be
|
||||||
|
//part of the calculations.
|
||||||
if($echo) echo 'O: ' . date('r', $offset) . "\n";
|
if($echo) echo 'O: ' . date('r', $offset) . "\n";
|
||||||
$hour = (in_array($this->freq, array('hourly','minutely')) && $offset > $this->start) ? date('H', $offset) : date('H', $this->start);
|
$hour = (in_array($this->freq, array('hourly','minutely')) && $offset > $this->start) ? date('H', $offset) : date('H', $this->start);
|
||||||
$minute = (($this->freq == 'minutely' || isset($this->rules['byminute'])) && $offset > $this->start) ? date('i', $offset) : date('i', $this->start);
|
$minute = (($this->freq == 'minutely' || isset($this->rules['byminute'])) && $offset > $this->start) ? date('i', $offset) : date('i', $this->start);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once dirname(__FILE__) . "/../SG_iCalReader.php";
|
require_once dirname(__FILE__) . "/../SG_iCal.php";
|
||||||
|
|
||||||
require_once dirname(__FILE__) . "/../blocks/SG_iCal_VCalendar.php";
|
require_once dirname(__FILE__) . "/../blocks/SG_iCal_VCalendar.php";
|
||||||
require_once dirname(__FILE__) . "/../blocks/SG_iCal_VEvent.php";
|
require_once dirname(__FILE__) . "/../blocks/SG_iCal_VEvent.php";
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
require_once dirname(__FILE__) . '/../common.php';
|
require_once dirname(__FILE__) . '/../common.php';
|
||||||
require_once 'PHPUnit/Framework.php';
|
require_once 'PHPUnit/Framework.php';
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/Copenhagen');
|
||||||
|
|
||||||
class FreqTest extends PHPUnit_Framework_TestCase {
|
class FreqTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testDailyCount() {
|
public function testDailyCount() {
|
||||||
$dateset = array(
|
$dateset = array(
|
||||||
873183600,
|
873183600,
|
||||||
|
@ -609,7 +612,7 @@ class FreqTest extends PHPUnit_Framework_TestCase {
|
||||||
do {
|
do {
|
||||||
$n = $freq->findNext($n);
|
$n = $freq->findNext($n);
|
||||||
$e = (current($dateset) != -1) ? current($dateset) : false;
|
$e = (current($dateset) != -1) ? current($dateset) : false;
|
||||||
$this->assertEquals($n, $e);
|
$this->assertEquals($e, $n);
|
||||||
} while( next($dateset) !== false );
|
} while( next($dateset) !== false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue