For example, posts are stored as .ini in the vpdb/posts folder. Note that the same file can be used by multiple entities. For example, both the main post data and postmeta for it are stored in the same INI file.
Inheritance: extends Storage
コード例 #1
0
 /**
  * @test
  */
 public function loadAllReturnsOnlyOriginalEntities()
 {
     $this->parentStorage->save($this->testingParentEntity);
     $this->storage->save($this->testingMetaEntity);
     $loadedPostMeta = $this->storage->loadAll();
     $this->assertTrue(count($loadedPostMeta) === 1);
     $this->assertEquals($this->testingMetaEntity, reset($loadedPostMeta));
 }
コード例 #2
0
 /**
  * @test
  */
 public function parentEntityDoesNotContainReferenceAfterItsDeleted()
 {
     $parent = ['vp_id' => '927D63C187164CA1BCEAB2B13B29C8F0', 'some_field' => 'some_value'];
     $mnReference = ['vp_some_entity' => '927D63C187164CA1BCEAB2B13B29C8F0', 'vp_other_entity' => 'F0E1B6313B7A48E49A1B38DF382B350D'];
     $this->parentStorage->save($parent);
     $this->storage->save($mnReference);
     $this->storage->delete($mnReference);
     $loadedParent = $this->parentStorage->loadEntity($mnReference['vp_some_entity']);
     $this->assertArrayNotHasKey('vp_other_entity', $loadedParent);
 }
コード例 #3
0
 private function deleteComment()
 {
     $this->storage->delete(EntityUtils::prepareComment(self::$vpId));
     $this->postStorage->delete(EntityUtils::preparePost(self::$postVpId));
     $this->userStorage->delete(EntityUtils::prepareUser(self::$authorVpId));
     return [['vp_id' => self::$authorVpId, 'parent' => self::$authorVpId], ['vp_id' => self::$postVpId, 'parent' => self::$postVpId], ['vp_id' => self::$vpId, 'parent' => self::$vpId]];
 }
コード例 #4
0
 /**
  * @test
  * @testdox Synchronizer replaces value references
  */
 public function synchronizerReplacesValueReferences()
 {
     $post = EntityUtils::preparePost();
     $optionToSynchronize = [['vp_id' => 'site_icon', 'parent' => null]];
     $postToSynchronize = [['vp_id' => $post['vp_id'], 'parent' => null]];
     $previousSiteIcon = $this->storage->exists('site_icon') ? $this->storage->loadEntity('site_icon') : '';
     $this->postStorage->save($post);
     $option = EntityUtils::prepareOption('site_icon', $post['vp_id']);
     $this->storage->save($option);
     $this->postsSynchronizer->synchronize(Synchronizer::SYNCHRONIZE_EVERYTHING, $postToSynchronize);
     $this->synchronizer->synchronize(Synchronizer::SYNCHRONIZE_EVERYTHING, $optionToSynchronize);
     DBAsserter::assertFilesEqualDatabase();
     // cleanup
     if ($previousSiteIcon) {
         if (!isset($previousSiteIcon['option_value'])) {
             $previousSiteIcon['option_value'] = false;
         }
         $this->storage->save($previousSiteIcon);
     } else {
         $this->storage->delete($option);
     }
     $this->postStorage->delete($post);
     $this->synchronizer->reset();
     $this->postsSynchronizer->reset();
     $this->synchronizer->synchronize(Synchronizer::SYNCHRONIZE_EVERYTHING, $optionToSynchronize);
     $this->postsSynchronizer->synchronize(Synchronizer::SYNCHRONIZE_EVERYTHING, $postToSynchronize);
 }
コード例 #5
0
 /**
  * Test covers part of for WP-428
  *
  * @test
  */
 public function vpidShouldBeReplaceableWithZero()
 {
     $updatedEntity = $this->testingEntity;
     $updatedEntity['vp_comment_post_ID'] = 0;
     $this->storage->save($this->testingEntity);
     $this->storage->save($updatedEntity);
     $loadedOption = $this->storage->loadEntity($updatedEntity['vp_id']);
     $this->assertEquals($updatedEntity, $loadedOption);
 }
コード例 #6
0
 private function createPostWithShortcode()
 {
     $author = EntityUtils::prepareUser();
     self::$authorVpId = $author['vp_id'];
     $this->userStorage->save($author);
     $post = EntityUtils::preparePost(null, self::$authorVpId);
     self::$vpId = $post['vp_id'];
     $post['post_content'] = WordPressMissingFunctions::renderShortcode('gallery', ['id' => self::$vpId]);
     $this->storage->save($post);
     return [['vp_id' => self::$authorVpId, 'parent' => self::$authorVpId], ['vp_id' => self::$vpId, 'parent' => self::$vpId]];
 }
コード例 #7
0
 private function deleteTerm()
 {
     $this->storage->delete(EntityUtils::prepareTerm(self::$vpId));
     return [['vp_id' => self::$vpId, 'parent' => self::$vpId]];
 }
コード例 #8
0
ファイル: PostStorage.php プロジェクト: wp-cpm/versionpress
 function __construct($directory, $entityInfo)
 {
     parent::__construct($directory, $entityInfo);
 }
コード例 #9
0
 function __construct($directory, $entityInfo, $wpdb)
 {
     parent::__construct($directory, $entityInfo);
     $this->database = $wpdb;
 }
コード例 #10
0
 private function deleteUserMeta()
 {
     $this->storage->delete(EntityUtils::prepareUserMeta(self::$vpId, self::$userVpId));
     $this->userStorage->delete(EntityUtils::prepareUser(self::$userVpId));
     return [['vp_id' => self::$vpId, 'parent' => self::$userVpId], ['vp_id' => self::$userVpId, 'parent' => self::$userVpId]];
 }
コード例 #11
0
ファイル: OptionStorage.php プロジェクト: wp-cpm/versionpress
 public function getEntityFilename($optionName, $parentId = null)
 {
     $sanitizedOptionName = urlencode($optionName);
     $sanitizedOptionName = str_replace('.', '%2E', $sanitizedOptionName);
     return parent::getEntityFilename($sanitizedOptionName, $parentId);
 }
コード例 #12
0
 protected function removeUnwantedColumns($entity)
 {
     $entity = parent::removeUnwantedColumns($entity);
     unset($entity['count']);
     return $entity;
 }