/** * @test * @author Christopher Hlubek <*****@*****.**> */ public function callingViewInitializesDesignDocument() { $design = new Fixtures\Design\CompanyDesign(); $design->setClient($this->client); $design->totalPurchasesAmount('12345678'); $document = $this->client->getDocument('_design/company'); $this->assertNotNull($document); }
/** * @throws \TYPO3\CouchDB\Client\NotFoundException * @return void */ public function synchronize() { try { $designDocument = $this->client->getDocument('_design/' . $this->getDesignDocumentName(), array('decodeAssociativeArray' => TRUE)); } catch (\TYPO3\CouchDB\Client\NotFoundException $notFoundException) { $information = $notFoundException->getInformation(); if ($information['reason'] === 'no_db_file') { $this->client->createDatabase(); } if ($information['reason'] === 'no_db_file' || $information['reason'] === 'missing') { $designDocument = array('_id' => '_design/' . $this->getDesignDocumentName(), 'language' => $this->language); } else { throw $notFoundException; } } $declarations = $this->getDeclarations(); foreach ($declarations as $declaration) { $viewDeclaration = call_user_func(get_class($this) . '::' . $declaration . 'Declaration'); $designDocument['views'][$declaration] = $viewDeclaration; } $this->client->createDocument($designDocument); }
/** * @test * @author Christopher Hlubek <*****@*****.**> */ public function createAndGetDesignDocumentWorks() { $this->client->createDocument(array('language' => 'javascript'), '_design/test'); $response = $this->client->getDocument('_design/test'); $this->assertEquals('javascript', $response->language); }