save() public method

public save ( $data )
 /**
  * @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));
 }
 /**
  * @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);
 }
 /**
  * @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);
 }
 /**
  * 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);
 }
 private function createTermMeta()
 {
     $term = EntityUtils::prepareTerm();
     self::$termVpId = $term['vp_id'];
     $this->termStorage->save($term);
     $termmeta = EntityUtils::prepareTermMeta(null, self::$termVpId, 'some-meta', 'some value');
     $this->storage->save($termmeta);
     self::$vpId = $termmeta['vp_id'];
     return [['vp_id' => self::$vpId, 'parent' => self::$termVpId], ['vp_id' => self::$termVpId, 'parent' => self::$termVpId]];
 }
 private function createUserMeta()
 {
     $user = EntityUtils::prepareUser();
     self::$userVpId = $user['vp_id'];
     $this->userStorage->save($user);
     $usermeta = EntityUtils::prepareUserMeta(null, self::$userVpId, 'some-meta', 'some value');
     $this->storage->save($usermeta);
     self::$vpId = $usermeta['vp_id'];
     return [['vp_id' => self::$vpId, 'parent' => self::$userVpId], ['vp_id' => self::$userVpId, 'parent' => self::$userVpId]];
 }
 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]];
 }
 private function createPostMeta()
 {
     $author = EntityUtils::prepareUser();
     self::$authorVpId = $author['vp_id'];
     $this->userStorage->save($author);
     $post = EntityUtils::preparePost(null, self::$authorVpId);
     self::$postVpId = $post['vp_id'];
     $this->postStorage->save($post);
     $post2 = EntityUtils::preparePost(null, self::$authorVpId);
     self::$post2VpId = $post2['vp_id'];
     $this->postStorage->save($post2);
     /**
      * This postmeta has a value reference to another post.
      * @see schema.yml
      * @var array
      */
     $postmeta = EntityUtils::preparePostMeta(null, self::$postVpId, '_thumbnail_id', self::$post2VpId);
     self::$vpId = $postmeta['vp_id'];
     $this->storage->save($postmeta);
     return [['vp_id' => self::$authorVpId, 'parent' => self::$authorVpId], ['vp_id' => self::$postVpId, 'parent' => self::$postVpId], ['vp_id' => self::$post2VpId, 'parent' => self::$post2VpId], ['vp_id' => self::$vpId, 'parent' => self::$postVpId]];
 }
 private function editTerm($name = 'Another name')
 {
     $this->storage->save(EntityUtils::prepareTerm(self::$vpId, $name));
     return [['vp_id' => self::$vpId, 'parent' => self::$vpId]];
 }
 private function editComment($key = 'comment_content', $value = 'another content')
 {
     $this->storage->save(EntityUtils::prepareComment(self::$vpId, null, null, [$key => $value]));
     return [['vp_id' => self::$vpId, 'parent' => self::$vpId]];
 }
Exemplo n.º 11
0
 public function save($data)
 {
     unset($data['option_id']);
     return parent::save($data);
 }
 private function editUser($key = 'user_email', $value = '*****@*****.**')
 {
     $this->storage->save(EntityUtils::prepareUser(self::$vpId, [$key => $value]));
     return [['vp_id' => self::$vpId, 'parent' => self::$vpId]];
 }