(NFC) (dev/core#878) Simplify copyright header (tests/*)
[civicrm-core.git] / tests / phpunit / CRM / Contact / Page / View / NoteTest.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
7 | This code 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 * Test class for CRM_Contact_Page_View_Note BAO
15 *
16 * @package CiviCRM
17 * @group headless
18 */
19 class CRM_Contact_Page_View_NoteTest extends CiviUnitTestCase {
20
21 /**
22 * Sets up the fixture, for example, opens a network connection.
23 * This method is called before a test is executed.
24 */
25 protected function setUp() {
26 parent::setUp();
27 }
28
29 /**
30 * Tears down the fixture, for example, closes a network connection.
31 *
32 * This method is called after a test is executed.
33 */
34 protected function tearDown() {
35 parent::tearDown();
36 }
37
38 public function testNoContactIdNote() {
39 $contactId = $this->individualCreate();
40 foreach ([1, 2, 3, 4, 5] as $noteID) {
41 $note = new CRM_Core_DAO_Note();
42 $note->entity_id = $contactId;
43 $note->subject = 'Test Note ' . $noteID;
44 $note->note = 'Test Note from Tests';
45 $note->entity_table = 'civicrm_contact';
46 if ($noteID == 5) {
47 $note->contact_id = $contactId;
48 }
49 $note->save();
50 }
51 $page = new CRM_Contact_Page_View_Note();
52 $page->_contactId = $contactId;
53 $page->_permission = CRM_Core_PERMISSION::EDIT;
54 $page->browse();
55 $this->assertEquals(count($page->values), 5);
56 foreach ($page->values as $note) {
57 $this->assertEquals($note['entity_id'], $contactId);
58 if ($note['id'] == 5) {
59 $this->assertEquals($note['createdBy'], 'Mr. Anthony Anderson II');
60 }
61 }
62 }
63
64 }