Example #1
0
 /**
  * Get Instance Config From Entity
  *
  * @param PluginInstance $pluginInstance
  *
  * @return array
  */
 protected function getInstanceConfigFromEntity(PluginInstance $pluginInstance)
 {
     //Instance configs less than 0 are default instanc configs
     if ($pluginInstance->getInstanceId() < 0) {
         return $this->getDefaultInstanceConfig($pluginInstance->getPlugin());
     } else {
         $instanceConfig = $pluginInstance->getInstanceConfig();
         if (!is_array($instanceConfig)) {
             $instanceConfig = [];
         }
         //Merge the default and db instance configs. Db overwrites.
         $instanceConfig = $this->mergeConfigArrays($this->getDefaultInstanceConfig($pluginInstance->getPlugin()), $instanceConfig);
     }
     return $instanceConfig;
 }
Example #2
0
 public function testUtilities()
 {
     $data = $this->getTestData();
     $obj1 = new PluginInstance();
     $obj1->populate($data);
     $this->assertEquals($data['plugin'], $obj1->getPlugin());
     $this->assertEquals($data['siteWide'], $obj1->isSiteWide());
     $this->assertEquals($data['displayName'], $obj1->getDisplayName());
     $this->assertEquals($data['instanceConfig'], $obj1->getInstanceConfig());
     $this->assertEquals($data['md5'], $obj1->getMd5());
     $this->assertEquals($data['previousInstance']->getInstanceId(), $obj1->getPreviousInstance());
     $this->assertEquals($data['renderedCss'], $obj1->getRenderedCss());
     $this->assertEquals($data['renderedJs'], $obj1->getRenderedJs());
     $this->assertEquals($data['renderedHtml'], $obj1->getRenderedHtml());
     $this->assertEquals($data['canCache'], $obj1->getCanCache());
     $this->assertEquals($data['editCss'], $obj1->getEditCss());
     $this->assertEquals($data['editJs'], $obj1->getEditJs());
     $this->assertEquals($data['icon'], $obj1->getIcon());
     $this->assertEquals($data['tooltip'], $obj1->getTooltip());
     $data['saveData'] = ['testSave' => 'saveData'];
     $obj1->populate($data);
     $this->assertEquals($data['saveData'], $obj1->getInstanceConfig());
     $this->assertEquals(md5(serialize($data['saveData'])), $obj1->getMd5());
     // sync the data back up
     $data['md5'] = $obj1->getMd5();
     $data['instanceConfig'] = $obj1->getInstanceConfig();
     $json = json_encode($obj1);
     $this->assertJson($json);
     $iterator = $obj1->getIterator();
     $this->assertInstanceOf('\\ArrayIterator', $iterator);
     $array = $obj1->toArray();
     $this->assertEquals($data['plugin'], $array['plugin']);
     $this->assertEquals($data['siteWide'], $array['siteWide']);
     $this->assertEquals($data['displayName'], $array['displayName']);
     // @todo this breaks in travis?
     // $this->assertEquals($data['instanceConfig'], $array['instanceConfig']);
     $this->assertEquals($data['md5'], $array['md5']);
     $this->assertEquals($data['renderedCss'], $array['renderedCss']);
     $this->assertEquals($data['renderedJs'], $array['renderedJs']);
     $this->assertEquals($data['renderedHtml'], $array['renderedHtml']);
     $this->assertEquals($data['canCache'], $array['canCache']);
     $this->assertEquals($data['editCss'], $array['editCss']);
     $this->assertEquals($data['editJs'], $array['editJs']);
     $this->assertEquals($data['icon'], $array['icon']);
     $this->assertEquals($data['tooltip'], $array['tooltip']);
 }