4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 namespace api\v
4\Action
;
22 use Civi\Api4\Contact
;
23 use api\v
4\UnitTestCase
;
26 * Class UpdateContactTest
27 * @package api\v4\Action
30 class UpdateContactTest
extends UnitTestCase
{
32 public function testUpdateWithIdInWhere() {
33 $contactId = Contact
::create(FALSE)
34 ->addValue('first_name', 'Johann')
35 ->addValue('last_name', 'Tester')
36 ->addValue('contact_type', 'Individual')
40 $contact = Contact
::update(FALSE)
41 ->addWhere('id', '=', $contactId)
42 ->addValue('first_name', 'Testy')
45 $this->assertEquals('Testy', $contact['first_name']);
46 $this->assertEquals('Tester', $contact['last_name']);
49 public function testUpdateWithIdInValues() {
50 $contactId = Contact
::create(FALSE)
51 ->addValue('first_name', 'Bobby')
52 ->addValue('last_name', 'Tester')
53 ->addValue('contact_type', 'Individual')
57 $contact = Contact
::update(FALSE)
58 ->addValue('id', $contactId)
59 ->addValue('first_name', 'Billy')
61 $this->assertCount(1, $contact);
62 $this->assertEquals($contactId, $contact[0]['id']);
63 $this->assertEquals('Billy', $contact[0]['first_name']);
64 $this->assertEquals('Tester', $contact[0]['last_name']);