/**
  * {@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;
 }
 public function testParamsToArray()
 {
     $entityData1 = array('e1key1' => 'e1value1');
     $entity1 = $this->getMock('InoPerunApi\\Entity\\EntityInterface');
     $entity1->expects($this->once())->method('getProperties')->will($this->returnValue($entityData1));
     $entityData2 = array('e1key2' => 'e1value2');
     $entity2 = $this->getMock('InoPerunApi\\Entity\\EntityInterface');
     $entity2->expects($this->once())->method('getProperties')->will($this->returnValue($entityData2));
     $params = array('key1' => 'value1', 'key2' => 'value2', 'complex' => array('key3' => 'value3'), 'entity' => $entity1, 'collection' => array('embeddedEntity' => $entity2));
     $expected = array('key1' => 'value1', 'key2' => 'value2', 'complex' => array('key3' => 'value3'), 'entity' => $entityData1, 'collection' => array('embeddedEntity' => $entityData2));
     $this->assertSame($expected, $this->manager->paramsToArray($params));
 }
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);