public function testSaveLoadDelete() { // Save it $this->obj['blog-slug-1']['title'] = 'My First Blog'; $this->obj['blog-slug-1']['content'] = 'Can I be in the blog-o-club too?'; $this->obj['blog-slug-2']['title'] = 'My Second Blog, and maybe the last'; $this->obj['blog-slug-2']['content'] = 'I promise to write something soon!'; $this->assertTrue($this->obj->save(), $this->obj->lastError()); // Grab some konown values to test with $colTitleValue = $this->obj['blog-slug-1']['title']; $colTitleValue2 = $this->obj['blog-slug-2']['title']; // Re-Load, check saved data $this->obj = NULL; $this->obj = new TestCFSuper(); $this->assertTrue($this->obj->load($this->_keyID), $this->obj->lastError()); // Test at least 2 supercolumns to make sure population is ok $this->assertTrue($colTitleValue == $this->obj['blog-slug-1']['title']); $this->assertTrue($colTitleValue2 == $this->obj['blog-slug-2']['title']); // Delete columnfamily $this->obj->delete(); $this->assertTrue($this->obj->save(), $this->obj->lastError()); // Confirm we can't load the key any more $this->obj = NULL; $this->obj = new TestCFSuper(); $this->assertFalse($this->obj->load($this->_keyID), $this->obj->lastError()); }
// Make sure the same two characters don't appear next to each other if ($r != $string[$i - 1]) { $string .= $r; } } // Return the string return $string; } // generate 5 timestamped supercolumns for ($i = 1; $i <= 5; $i++) { $bp = new BlogPost(UUID::v1()); $bp->column_title = rand_str(); $bp->column_body = rand_str(); $scf->addSuper($bp); } echo 'Saving SuperColumnFamily...<br>'; print_r($scf->toJSON()); $scf->save(); // get slice of the 5 most recent entries (count = 5, reversed = true) echo '<br><br>Loading via SuperColumnFamily container...<br>'; $scNew = new PandraSuperColumnFamily($keyID, $ks, $cfName, PandraColumnContainer::TYPE_UUID); $scNew->limit(5)->load(); echo '<br>Loaded...<br>'; print_r($scNew->toJSON()); echo '<br><br>Loading SuperColumn Slice...<br>'; $result = PandraCore::getCFSlice($ks, $keyID, new cassandra_ColumnParent(array('column_family' => $cfName)), new PandraSlicePredicate(PandraSlicePredicate::TYPE_RANGE, array('start' => '', 'finish' => '', 'count' => 5, 'reversed' => true))); $scNew = new PandraSuperColumnFamily($keyID, $ks, $cfName, PandraColumnContainer::TYPE_UUID); var_dump($result); $scNew->populate($result); echo '<br>Imported...<br>'; print_r($scNew->toJSON());