3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Verify that the SOAP bindings correctly parse and authenticate requests.
16 class E2E_Extern_SoapTest
extends CiviEndToEndTestCase
{
33 public function setUp() {
34 CRM_Core_Config
::singleton(1, 1);
37 $this->adminUser
= $_CV['ADMIN_USER'];
38 $this->adminPass
= $_CV['ADMIN_PASS'];
39 $this->url
= CRM_Core_Resources
::singleton()->getUrl('civicrm', 'extern/soap.php');
41 foreach (array('adminUser', 'adminPass', 'url') as $prop) {
42 if (empty($this->{$prop})) {
43 $this->markTestSkipped("Failed to lookup SOAP URL, user, or password. Have you configured `cv` for testing?");
49 * Send a request with bad credentials.
51 * @expectedException SoapFault
53 public function testAuthenticationBadPassword() {
54 $client = $this->createClient();
55 $client->authenticate($this->adminUser
, mt_rand());
59 * Send a request with bad credentials.
61 * @expectedException SoapFault
63 public function testAuthenticationBadKey() {
64 $client = $this->createClient();
65 $key = $client->authenticate($this->adminUser
, $this->adminPass
);
66 $client->get_contact(mt_rand(), array());
70 * A basic test for one SOAP function.
72 public function testGetContact() {
73 $client = $this->createClient();
74 $key = $client->authenticate($this->adminUser
, $this->adminPass
);
75 $contacts = $client->get_contact($key, array(
77 'return.display_name' => 1,
79 $this->assertEquals($contacts['is_error'], 0);
80 $this->assertEquals($contacts['count'], 1);
81 $this->assertEquals($contacts['values'][101]['contact_id'], 101);
87 protected function createClient() {
88 return new SoapClient(NULL, array(
89 'location' => $this->url
,
90 'uri' => 'urn:civicrm',