public function testGettingInitialId() { $doc = new Document(array('mike' => 'snow')); $doc->setId('albums'); $this->assertEquals('albums', $doc->getInitialId()); $doc->setId('singles'); $this->assertEquals('albums', $doc->getInitialId()); }
public function testStoringDocuments() { exec('rm -rf /tmp/flywheel/_pages'); if (!is_dir('/tmp/flywheel')) { mkdir('/tmp/flywheel'); } $config = new Config('/tmp/flywheel'); $repo = new NestedRepository('_pages', $config); for ($i = 0; $i < 5; $i++) { $data = array('slug' => '123', 'body' => 'THIS IS BODY TEXT'); $document = new Document($data); $document->setId($i . '/test/' . $i); $repo->store($document); $name = $i . '.json'; $this->assertSame($data, (array) json_decode(file_get_contents('/tmp/flywheel/_pages/' . $i . '/test/' . $name))); } }
/** * @param Message $event * * @return Document */ private function convertEventToDocument(Message $event) { $eventArr = $this->messageConverter->convertToArray($event); MessageDataAssertion::assert($eventArr); $data = ['event_id' => $eventArr['uuid'], 'version' => $eventArr['version'], 'event_name' => $eventArr['message_name'], 'payload' => $eventArr['payload'], 'metadata' => $eventArr['metadata'], 'created_at' => $eventArr['created_at']->format('Y-m-d\\TH:i:s.u')]; $document = new Document($data); $document->setId($data['event_id']); return $document; }
public function testChangingDocumentIDChangesFilename() { if (!is_dir('/tmp/flywheel')) { mkdir('/tmp/flywheel'); } $config = new Config('/tmp/flywheel'); $repo = new Repository('_pages', $config); $doc = new Document(array('test' => '123')); $doc->setId('test1234'); $repo->store($doc); $this->assertTrue(file_exists('/tmp/flywheel/_pages/test1234.json')); $doc->setId('9876test'); $repo->update($doc); $this->assertFalse(file_exists('/tmp/flywheel/_pages/test1234.json')); }
/** * @param EncryptedWallet $encryptedWallet * @return EncryptedWalletDocument */ private function walletToDocument(EncryptedWallet $encryptedWallet) { $searchFields = array('id' => $encryptedWallet->getId()->getValue(), 'userId' => $encryptedWallet->getUserId()->getValue(), 'name' => $encryptedWallet->getName(), 'coinSymbol' => $encryptedWallet->getCoinSymbol(), 'creationTime' => clone $encryptedWallet->getCreationTime()); $docArray = $searchFields; $docArray['data'] = serialize($encryptedWallet); $walletDocument = new Document($docArray); $walletDocument->setId($encryptedWallet->getId()->getValue()); // DEBUG //var_dump($wallet); //var_dump($walletDocument); //die(); return $walletDocument; }