source: sipes/modules_contrib/soap_server/soap_server.test @ ca33cb0

stableversion-3.0
Last change on this file since ca33cb0 was 3959b2a, checked in by planificacion <planificacion@…>, 8 años ago

Se agregaron los modulos para permitir el despliegue de servicios web (SOAP)

  • Propiedad mode establecida a 100644
File size: 2.9 KB
Línea 
1<?php
2// $Id: soap_server.test,v 1.1.2.1 2011/01/22 03:34:04 ilo Exp $
3
4/**
5 * @file
6 * Simpletest case for soap_server module.
7 *
8 * Verify SOAP server provides valid WSDL file and handles requests properly.
9 */
10
11/**
12 * Functionality tests for email example module.
13 */
14class SoapServerTestCase extends DrupalWebTestCase {
15
16  /**
17   * Save endpoint settings for testing.
18   *
19   * @var array
20   */
21  protected $endpoint;
22
23  public static function getInfo() {
24    return array(
25      'name' => 'Soap Server',
26      'description' => 'Verify Soap server implementation.',
27      'group' => 'Services',
28      'dependencies'
29    );
30  }
31
32  function setUp(){
33    // Enable soap_server should enable also services.
34    parent::setUp(array('ctools', 'services', 'soap_server'));
35
36    // Login as services administrator.
37    $user = $this->drupalCreateUser(array('administer services'));
38    $this->drupalLogin($user);
39
40    // Create a SOAP endpoint.
41    $this->endpoint = array(
42      'name'   => 'soap_server_test_endpoint',
43      'title'  => $this->randomName(),
44      'server' => 'soap_server',
45      'path'   => 'services/soap/simpletest',
46      'services_use_content_permissions' => TRUE,
47    );
48    $this->drupalPost(
49      'admin/build/services/add',
50      $this->endpoint,
51      t('Save and proceed')
52    );
53    $this->assertRaw(t('Your new endpoint %title has been saved.', array('%title' => $this->endpoint['title'])));
54
55    // Enable system resources
56    $resources = array(
57      'resources[system][actions][connect][enabled]'       => TRUE,
58      'resources[system][actions][get_variable][enabled]'  => TRUE,
59      'resources[system][actions][set_variable][enabled]'  => TRUE,
60    );
61    $this->drupalPost(
62      'admin/build/services/' . $this->endpoint['name'] . '/resources',
63      $resources,
64      t('Save')
65    );
66    $this->assertRaw(t('Your resources have been saved.'));
67
68  }
69
70  /**
71   * Verify WSDL generation.
72   */
73//  function testWSDLGeneration() {
74//  }
75
76  /**
77   * Verify SOAP server handler.
78   */
79  function testSOAPHandler() {
80    $wsdl_url = url($this->endpoint['path'], array('absolute' => TRUE)) . '?wsdl';
81
82    // exceptions will not work in this context.
83    $options = array('trace' => 1, 'exceptions' => TRUE);
84    if (preg_match('/simpletest\d+/', $this->databasePrefix, $matches)) {
85      $options += array('user_agent' => drupal_generate_test_ua($matches[0]));
86    }
87    $client = new SoapClient($wsdl_url, $options);
88    $result = $client->__getFunctions();
89
90    if (is_soap_fault($result)) {
91      $this->fail('Return service available functions.');
92    }
93    else {
94      $this->assertTrue(strstr($result[0], 'system_connect') , t('System connect method found.'));
95      $this->assertTrue(strstr($result[1], 'system_get_variable') , t('System get_variable method found.'));
96      $this->assertTrue(strstr($result[2], 'system_set_variable') , t('System set_variable method found.'));
97    }
98
99  }
100
101}
102
103
104
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.