diff options
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Action/DateTest.php')
-rw-r--r-- | www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Action/DateTest.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Action/DateTest.php b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Action/DateTest.php new file mode 100644 index 00000000..8cdbfc7c --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Action/DateTest.php @@ -0,0 +1,46 @@ +<?php + +namespace Civi\Test\Api4\Action; + +use Civi\Api4\Contact; +use Civi\Api4\Relationship; +use Civi\Test\Api4\UnitTestCase; + +/** + * @group headless + */ +class DateTest extends UnitTestCase { + + public function testRelationshipDate() { + $c1 = Contact::create() + ->addValue('first_name', 'c') + ->addValue('last_name', 'one') + ->execute() + ->first()['id']; + $c2 = Contact::create() + ->addValue('first_name', 'c') + ->addValue('last_name', 'two') + ->execute() + ->first()['id']; + $r = Relationship::create() + ->addValue('contact_id_a', $c1) + ->addValue('contact_id_b', $c2) + ->addValue('relationship_type_id', 1) + ->addValue('start_date', 'now') + ->addValue('end_date', 'now + 1 week') + ->execute() + ->first()['id']; + $result = Relationship::get() + ->addWhere('start_date', '=', 'now') + ->addWhere('end_date', '>', 'now + 1 day') + ->execute() + ->indexBy('id'); + $this->assertArrayHasKey($r, $result); + $result = Relationship::get() + ->addWhere('start_date', '<', 'now') + ->execute() + ->indexBy('id'); + $this->assertArrayNotHasKey($r, $result); + } + +} |