Merge pull request #14004 from mfb/set-utf8
[civicrm-core.git] / tests / phpunit / CRM / Contact / Page / View / NoteTest.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 5 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2019 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 * Test class for CRM_Contact_Page_View_Note BAO
31 *
32 * @package CiviCRM
33 * @group headless
34 */
35 class CRM_Contact_Page_View_NoteTest extends CiviUnitTestCase {
36
37 /**
38 * Sets up the fixture, for example, opens a network connection.
39 * This method is called before a test is executed.
40 */
41 protected function setUp() {
42 parent::setUp();
43 }
44
45 /**
46 * Tears down the fixture, for example, closes a network connection.
47 *
48 * This method is called after a test is executed.
49 */
50 protected function tearDown() {
51 parent::tearDown();
52 }
53
54 public function testNoContactIdNote() {
55 $contactId = $this->individualCreate();
56 foreach ([1, 2, 3, 4, 5] as $noteID) {
57 $note = new CRM_Core_DAO_Note();
58 $note->entity_id = $contactId;
59 $note->subject = 'Test Note ' . $noteID;
60 $note->note = 'Test Note from Tests';
61 $note->entity_table = 'civicrm_contact';
62 if ($noteID == 5) {
63 $note->contact_id = $contactId;
64 }
65 $note->save();
66 }
67 $page = new CRM_Contact_Page_View_Note();
68 $page->_contactId = $contactId;
69 $page->_permission = CRM_Core_PERMISSION::EDIT;
70 $page->browse();
71 $this->assertEquals(count($page->values), 5);
72 foreach ($page->values as $note) {
73 $this->assertEquals($note['entity_id'], $contactId);
74 if ($note['id'] == 5) {
75 $this->assertEquals($note['createdBy'], 'Mr. Anthony Anderson II');
76 }
77 }
78 }
79
80 }