/** * get dynamic field without skin instance * * @param string $group config group name * @param string $id field type id * @return AbstractType */ public function getType($group, $id) { $config = $this->configHandler->get($group, $id); if ($config == null) { return null; } $type = $this->registerHandler->getType($this, $config->get('typeId')); $type->setConfig($config); return $type; }
/** * test orders * * @return void */ public function testOrders() { $handler = $this->handler; $proxy = m::mock('Xpressengine\\DynamicField\\DatabaseProxy', [$handler])->shouldAllowMockingProtectedMethods()->makePartial(); $config = $this->getConfigEntity(); $config->shouldReceive('get')->with('typeId')->andReturn('id'); $config->shouldReceive('get')->with('use')->andReturn(true); $query = m::mock('Illuminate\\Database\\Query\\Builder'); $type = m::mock('Type', 'Xpressengine\\DynamicField\\AbstractType'); $type->shouldReceive('setConfig'); $type->shouldReceive('orders')->andReturn($query); $this->configHandler->shouldReceive('gets')->andReturn([$config]); $this->registerHandler->shouldReceive('getType')->andReturn($type); $result = $proxy->orders($query, []); $this->assertInstanceOf('Illuminate\\Database\\Query\\Builder', $result); }
/** * test get skins by type * * @return void */ public function testGetSkinsByType() { $pluginRegister = $this->pluginRegister; $handler = new RegisterHandler($pluginRegister); $dfHandler = m::mock('Xpressengine\\DynamicField\\DynamicFieldHandler'); $id = 'id'; $skin = m::mock('SkinClass'); $skin->shouldReceive('__construct'); $skins = [$skin]; $pluginRegister->shouldReceive('get')->andReturn($skins); $result = $handler->getSkinsByType($dfHandler, $id); $this->assertInstanceOf('Generator', $result); }