Commit | Line | Data |
---|---|---|
c1871119 CW |
1 | <?php |
2 | ||
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
5 | | Copyright CiviCRM LLC. All rights reserved. | | |
6 | | | | |
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 | +--------------------------------------------------------------------+ | |
11 | */ | |
12 | ||
13 | /** | |
14 | * | |
15 | * @package CRM | |
16 | * @copyright CiviCRM LLC https://civicrm.org/licensing | |
17 | */ | |
18 | ||
19 | namespace api\v4\Entity; | |
20 | ||
21 | use api\v4\UnitTestCase; | |
22 | use Civi\Api4\Domain; | |
23 | use Civi\Test\TransactionalInterface; | |
24 | ||
25 | /** | |
26 | * @group headless | |
27 | */ | |
28 | class DomainTest extends UnitTestCase implements TransactionalInterface { | |
29 | ||
30 | public function testActiveDomain() { | |
31 | Domain::create(FALSE) | |
32 | ->addValue('name', 'Not current') | |
33 | ->addValue('version', \CRM_Utils_System::version()) | |
34 | ->execute(); | |
35 | ||
36 | Domain::update(FALSE) | |
37 | ->addValue('name', 'Currently the current domain') | |
38 | ->addWhere('is_active', '=', TRUE) | |
39 | ->execute(); | |
40 | ||
41 | $getCurrent = Domain::get(FALSE) | |
42 | ->addWhere('is_active', '=', TRUE) | |
43 | ->execute()->single(); | |
44 | ||
45 | $this->assertEquals('Currently the current domain', $getCurrent['name']); | |
46 | ||
47 | $getAll = Domain::get(FALSE) | |
48 | ->addSelect('*', 'is_active') | |
49 | ->execute()->indexBy('name'); | |
50 | ||
51 | $this->assertTrue($getAll['Currently the current domain']['is_active']); | |
52 | $this->assertFalse($getAll['Not current']['is_active']); | |
53 | } | |
54 | ||
55 | } |