public function setUp() { $config = (include './config/module.config.php'); $config = $config['ZfcDatagrid']; $cacheOptions = new \Zend\Cache\Storage\Adapter\MemoryOptions(); $config['cache']['adapter']['name'] = 'Memory'; $config['cache']['adapter']['options'] = $cacheOptions->toArray(); $this->config = $config; $mvcEvent = $this->getMock('Zend\\Mvc\\MvcEvent'); $mvcEvent->expects($this->any())->method('getRequest')->will($this->returnValue($this->getMock('Zend\\Http\\PhpEnvironment\\Request'))); $serviceLocator = $this->getMock('Zend\\ServiceManager\\ServiceManager'); $this->grid = new Datagrid(); $this->grid->setOptions($this->config); $this->grid->setMvcEvent($mvcEvent); $this->grid->setServiceLocator($serviceLocator); }
public function createService(ServiceLocatorInterface $sm) { $config = $sm->get('config'); if (!isset($config['ZfcDatagrid'])) { throw new InvalidArgumentException('Config key "ZfcDatagrid" is missing'); } /* @var $application \Zend\Mvc\Application */ $application = $sm->get('application'); $grid = new Datagrid(); $grid->setOptions($config['ZfcDatagrid']); $grid->setMvcEvent($application->getMvcEvent()); if ($sm->has('translator') === true) { $grid->setTranslator($sm->get('translator')); } $grid->init(); return $grid; }