Merge pull request #17778 from totten/master-setup-validate
[civicrm-core.git] / tests / phpunit / api / v4 / Action / EventTest.php
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 use Civi\Api4\Event;
20
21 /**
22 * @group headless
23 */
24 class EventTest extends \api\v4\UnitTestCase {
25
26 /**
27 * Test that the event api filters out templates by default.
28 *
29 * @throws \Civi\API\Exception\UnauthorizedException
30 */
31 public function testTemplateFilterByDefault() {
32 $t = Event::create()->setValues(['template_title' => 'Big Event', 'is_template' => 1, 'start_date' => 'now', 'event_type_id:name' => 'Meeting'])->execute()->first();
33 $e = Event::create()->setValues(['title' => 'Bigger Event', 'start_date' => 'now', 'event_type_id:name' => 'Meeting'])->execute()->first();
34 $result = (array) Event::get()->execute()->column('id');
35 $this->assertContains($e['id'], $result);
36 $this->assertNotContains($t['id'], $result);
37 }
38
39 }