4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 namespace api\v
4\Action
;
24 use Civi\Api4\Contact
;
25 use Civi\Api4\Relationship
;
26 use api\v
4\UnitTestCase
;
31 class DateTest
extends UnitTestCase
{
33 public function testRelationshipDate() {
34 $c1 = Contact
::create()
35 ->addValue('first_name', 'c')
36 ->addValue('last_name', 'one')
39 $c2 = Contact
::create()
40 ->addValue('first_name', 'c')
41 ->addValue('last_name', 'two')
44 $r = Relationship
::create()
45 ->addValue('contact_id_a', $c1)
46 ->addValue('contact_id_b', $c2)
47 ->addValue('relationship_type_id', 1)
48 ->addValue('start_date', 'now')
49 ->addValue('end_date', 'now + 1 week')
52 $result = Relationship
::get()
53 ->addWhere('start_date', '=', 'now')
54 ->addWhere('end_date', '>', 'now + 1 day')
57 $this->assertArrayHasKey($r, $result);
58 $result = Relationship
::get()
59 ->addWhere('start_date', '<', 'now')
62 $this->assertArrayNotHasKey($r, $result);