/** * Displays information about the given Document * * @param Document $document * @param bool $showBody */ public function showDocument(Document $document, $showBody = FALSE) { $this->outputLine(static::ESCAPE . static::GREEN . 'Database: ' . $document->_getDb() . ' ' . 'ID: ' . ($document->getId() ? $document->getId() : '(Missing ID)') . ' ' . static::ESCAPE . static::NORMAL); if ($showBody) { $this->outputLine($this->formatJsonData($document->_getDataProtected(), TRUE) . PHP_EOL); } }
/** * Merges two Documents * * @param Document $oldDocument * @param Document|array|\stdClass $newDocument * @throws \Cundd\Rest\Domain\Exception\NoDatabaseSelectedException if the converted Document has no database * @return Document */ protected function mergeDocuments($oldDocument, $newDocument) { $mergeKeys = array('uid', 'pid', 'id', 'db', Document::DATA_PROPERTY_NAME); foreach ($mergeKeys as $key) { if (isset($newDocument[$key]) && $newDocument[$key]) { $oldDocument[$key] = $newDocument[$key]; } } if (!$oldDocument->_getDb()) { $currentDatabase = $this->getDatabase(); if (!$currentDatabase) { throw new NoDatabaseSelectedException('The given object and the repository have no database set', 1389257938); } $oldDocument->_setDb($currentDatabase); } return $oldDocument; }
/** * @test */ public function getInitialDbTest() { $result = $this->fixture->_getDb(); $this->assertEquals('', $result); }