コード例 #1
0
ファイル: CreateTest.php プロジェクト: rukzuk/rukzuk
 /**
  * @test
  * @group library
  */
 public function createShouldStoreExpectedModule()
 {
     // ARRANGE
     $moduleCountBefore = count($this->service->getAll($this->websiteId));
     $create = new DataModul();
     $create->setName(__METHOD__ . '_1');
     $create->setDescription('TEST_DESCRIPTION_CREATE_1');
     $create->setVersion('TEST_VERSION_CREATE_1');
     $create->setIcon('TEST_ICON_CREATE_1');
     $create->setForm(SbJson::decode(SbJson::encode(array(array('name' => 'Titel und Beschreibung', 'formGroupData' => array('params' => array('name' => 'Cmsvar', 'value' => 'title')))))));
     $create->setFormvalues(SbJson::decode(SbJson::encode(array(array('key' => 'value')))));
     $create->setCategory('TEST_CATEGORY_CREATE_1');
     $create->setModuletype('root');
     $create->setAllowedchildmoduletype('extension');
     $create->setRerenderrequired('rerenderrequired');
     // ACT
     $createdModul = $this->service->create($this->websiteId, $create);
     // ASSERT
     $modules = $this->service->getAll($this->websiteId);
     $this->assertTrue(count($modules) > $moduleCountBefore);
     /** @var \Cms\Data\Modul[] $modules */
     foreach ($modules as $module) {
         if ($module->getName() === $create->getName()) {
             $createdModule = $module;
         }
     }
     $this->assertInstanceOf('Cms\\Data\\Modul', $createdModule);
     $this->assertEquals($create->getName(), $createdModule->getName());
     $this->assertEquals($this->websiteId, $createdModule->getWebsiteId());
     $this->assertEquals($create->getDescription(), $createdModule->getDescription());
     $this->assertEquals($create->getVersion(), $createdModule->getVersion());
     $this->assertEquals($create->getIcon(), $createdModule->getIcon());
     $this->assertEquals($create->getForm(), $createdModule->getForm());
     $this->assertEquals($create->getFormvalues(), $createdModule->getFormvalues());
     $this->assertEquals($create->getCategory(), $createdModule->getCategory());
     $this->assertEquals($create->getModuletype(), $createdModule->getModuletype());
     $this->assertEquals($create->getAllowedchildmoduletype(), $createdModule->getAllowedchildmoduletype());
     $this->assertEquals($create->getRerenderrequired(), $createdModule->getReRenderRequired());
     // Timestamp der letzten Aenderung darf nicht aelter sein als ein paar Sekunden
     $this->assertNotNull($createdModule->getLastupdate());
     $maxAlter = date('Y-m-d H:i:s', time() - 2);
     $this->assertGreaterThan($maxAlter, $createdModule->getLastupdate());
     $uuidValidator = new UniqueIdValidator(\Orm\Data\Modul::ID_PREFIX, \Orm\Data\Modul::ID_SUFFIX);
     $this->assertTrue($uuidValidator->isValid($createdModule->getId()));
     // this call throws exception on error occured
     $this->service->getAssetsPath($this->websiteId, $createdModule->getId());
 }
コード例 #2
0
ファイル: GetByIdTest.php プロジェクト: rukzuk/rukzuk
 /**
  * @test
  * @group library
  */
 public function test_getById_success()
 {
     // ARRANGE
     $dao = $this->createModuleDao();
     $sources = $this->getModuleSourceItemsFromGlobalSetAndPackage('module_test', 'rz_testing');
     $moduleSource = new ModuleSource($this->websiteId, $sources);
     $expectedModuleId = 'rz_tests_module_only_global';
     $expectedModule = new DataModule();
     $expectedModule->setSourceType(DataModule::SOURCE_REPOSITORY);
     $expectedModule->setOverwritten(false);
     $expectedModule->setId($expectedModuleId);
     $expectedModule->setName('this is the name: rz_tests_module_only_global (global)');
     $expectedModule->setDescription('');
     $expectedModule->setVersion('test');
     $expectedModule->setIcon('application.png');
     $expectedModule->setCategory('{"de":"Default Module","en":"Default Modules"}');
     $expectedModule->setModuletype('default');
     $expectedModule->setAllowedchildmoduletype('*');
     $expectedModule->setRerenderrequired(true);
     $expectedModule->setApiType('APIv1');
     $expectedModule->setSessionRequired(true);
     // ACT
     $module = $dao->getById($moduleSource, $expectedModuleId);
     // ASSERT
     $this->assertSame($expectedModule->getId(), $module->getId());
     $this->assertSame($expectedModule->getSourceType(), $module->getSourceType());
     $this->assertSame($expectedModule->isOverwritten(), $module->isOverwritten());
     $this->assertSame($expectedModule->getName(), $module->getName());
     $this->assertSame($expectedModule->getDescription(), $module->getDescription());
     $this->assertSame($expectedModule->getVersion(), $module->getVersion());
     $this->assertSame($expectedModule->getIcon(), $module->getIcon());
     $this->assertSame($expectedModule->getCategory(), $module->getCategory());
     $this->assertSame($expectedModule->getModuletype(), $module->getModuletype());
     $this->assertSame($expectedModule->getAllowedchildmoduletype(), $module->getAllowedchildmoduletype());
     $this->assertSame($expectedModule->getRerenderrequired(), $module->getRerenderrequired());
     $this->assertSame($expectedModule->getApiType(), $module->getApiType());
     $this->assertSame($expectedModule->getSessionRequired(), $module->getSessionRequired());
 }
コード例 #3
0
ファイル: Filesystem.php プロジェクト: rukzuk/rukzuk
 /**
  * @param string     $websiteId
  * @param string     $moduleId
  * @param SourceItem $sourceItem
  * @param \stdClass  $moduleManifest
  * @param \stdClass  $moduleForm
  * @param \stdClass  $moduleCustomData
  * @param integer    $moduleLastUpdate
  *
  * @return DataModule
  */
 protected function loadDataObject($websiteId, $moduleId, SourceItem $sourceItem, $moduleManifest, $moduleForm, $moduleCustomData, $moduleLastUpdate)
 {
     $module = new DataModule();
     $module->setId($moduleId);
     $module->setWebsiteid($websiteId);
     $module->setCustomData($moduleCustomData);
     $module->setLastUpdate($moduleLastUpdate);
     $module->setSource($sourceItem);
     $module->setSourceType($sourceItem->getType());
     $module->setOverwritten($sourceItem->isOverwritten());
     if (property_exists($moduleManifest, 'name')) {
         $module->setName($moduleManifest->name);
     }
     if (property_exists($moduleManifest, 'description')) {
         $module->setDescription($moduleManifest->description);
     }
     if (property_exists($moduleManifest, 'version')) {
         $module->setVersion($moduleManifest->version);
     }
     if (property_exists($moduleManifest, 'icon')) {
         $module->setIcon($moduleManifest->icon);
     }
     if (property_exists($moduleManifest, 'category')) {
         $module->setCategory($moduleManifest->category);
     }
     if (property_exists($moduleManifest, 'moduleType')) {
         $module->setModuletype($moduleManifest->moduleType);
     }
     if (property_exists($moduleManifest, 'allowedChildModuleType')) {
         $module->setAllowedchildmoduletype($moduleManifest->allowedChildModuleType);
     }
     if (property_exists($moduleManifest, 'reRenderRequired')) {
         $module->setRerenderrequired($moduleManifest->reRenderRequired);
     }
     if (property_exists($moduleManifest, 'ghostContainerMode')) {
         $module->setGhostContainerMode($moduleManifest->ghostContainerMode);
     }
     if (property_exists($moduleForm, 'form')) {
         $module->setForm($moduleForm->form);
     }
     if (property_exists($moduleForm, 'formValues')) {
         $module->setFormvalues($moduleForm->formValues);
     }
     if (property_exists($moduleManifest, 'apiType')) {
         $module->setApiType($moduleManifest->apiType);
     }
     if (property_exists($moduleManifest, 'sessionRequired')) {
         $module->setSessionRequired($moduleManifest->{'sessionRequired'});
     }
     return $module;
 }
コード例 #4
0
ファイル: Import.php プロジェクト: rukzuk/rukzuk
 /**
  * @param  \Cms\Service\Modul $moduleService
  * @param  string             $moduleId
  * @param  string             $websiteId
  * @param  string             $moduleJsonFilePath
  *
  * @return DataModule
  */
 private function createOrOverwriteModuleFromModuleJson($moduleService, $moduleId, $websiteId, $moduleJsonFilePath)
 {
     $moduleJsonString = file_get_contents($moduleJsonFilePath);
     $this->cleaningColorIds($websiteId, $moduleJsonString);
     $moduleJson = json_decode($moduleJsonString);
     $moduleJsonArrayObject = new \ArrayObject($moduleJson);
     $moduleJsonValues = $moduleJsonArrayObject->getArrayCopy();
     if (version_compare($this->getImportVersion(), '1.3.0') < 0) {
         // insert namespace
         $namespaceCode = "<?php namespace Dual\\Render; ?>\n";
         $moduleJsonValues['renderer'] = $namespaceCode . $moduleJsonValues['renderer'];
         $moduleJsonValues['css'] = $namespaceCode . $moduleJsonValues['css'];
         $moduleJsonValues['header'] = $namespaceCode . $moduleJsonValues['header'];
     }
     $newModule = new DataModule();
     $newModule->setId($moduleId);
     $newModule->setName($moduleJsonValues['name']);
     $newModule->setDescription($moduleJsonValues['description']);
     $newModule->setCategory($moduleJsonValues['category']);
     $newModule->setVersion($moduleJsonValues['version']);
     $newModule->setIcon($moduleJsonValues['icon']);
     $newModule->setModuletype($moduleJsonValues['moduleType']);
     $newModule->setAllowedchildmoduletype($moduleJsonValues['allowedChildModuleType']);
     if (isset($moduleJsonValues['form']) && is_string($moduleJsonValues['form'])) {
         $newModule->setForm(json_decode($moduleJsonValues['form']));
     } else {
         $newModule->setForm($moduleJsonValues['form']);
     }
     if (isset($moduleJsonValues['formValues']) && is_string($moduleJsonValues['formValues'])) {
         $newModule->setFormvalues(json_decode($moduleJsonValues['formValues']));
     } else {
         $newModule->setFormvalues($moduleJsonValues['formValues']);
     }
     if (isset($moduleJsonValues['reRenderRequired'])) {
         $newModule->setRerenderrequired($moduleJsonValues['reRenderRequired']);
     }
     if (isset($moduleJsonValues['customData'])) {
         $newModule->setCustomData($moduleJsonValues['customData']);
     }
     if (isset($moduleJsonValues['apiType'])) {
         $newModule->setApiType($moduleJsonValues['apiType']);
     }
     if (isset($moduleJsonValues['sessionRequired'])) {
         $newModule->setSessionRequired($moduleJsonValues['sessionRequired']);
     }
     $createdModule = $this->createOrOverwriteModule($moduleService, $websiteId, $newModule);
     $this->saveModuleLegacyCode($moduleService, $createdModule, array('css' => $moduleJsonValues['css'], 'renderer' => $moduleJsonValues['renderer'], 'header' => $moduleJsonValues['header']));
     return $createdModule;
 }