Esempio n. 1
0
 public function testNameSm()
 {
     $definition = new Definition();
     $definition->setCallback(array());
     $definition->setNameSm('namesm');
     $this->assertEquals('namesm', $definition->getNameSm());
     $outArray = $definition->toArray();
     $this->assertArrayHasKey('nameSm', $outArray);
     $this->assertEquals('namesm', $outArray['nameSm']);
 }
Esempio n. 2
0
 public function testDispatch()
 {
     $mock = $this->getMockBuilder('stdClass')->setMethods(['uneMethode'])->getMock();
     $mock_sm = $this->getMockBuilder('Interop\\Container\\ContainerInterface')->disableOriginalConstructor()->setMethods(array('get', 'has'))->getMock();
     $mock_sm->expects($this->any())->method('get')->with('maclasse_sm')->will($this->returnValue($mock));
     $definition = new Definition();
     $definition->setNameSm('maclasse_sm');
     $definition->setCallback((new Callback())->setMethod('uneMethode'));
     $server = new Server($mock_sm, []);
     $out = $server->_dispatch($definition, array());
     $this->assertEquals($mock->uneMethode(), $out);
 }
Esempio n. 3
0
 /**
  * (non-PHPdoc).
  *
  * @see \Zend\Server\AbstractServer::_buildSignature()
  */
 protected function _buildSignature(Reflection\AbstractFunction $reflection, $class = null)
 {
     $ns = $reflection->getNamespace();
     $name = $reflection->getName();
     $shortName = $reflection->getDeclaringClass()->getShortName();
     $method = empty($ns) ? strtolower($shortName) . '.' . $name : $ns . '.' . $name;
     // Ignore Because copy to parent::_buildSignature
     // @codeCoverageIgnoreStart
     if (!$this->overwriteExistingMethods && $this->table->hasMethod($method)) {
         throw new Exception\RuntimeException('Duplicate method registered: ' . $method);
     }
     // @codeCoverageIgnoreEnd
     $definition = new Method\Definition();
     $definition->setName($method)->setCallback($this->_buildCallback($reflection))->setMethodHelp($reflection->getDescription())->setInvokeArguments($reflection->getInvokeArguments());
     foreach ($reflection->getPrototypes() as $proto) {
         $prototype = new Prototype();
         $prototype->setReturnType($this->_fixType($proto->getReturnType()));
         foreach ($proto->getParameters() as $parameter) {
             $param = new Parameter(array('type' => $this->_fixType($parameter->getType()), 'name' => $parameter->getName(), 'optional' => $parameter->isOptional()));
             // Ignore Because copy to parent::_buildSignature
             // @codeCoverageIgnoreStart
             if ($parameter->isDefaultValueAvailable()) {
                 $param->setDefaultValue($parameter->getDefaultValue());
             }
             // @codeCoverageIgnoreEnd
             $prototype->addParameter($param);
         }
         $definition->addPrototype($prototype);
     }
     if (is_object($class)) {
         // Ignore Because copy to parent::_buildSignature
         // @codeCoverageIgnoreStart
         $definition->setObject($class);
         // @codeCoverageIgnoreEnd
     } elseif ($this->container->has($class)) {
         $definition->setNameSm($class);
     }
     $this->table->addMethod($definition);
     return $definition;
 }