/** * @test */ public function storageDoesNotContainDeletedEntities() { $anotherTestingEntity = $this->testingEntity; $anotherTestingEntity['another_field'] = 'value'; $anotherTestingEntity['vp_id'] = '0123456789ABCDEFFEDCBA9876543210'; $this->storage->save($this->testingEntity); $this->storage->save($anotherTestingEntity); $loadedEntities = $this->storage->loadAll(); $this->assertTrue(count($loadedEntities) === 2); $this->storage->delete($this->testingEntity); $loadedEntities = $this->storage->loadAll(); $this->assertTrue(count($loadedEntities) === 1); $this->assertEquals($anotherTestingEntity, reset($loadedEntities)); }
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]]; }
/** * @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); }
private function removeCategory() { $this->storage->delete(EntityUtils::preparePost(self::$vpId)); $this->termTaxonomyStorage->delete(EntityUtils::prepareTermTaxonomy(self::$categoryTaxonomyVpId, self::$categoryVpId)); $this->termStorage->delete(EntityUtils::prepareTerm(self::$categoryVpId)); $this->userStorage->delete(EntityUtils::prepareUser(self::$authorVpId)); return [['vp_id' => self::$vpId, 'parent' => self::$vpId], ['vp_id' => self::$categoryTaxonomyVpId, 'parent' => self::$categoryVpId], ['vp_id' => self::$categoryVpId, 'parent' => self::$categoryVpId], ['vp_id' => self::$authorVpId, 'parent' => self::$authorVpId]]; }
private function deleteTerm() { $this->storage->delete(EntityUtils::prepareTerm(self::$vpId)); return [['vp_id' => self::$vpId, 'parent' => self::$vpId]]; }
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]]; }