Esempio n. 1
0
 public function testTwoValidBindingAnnotationsIsOk()
 {
     $instance = new TwoValidBindingAnnotations();
     $reader = new SCA_AnnotationReader($instance);
     $service_description = $reader->reflectService();
     $this->assertContains("soap", $service_description->binding);
     $this->assertContains("jsonrpc", $service_description->binding);
 }
Esempio n. 2
0
 public function testAPublicMethodWithNoAnnotationsHasEmptyParametersAndReturn()
 {
     $instance = new MethodHasNoAnnotations();
     $reader = new SCA_AnnotationReader($instance);
     $service_description = $reader->reflectService();
     $this->assertTrue(key_exists('myPublicMethod', $service_description->operations));
     $op_array = $service_description->operations;
     $method = $op_array['myPublicMethod'];
     $this->assertEquals(array('parameters' => array(), 'return' => null), $method);
 }
Esempio n. 3
0
 public function testReturnWithChoiceOfValidTypeOrNullIsValid()
 {
     $instance = new ReturnWithChoiceOfValidTypeOrNull();
     $reader = new SCA_AnnotationReader($instance);
     $service_description = $reader->reflectService();
     $this->assertTrue(key_exists('myPublicMethod', $service_description->operations));
     $op_array = $service_description->operations;
     $method = $op_array['myPublicMethod'];
     $return_array = $method['return'];
     $this->assertEquals(array(0 => array('annotationType' => '@return', 'type' => 'string', 'nillable' => true)), $return_array);
 }
Esempio n. 4
0
 public function testServiceWithInvalidInterfaces()
 {
     try {
         $instance = new ServiceWithInvalidInterface();
         $reader = new SCA_AnnotationReader($instance);
         $service_description = $reader->reflectService();
     } catch (SCA_RuntimeException $e) {
         $this->assertContains('Service interface', $e->getMessage());
         $this->assertContains('specified by @service does not match any interface implemented by', $e->getMessage());
         return;
     }
     $this->fail();
 }
Esempio n. 5
0
 public function testReturnWithInvalidNamespaceIsInvalid()
 {
     try {
         $instance = new ReturnWithInvalidNamespace();
         $reader = new SCA_AnnotationReader($instance);
         $service_description = $reader->reflectService();
     } catch (SCA_RuntimeException $e) {
         $this->assertContains("return", $e->getMessage());
         $this->assertContains("Namespace", $e->getMessage());
         return;
     }
     $this->fail();
 }
Esempio n. 6
0
 public function testTabsAndSpacesAreOk()
 {
     $instance = new TabsAndSpaces();
     $reader = new SCA_AnnotationReader($instance);
     $service_description = $reader->reflectService();
     $this->assertTrue(key_exists('spaces', $service_description->operations));
     $this->assertTrue(key_exists('tabs', $service_description->operations));
     $spaces_op = $service_description->operations['spaces'];
     $parm = $spaces_op['parameters'][0];
     $this->assertEquals(array('annotationType' => '@param', 'nillable' => false, 'description' => 'the ticker symbol', 'name' => 'ticker', 'type' => 'string'), $parm);
     $tabs_op = $service_description->operations['tabs'];
     $parm = $tabs_op['parameters'][0];
     $this->assertEquals(array('annotationType' => '@param', 'nillable' => false, 'description' => 'the ticker symbol', 'name' => 'ticker', 'type' => 'string'), $parm);
     $references = $reader->reflectReferences();
     $this->assertEquals(array('spaces' => 'spaces.php', 'tabs' => 'tabs.wsdl'), $references);
 }
Esempio n. 7
0
 /**
  * Get parameters for method
  *
  * @param string $method_name Method name
  *
  * @return array
  */
 public function getParametersForMethod($method_name)
 {
     $reader = new SCA_AnnotationReader($this->class_instance);
     $service_description = $reader->reflectService();
     $operations = $service_description->operations;
     if (!array_key_exists($method_name, $operations)) {
         throw new SCA_MethodNotAllowedException("Method not allowed.");
     }
     return $service_description->operations[$method_name]["parameters"];
 }
Esempio n. 8
0
File: SCA.php Progetto: psagi/sdo
 /**
  * Create an array containing the service descriptions from the annotations
  * found in the class file.
  *
  * @param string $class_file Class file containing the service annotations
  *
  * @return object The service description object
  * @throws SCA_RuntimeException ... when things go wrong
  */
 public static function constructServiceDescription($class_file)
 {
     $class_name = SCA_Helper::guessClassName($class_file);
     if (!class_exists($class_name, false)) {
         // The code analyzer marks the following include with a variable name as
         // unsafe. It is safe, however as the class file name can only come from
         // a getService call or an annotation.
         include "{$class_file}";
     }
     if (class_exists($class_name, false)) {
         $instance = new $class_name();
         $reader = new SCA_AnnotationReader($instance);
         $service_description = $reader->reflectService();
         $service_description->class_name = $class_name;
         $service_description->realpath = realpath($class_file);
         $service_description->targetnamespace = "http://{$class_name}";
     } else {
         throw new SCA_RuntimeException("Invalid Classname: {$class_name}");
     }
     return $service_description;
 }
Esempio n. 9
0
 /**
  * Determine parameters for method
  *
  * @param string $method_name method to call
  *
  * @return mixed
  */
 public function getParametersForMethod($method_name)
 {
     $reader = new SCA_AnnotationReader($this->instance_of_the_base_class);
     $service_description = $reader->reflectService();
     //$this->atomservicewrapperlog->log("SCA_ServiceWrapperAtom::__call() - what does the service desc eval look like when method_name is $method_name ?...".$service_description["operations"][$method_name]."\n");
     //$this->atomservicewrapperlog->log("SCA_ServiceWrapperAtom::__call() - what does the service_desc look like?".print_r($service_description, true)."\n");
     $operations = $service_description->operations;
     if (!array_key_exists($method_name, $operations)) {
         throw new SCA_MethodNotAllowedException("Method not allowed.");
     }
     return $service_description->operations[$method_name]["parameters"];
 }
Esempio n. 10
0
 /**
  * Determine parameters for method
  *
  * @param string $method_name method to call
  *
  * @return mixed
  */
 public function getParametersForMethod($method_name)
 {
     $reader = new SCA_AnnotationReader($this->instance_of_the_base_class);
     $service_description = $reader->reflectService();
     return $service_description->operations[$method_name]["parameters"];
 }