projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
APIv4 - Use non-deprecated join syntax internally
[civicrm-core.git]
/
tests
/
phpunit
/
api
/
v4
/
Action
/
ContactApiKeyTest.php
diff --git
a/tests/phpunit/api/v4/Action/ContactApiKeyTest.php
b/tests/phpunit/api/v4/Action/ContactApiKeyTest.php
index 3e411514f3de4bea409f5557b8efa642123354f5..afa8fed64a271964bd5e1a56774caf8c220abd62 100644
(file)
--- a/
tests/phpunit/api/v4/Action/ContactApiKeyTest.php
+++ b/
tests/phpunit/api/v4/Action/ContactApiKeyTest.php
@@
-14,8
+14,6
@@
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
- * $Id$
- *
*/
*/
@@
-59,10
+57,10
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
// Can also be fetched via join
$email = Email::get()
// Can also be fetched via join
$email = Email::get()
- ->addSelect('contact.api_key')
+ ->addSelect('contact
_id
.api_key')
->addWhere('id', '=', $contact['email']['id'])
->execute()->first();
->addWhere('id', '=', $contact['email']['id'])
->execute()->first();
- $this->assertEquals($key, $email['contact.api_key']);
+ $this->assertEquals($key, $email['contact
_id
.api_key']);
$this->assertFalse($isSafe($email), "Should reveal secret details ($key): " . var_export($email, 1));
// Remove permission and we should not see the key
$this->assertFalse($isSafe($email), "Should reveal secret details ($key): " . var_export($email, 1));
// Remove permission and we should not see the key
@@
-78,12
+76,12
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
// Also not available via join
$email = Email::get()
// Also not available via join
$email = Email::get()
- ->addSelect('contact.api_key')
+ ->addSelect('contact
_id
.api_key')
->addWhere('id', '=', $contact['email']['id'])
->setDebug(TRUE)
->execute();
->addWhere('id', '=', $contact['email']['id'])
->setDebug(TRUE)
->execute();
- $this->assertContains('contact.api_key', $email->debug['undefined_fields']);
- $this->assertArrayNotHasKey('contact.api_key', $email[0]);
+ $this->assertContains('contact
_id
.api_key', $email->debug['undefined_fields']);
+ $this->assertArrayNotHasKey('contact
_id
.api_key', $email[0]);
$this->assertTrue($isSafe($email[0]), "Should NOT reveal secret details ($key): " . var_export($email[0], 1));
$result = Contact::get()
$this->assertTrue($isSafe($email[0]), "Should NOT reveal secret details ($key): " . var_export($email[0], 1));
$result = Contact::get()
@@
-110,7
+108,7
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
catch (\Exception $e) {
$error = $e->getMessage();
}
catch (\Exception $e) {
$error = $e->getMessage();
}
- $this->assert
Contains
('key', $error);
+ $this->assert
StringContainsString
('key', $error);
}
public function testGetApiKeyViaJoin() {
}
public function testGetApiKeyViaJoin() {
@@
-123,8
+121,7
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
return strpos(json_encode($mixed), $key) === FALSE;
};
return strpos(json_encode($mixed), $key) === FALSE;
};
- $contact = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::create(FALSE)
->addValue('first_name', 'Api')
->addValue('last_name', 'Key0')
->addValue('api_key', $key)
->addValue('first_name', 'Api')
->addValue('last_name', 'Key0')
->addValue('api_key', $key)
@@
-132,25
+129,22
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
->first();
$this->assertFalse($isSafe($contact), "Should reveal secret details ($key): " . var_export($contact, 1));
->first();
$this->assertFalse($isSafe($contact), "Should reveal secret details ($key): " . var_export($contact, 1));
- Email::create()
- ->setCheckPermissions(FALSE)
+ Email::create(FALSE)
->addValue('email', 'foo@example.org')
->addValue('contact_id', $contact['id'])
->execute();
->addValue('email', 'foo@example.org')
->addValue('contact_id', $contact['id'])
->execute();
- $result = Email::get()
- ->setCheckPermissions(FALSE)
+ $result = Email::get(FALSE)
->addWhere('contact_id', '=', $contact['id'])
->addSelect('email')
->addWhere('contact_id', '=', $contact['id'])
->addSelect('email')
- ->addSelect('contact.api_key')
+ ->addSelect('contact
_id
.api_key')
->execute()
->first();
$this->assertFalse($isSafe($result), "Should reveal secret details ($key): " . var_export($result, 1));
->execute()
->first();
$this->assertFalse($isSafe($result), "Should reveal secret details ($key): " . var_export($result, 1));
- $result = Email::get()
- ->setCheckPermissions(TRUE)
+ $result = Email::get(TRUE)
->addWhere('contact_id', '=', $contact['id'])
->addWhere('contact_id', '=', $contact['id'])
- ->addSelect('contact.api_key')
+ ->addSelect('contact
_id
.api_key')
->execute()
->first();
$this->assertTrue($isSafe($result), "Should NOT reveal secret details ($key): " . var_export($result, 1));
->execute()
->first();
$this->assertTrue($isSafe($result), "Should NOT reveal secret details ($key): " . var_export($result, 1));
@@
-160,8
+154,7
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'edit all contacts'];
$key = uniqid();
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'edit all contacts'];
$key = uniqid();
- $contact = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::create(FALSE)
->addValue('first_name', 'Api')
->addValue('last_name', 'Key2')
->addValue('api_key', $key)
->addValue('first_name', 'Api')
->addValue('last_name', 'Key2')
->addValue('api_key', $key)
@@
-180,14
+173,13
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
$error = $e->getMessage();
}
$error = $e->getMessage();
}
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addWhere('id', '=', $contact['id'])
->addSelect('api_key')
->execute()
->first();
->addWhere('id', '=', $contact['id'])
->addSelect('api_key')
->execute()
->first();
- $this->assert
Contains
('key', $error);
+ $this->assert
StringContainsString
('key', $error);
// Assert key is still the same
$this->assertEquals($result['api_key'], $key);
// Assert key is still the same
$this->assertEquals($result['api_key'], $key);
@@
-214,8
+206,7
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'edit own api keys', 'edit all contacts'];
$key = uniqid();
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'edit own api keys', 'edit all contacts'];
$key = uniqid();
- $contact = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::create(FALSE)
->addValue('first_name', 'Api')
->addValue('last_name', 'Key3')
->addValue('api_key', $key)
->addValue('first_name', 'Api')
->addValue('last_name', 'Key3')
->addValue('api_key', $key)
@@
-234,10
+225,9
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
$error = $e->getMessage();
}
$error = $e->getMessage();
}
- $this->assert
Contains
('key', $error);
+ $this->assert
StringContainsString
('key', $error);
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addWhere('id', '=', $contact['id'])
->addSelect('api_key')
->execute()
->addWhere('id', '=', $contact['id'])
->addSelect('api_key')
->execute()
@@
-254,8
+244,7
@@
class ContactApiKeyTest extends \api\v4\UnitTestCase {
->addValue('api_key', "MyId!")
->execute();
->addValue('api_key', "MyId!")
->execute();
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addWhere('id', '=', $contact['id'])
->addSelect('api_key')
->execute()
->addWhere('id', '=', $contact['id'])
->addSelect('api_key')
->execute()