Пример #1
0
 /**
  * @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
 /**
  * @param string $websiteId
  * @param $publishConfig
  * @return string config as JSON
  */
 protected function getPublishDataFromPublishConfig($websiteId, $publishConfig)
 {
     return SbJson::encode($publishConfig);
 }
Пример #3
0
 /**
  * @param string $moduleDataDirectory
  * @param string $filename
  * @param mixed  $data
  *
  * @throws SbJson\JsonException
  * @throws \Exception
  */
 protected function storeJsonFile($moduleDataDirectory, $filename, $data)
 {
     $dataJson = SbJson::prettyPrint(SbJson::encode($data));
     $this->setFileContent($moduleDataDirectory, $filename, $dataJson);
 }
Пример #4
0
 /**
  * @test
  * @group library
  * @dataProvider decodeSuccessProvider
  */
 public function decodeSuccess($value, $expectedResult, $type)
 {
     $actualResult = SbJson::decode($value, $type);
     $this->assertEquals($expectedResult, $actualResult);
 }
Пример #5
0
 /**
  * @test
  * @group library
  */
 public function getAllShouldRetrieveExpectedModules()
 {
     $sortedIndex = array(1, 2, 0);
     /** @var \Cms\Data\Modul[] $creates */
     $creates = array();
     $newModule = new DataModule();
     $newModule->setName(__METHOD__ . '_3');
     $newModule->setDescription('TEST_DESCRIPTION_GET_ALL_3');
     $newModule->setVersion('TEST_VERSION_GET_ALL_3');
     $newModule->setIcon('TEST_ICON_GET_ALL_3');
     $newModule->setForm(array());
     $newModule->setFormvalues(SbJson::decode(SbJson::encode(array('foo' => 'bar'))));
     $newModule->setCategory('TEST_CATEGORY_GET_ALL_3');
     $newModule->setModuletype('default');
     $newModule->setAllowedchildmoduletype('extension');
     $creates[] = $newModule;
     $newModule = new DataModule();
     $newModule->setName(__METHOD__ . '_1');
     $newModule->setDescription('TEST_DESCRIPTION_GET_ALL_1');
     $newModule->setVersion('TEST_VERSION_GET_ALL_1');
     $newModule->setIcon('TEST_ICON_GET_ALL_1');
     $newModule->setForm(SbJson::decode(SbJson::encode(array(array('id' => 'abcdefg', 'name' => 'Titel und Beschreibung')))));
     $newModule->setFormvalues(new \stdClass());
     $newModule->setCategory('TEST_CATEGORY_GET_ALL_1');
     $newModule->setModuletype('root');
     $newModule->setAllowedchildmoduletype('*');
     $creates[] = $newModule;
     $newModule = new DataModule();
     $newModule->setName(__METHOD__ . '_2');
     $newModule->setDescription('TEST_DESCRIPTION_GET_ALL_2');
     $newModule->setVersion('TEST_VERSION_GET_ALL_2');
     $newModule->setIcon('TEST_ICON_GET_ALL_2');
     $newModule->setForm(array());
     $newModule->setFormvalues(SbJson::decode(SbJson::encode(array('asdf' => 0))));
     $newModule->setCategory('TEST_CATEGORY_GET_ALL_2');
     $newModule->setModuletype('default');
     $newModule->setAllowedchildmoduletype('extension');
     $creates[] = $newModule;
     $moduleIds = array();
     foreach ($creates as $create) {
         $createdModul = $this->service->create($this->websiteId, $create);
         $moduleIds[] = $createdModul->getId();
     }
     /** @var \Cms\Data\Modul[] $modules */
     $modules = $this->service->getAll($this->websiteId);
     /** @var \Cms\Data\Modul[] $createdModules */
     $createdModules = array();
     foreach ($modules as $module) {
         if ($module->getName() === $creates[0]->getName() || $module->getName() === $creates[1]->getName() || $module->getName() === $creates[2]->getName()) {
             $createdModules[] = $module;
         }
     }
     foreach ($createdModules as $returnedIndex => $module) {
         $index = $sortedIndex[$returnedIndex];
         $this->assertInstanceOf('Cms\\Data\\Modul', $module);
         $this->assertSame($creates[$index]->getName(), $module->getName());
         $this->assertSame($creates[$index]->getDescription(), $module->getDescription());
         $this->assertSame($creates[$index]->getVersion(), $module->getVersion());
         $this->assertSame($creates[$index]->getIcon(), $module->getIcon());
         $this->assertEquals($creates[$index]->getForm(), $module->getForm());
         $this->assertEquals($creates[$index]->getFormvalues(), $module->getFormvalues());
         $this->assertSame($creates[$index]->getCategory(), $module->getCategory());
         $this->assertSame($creates[$index]->getModuletype(), $module->getModuletype());
         $this->assertSame($creates[$index]->getAllowedchildmoduletype(), $module->getAllowedchildmoduletype());
         $uuidValidator = new UniqueIdValidator(\Orm\Data\Modul::ID_PREFIX, \Orm\Data\Modul::ID_SUFFIX);
         $this->assertTrue($uuidValidator->isValid($module->getId()));
     }
 }
Пример #6
0
 private function writePublisherStatusToCache($websiteId, $buildId, PublisherStatusData $publishedStatus)
 {
     $publishedInfoFilePath = $this->getPublisherStatusCacheFilePath($websiteId, $buildId);
     FS::writeContentToFile($publishedInfoFilePath, SbJson::encode($publishedStatus->toArray()));
 }