Example #1
0
 /**
  * Get chart data
  *
  * @param array $vars
  * @return DataInterface
  * @throws BadMethodCallException
  */
 protected function getData(array $vars)
 {
     if (null === $this->data) {
         throw new BadMethodCallException("Can't build result when setData() was not called.");
     }
     $result = $this->data;
     if (null !== $this->dataMapping) {
         $result = new MappedData($this->dataMapping, $result);
     }
     if (isset($vars['config']['data_transformer'])) {
         $transformer = $this->transformerFactory->createTransformer($vars['config']['data_transformer']);
         $result = $transformer->transform($result, $vars['options']);
     }
     return $result;
 }
 /**
  * @expectedException \Oro\Bundle\ChartBundle\Exception\InvalidArgumentException
  * @expectedMessage Service "transformer_service" must be an instance of
  * "Oro\Bundle\ChartBundle\Model\Data\Transformer\TransformerInterface".
  */
 public function testCreateTransformerFails()
 {
     $serviceId = 'transformer_service';
     $this->container->expects($this->once())->method('get')->with($serviceId)->will($this->returnValue(new \stdClass()));
     $this->factory->createTransformer($serviceId);
 }