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\Api4TestBase
;
24 use Civi\Test\TransactionalInterface
;
27 * Class UpdateContactTest
28 * @package api\v4\Action
31 class UpdateContactTest
extends Api4TestBase
implements TransactionalInterface
{
33 public function testUpdateWithIdInWhere() {
34 $contactId = Contact
::create(FALSE)
35 ->addValue('first_name', 'Johann')
36 ->addValue('last_name', 'Tester')
37 ->addValue('contact_type', 'Individual')
41 $contact = Contact
::update(FALSE)
42 ->addWhere('id', '=', $contactId)
43 ->addValue('first_name', 'Testy')
46 $this->assertEquals('Testy', $contact['first_name']);
47 $this->assertEquals('Tester', $contact['last_name']);
50 public function testUpdateWithIdInValues() {
51 $contactId = Contact
::create(FALSE)
52 ->addValue('first_name', 'Bobby')
53 ->addValue('last_name', 'Tester')
54 ->addValue('contact_type', 'Individual')
58 $contact = Contact
::update(FALSE)
59 ->addValue('id', $contactId)
60 ->addValue('first_name', 'Billy')
62 $this->assertCount(1, $contact);
63 $this->assertEquals($contactId, $contact[0]['id']);
64 $this->assertEquals('Billy', $contact[0]['first_name']);
65 $this->assertEquals('Tester', $contact[0]['last_name']);