public function testDumpDocumentWithAttachment() { $doc = new phpillowUserDocument(); $doc->login = '******'; $doc->attachFile($file = dirname(__FILE__) . '/../phpillow/data/image_png.png'); $doc->save(); $tool = new phpillowTool('http://localhost:5984/test', array('verbose' => false)); $tool->setOutputStreams($stdout = fopen('string://', 'w'), $stderr = fopen('string://', 'w')); $this->assertEquals(0, $tool->dump()); fseek($stdout, 0); fseek($stderr, 0); $this->compareDump(__FUNCTION__, stream_get_contents($stdout)); $this->assertEquals("Dumping document user-kore\n", stream_get_contents($stderr)); }
phpillowConnection::createInstance('10.0.118.171', 5984, 'admin', 'm4!1.d3'); phpillowConnection::setDatabase('test'); $db = phpillowConnection::getInstance(); try { $db->delete('/test'); } catch (Exception $e) { /* Ignore */ } $db->put('/test'); // /* $start = microtime(true); for ($i = 0; $i < $puts; ++$i) { $doc = new phpillowUserDocument(); $doc->login = '******' . $i; $doc->name = 'Kore Nordmann'; $doc->save(); } printf("%d PUTs in %.2fs (%d req/s)\n", $puts, $time = microtime(true) - $start, $puts / $time); // */ $start = microtime(true); for ($i = 0; $i < $gets; ++$i) { $doc = new phpillowUserDocument('user-kore_0'); } printf("%d GETs in %.2fs (%d req/s)\n", $gets, $time = microtime(true) - $start, $gets / $time); $start = microtime(true); $doc = phpillowUserView::user(array('key' => 'kore_0')); printf("First view in %.2fs (%d req/s)\n", $time = microtime(true) - $start, 1 / $time); $start = microtime(true); for ($i = 0; $i < $views; ++$i) { $doc = phpillowUserView::user(array('key' => 'kore_0')); }