Skip to content
This repository was archived by the owner on Jul 29, 2020. It is now read-only.

Commit a0bd550

Browse files
committed
Unit Test fo "Allow use DateTime object as parameter for query creation" added
1 parent 1af52f1 commit a0bd550

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/FlexiPeeHP/FlexiBeeRO.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,7 @@ public static function flexiUrl(array $data, $joiner = 'and', $defop = 'eq')
17821782
break;
17831783
case 'DateTime':
17841784
$parts[$column] = $column." eq '".$data[$column]->format(self::$DateFormat)."'";
1785+
break;
17851786
default:
17861787
$parts[$column] = $column." $defop '".$data[$column]."'";
17871788
break;

testing/src/FlexiPeeHP/FlexiBeeROTest.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ public function testConstructor()
9494

9595
$mock->__construct('',
9696
[
97-
'company' => constant('FLEXIBEE_COMPANY'),
98-
'url' => constant('FLEXIBEE_URL'),
99-
'user' => constant('FLEXIBEE_LOGIN'),
100-
'password' => constant('FLEXIBEE_PASSWORD'),
101-
'debug' => true,
102-
'prefix' => 'c',
103-
'evidence' => $evidence]);
97+
'company' => constant('FLEXIBEE_COMPANY'),
98+
'url' => constant('FLEXIBEE_URL'),
99+
'user' => constant('FLEXIBEE_LOGIN'),
100+
'password' => constant('FLEXIBEE_PASSWORD'),
101+
'debug' => true,
102+
'prefix' => 'c',
103+
'evidence' => $evidence]);
104104
}
105105

106106
/**
@@ -242,8 +242,8 @@ public function testObject2array()
242242
$this->assertNull($this->object->object2array(new \stdClass()));
243243
$this->assertEquals(
244244
[
245-
'item' => 1,
246-
'arrItem' => ['a', 'b' => 'c']
245+
'item' => 1,
246+
'arrItem' => ['a', 'b' => 'c']
247247
]
248248
, $this->object->object2array(new \Test\ObjectForTesting()));
249249
}
@@ -888,6 +888,16 @@ public function testFlexiUrl()
888888
$this->object->flexiUrl(['a' => true, 'b' => false], 'or'));
889889
$this->assertEquals("a is null and b is not null",
890890
$this->object->flexiUrl(['a' => null, 'b' => '!null'], 'and'));
891+
892+
$begin = new \DateTime('2018-08-01');
893+
$end = new \DateTime('2018-08-31');
894+
$end = $end->modify('+1 day');
895+
896+
$interval = new \DateInterval('P1D');
897+
$daterange = new \DatePeriod($begin, $interval, $end);
898+
899+
$this->assertEquals("a eq '2018-10-25' and b between '2018-08-01' '2018-09-01'",
900+
$this->object->flexiUrl(['a' => new \DateTime('25-10-2018'), 'b' => $daterange]));
891901
}
892902

893903
/**

0 commit comments

Comments
 (0)