3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
28 * Verify that the SOAP bindings correctly parse and authenticate requests.
31 class E2E_Extern_SoapTest
extends CiviEndToEndTestCase
{
36 var $url, $adminUser, $adminPass;
38 public function setUp() {
39 CRM_Core_Config
::singleton(1, 1);
42 $this->adminUser
= $_CV['ADMIN_USER'];
43 $this->adminPass
= $_CV['ADMIN_PASS'];
44 $this->url
= CRM_Core_Resources
::singleton()->getUrl('civicrm', 'extern/soap.php');
46 foreach (array('adminUser', 'adminPass', 'url') as $prop) {
47 if (empty($this->{$prop})) {
48 $this->markTestSkipped("Failed to lookup SOAP URL, user, or password. Have you configured `cv` for testing?");
54 * Send a request with bad credentials.
56 * @expectedException SoapFault
58 public function testAuthenticationBadPassword() {
59 $client = $this->createClient();
60 $client->authenticate($this->adminUser
, mt_rand());
64 * Send a request with bad credentials.
66 * @expectedException SoapFault
68 public function testAuthenticationBadKey() {
69 $client = $this->createClient();
70 $key = $client->authenticate($this->adminUser
, $this->adminPass
);
71 $client->get_contact(mt_rand(), array());
75 * A basic test for one SOAP function.
77 public function testGetContact() {
78 $client = $this->createClient();
79 $key = $client->authenticate($this->adminUser
, $this->adminPass
);
80 $contacts = $client->get_contact($key, array(
82 'return.display_name' => 1,
84 $this->assertEquals($contacts['is_error'], 0);
85 $this->assertEquals($contacts['count'], 1);
86 $this->assertEquals($contacts['values'][101]['contact_id'], 101);
92 protected function createClient() {
93 return new SoapClient(NULL, array(
94 'location' => $this->url
,
95 'uri' => 'urn:civicrm',