public function testGivenArrayOfData()
 {
     $data = array('name' => 'Qwijibo');
     $repository = $this->getMockBuilder('\\ChartBlocks\\Repository\\Chart')->disableOriginalConstructor()->getMock();
     $this->client->expects($this->once())->method('getRepository')->with('Chart')->will($this->returnValue($repository));
     $factory = new EntityFactory($this->client);
     $result = $factory->createInstanceOf('Chart', $data);
     $this->assertInstanceOf('\\ChartBlocks\\Entity\\Chart', $result);
     $this->assertEquals($data['name'], $result->name);
 }
Пример #2
0
 /**
  * 
  * @param string $class
  * @param string $repository
  * @param mixed $object
  * @return \ChartBlocks\Entity\EntityInterface
  * @throws Exception
  */
 public function createInstanceOf($entityName, $object)
 {
     $class = '\\ChartBlocks\\Entity\\' . $entityName;
     if ($object instanceof $class) {
         return $object;
     }
     if (false === class_exists($class)) {
         throw new \InvalidArgumentException("{$class} not found");
     }
     if (is_array($object)) {
         $repo = $this->client->getRepository($entityName);
         return new $class($repo, $object);
     }
     throw new Exception("Invalid object for creating {$class}");
 }
Пример #3
0
 public function testGetHttpClient()
 {
     $client = new Client();
     $this->assertInstanceOf('\\Guzzle\\Http\\Client', $client->getHttpClient());
 }