public function testCreateDescription()
 {
     $factory = new ServiceDescriptionFactory($this->createServiceRegistry(), 'My.namespace');
     $d = $factory->createServiceDescription('https://example.com/router');
     $this->assertEquals('https://example.com/router', $d->getUrl());
     $this->assertEquals('My.namespace', $d->getNamespace());
     $this->assertEquals('remoting', $d->getType());
     $this->assertCount(2, $d->getActions());
     $this->assertJsonStringEqualsJsonString(json_encode(array('type' => 'remoting', 'url' => 'https://example.com/router', 'namespace' => 'My.namespace', 'actions' => array('TQ.ExtDirect.Tests.Description.Services.Service1' => array(array('name' => 'methodA', 'len' => 0), array('name' => 'methodB', 'formHandler' => true), array('name' => 'methodC', 'len' => 1), array('name' => 'methodD', 'len' => 1), array('name' => 'methodE', 'len' => 1), array('name' => 'methodF', 'len' => 1)), 'TQ.ExtDirect.Tests.Description.Services.Service4' => array(array('name' => 'methodA', 'len' => 0), array('name' => 'methodB', 'formHandler' => true))))), json_encode($d));
 }
Example #2
0
 /**
  * @param string $url
  * @param string $format
  * @return ServiceDescriptionResponse
  */
 public function createServiceDescription($url, $format = 'js')
 {
     $serviceDescription = $this->descriptionFactory->createServiceDescription($url);
     if ($format == 'json') {
         $response = JsonResponse::create($serviceDescription);
     } else {
         $response = new ServiceDescriptionResponse($serviceDescription, $this->getDescriptor());
     }
     if ($this->debug) {
         $response->setEncodingOptions(JSON_PRETTY_PRINT);
     }
     return $response;
 }