<?php
require_once($path_to_root.'/'.'includes/date_functions.inc');
class Split {
- public $stard_date;
+ public $start_date;
public $end_date;
- function __constructor($start_date, $period) {
- $this->start_date = $this->end_date = $start_date;
- $this->extend($period);
+ function __construct($start_date, $period=null) {
+ $this->start_date = $start_date;
+ $this->end_date = $start_date;
+ if($period) $this->extend($period);
}
function extend($days) {
--- /dev/null
+<?php
+global $path_to_root;
+$path_to_root = '../../';
+require_once('includes/splitter.inc');
+
+/* Stubbing undefined function */
+global $dateformats, $dateseps;
+ $dateformats = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD","MmmDDYYYY", "DDMmmYYYY", "YYYYMmmDD");
+ $dateseps = array("/", ".", "-", " ");
+function user_date_format() {
+ return 2; // YYYMMDD
+}
+
+function user_date_sep() {
+ return 0;
+}
+
+class splitTest extends PHPUnit_Framework_TestCase {
+ public function testConstructor() {
+ $date = '2013/01/05';
+ $split = new Split($date);
+
+ $this->assertEquals($split->start_date, $date);
+ $this->assertEquals($split->end_date, $date);
+
+ return $split;
+ }
+
+ /**
+ * @depends testConstructor
+ */
+ public function testExtend($split) {
+ $split->extend(10);
+ $this->assertEquals($split->end_date, '2013/01/15');
+ }
+}
+?>