public function testCallMethod()
 {
     $managerName = 'fooManager';
     $methodName = 'fooMethod';
     $params = array('foo' => 'bar');
     $changeState = true;
     $payload = $this->getMock('InoPerunApi\\Client\\Payload');
     $response = $this->createResponseMock();
     $response->expects($this->once())->method('getPayload')->will($this->returnValue($payload));
     $client = $this->createClientMock();
     $client->expects($this->once())->method('sendRequest')->with($managerName, $methodName, $params, $changeState)->will($this->returnValue($response));
     $this->manager->setClient($client);
     $entity = $this->getMock('InoPerunApi\\Entity\\EntityInterface');
     $entityFactory = $this->getMock('InoPerunApi\\Entity\\Factory\\FactoryInterface');
     $entityFactory->expects($this->once())->method('createFromResponsePayload')->with($payload)->will($this->returnValue($entity));
     $this->manager->setEntityFactory($entityFactory);
     $this->manager->setManagerName($managerName);
     $entity = $this->manager->callMethod($methodName, $params, $changeState);
 }
 /**
  * {@inheritdoc}
  * @see \InoPerunApi\Manager\Factory\FactoryInterface::createManager()
  */
 public function createManager($managerName, Client $client = null)
 {
     if (null === $client) {
         $client = $this->getClient();
     }
     if (!$this->isSupported($managerName)) {
         throw new Exception\UnsupportedManagerException(sprintf("Unsupported manager '%s'", $managerName));
     }
     $manager = new GenericManager($client);
     $manager->setManagerName($managerName);
     return $manager;
 }
Esempio n. 3
0
<?php

use InoPerunApi\Client\ClientFactory;
use InoPerunApi\Manager\GenericManager;
include __DIR__ . '/_common.php';
$config = (require __DIR__ . '/_client_config.php');
$clientFactory = new ClientFactory();
$client = $clientFactory->createClient($config);
$usersManager = new GenericManager($client);
$usersManager->setManagerName('usersManager');
/*
$user = $usersManager->callMethod('getRichUserWithAttributes', array(
    'user' => 13521
));
*/
$user = $usersManager->getRichUserWithAttributes(array('user' => 13521));
_dump($user);
<?php

use InoPerunApi\Client\ClientFactory;
use InoPerunApi\Entity\Group;
use InoPerunApi\Manager\GenericManager;
include __DIR__ . '/_common.php';
$config = (require __DIR__ . '/_client_config.php');
$clientFactory = new ClientFactory();
$client = $clientFactory->createClient($config);
$groupsManager = new GenericManager($client);
$groupsManager->setManagerName('groupsManager');
$group = new Group();
$group->setName('New test group 5');
$group->setParentGroupId(3141);
try {
    $newGroup = $groupsManager->createGroup(array('vo' => 421, 'group' => $group), true);
} catch (\Exception $e) {
    _dump("{$e}");
}
_dump($client->getHttpClient()->getLastRawRequest());
_dump($client->getHttpClient()->getLastRawResponse());
_dump($newGroup);