Permalink
Browse files

0.7 fixes

  • Loading branch information...
1 parent 9c6866f commit e9a1d351bf452d926259d74fe44b5511654c440c @mjpearson committed Feb 3, 2011
Showing with 24 additions and 23 deletions.
  1. +9 −9 lib/Core.class.php
  2. +15 −14 tests/lib/ColumnTest.php
View
@@ -363,7 +363,7 @@ static public function connectSeededKeyspace($hosts, $keySpace = DEFAULT_POOL_NA
$transport = new \TFramedTransport(new \TSocket($host, $port, PERSIST_CONNECTIONS, 'Pandra\\Core::registerError'), 1024, 1024);
}
$transport->open();
- $client = new cassandraClient(
+ $client = new \cassandraClient(
(function_exists("thrift_protocol_write_binary") ?
new \TBinaryProtocolAccelerated($transport) :
new \TBinaryProtocol($transport)));
@@ -612,33 +612,33 @@ static public function setConsistency($consistencyLevel, $readMode = FALSE) {
* @return SimpleXMLElement SimpleXML config structure
*/
static public function loadConfigXML() {
- if (!file_exists(\cassandra_CONF_PATH)) {
- throw new \RuntimeException('Cannot build models, file not found ('.\cassandra_CONF_PATH.')\n');
+ if (!file_exists(CASSANDRA_CONF_PATH)) {
+ throw new \RuntimeException('Cannot build models, file not found ('.CASSANDRA_CONF_PATH.')\n');
}
- $conf = simplexml_load_file(\cassandra_CONF_PATH);
+ $conf = simplexml_load_file(CASSANDRA_CONF_PATH);
return $conf;
}
static public function loadConfig() {
- if (!file_exists(\cassandra_CONF_PATH)) {
- throw new \RuntimeException('Cannot build models, file not found ('.\cassandra_CONF_PATH.')\n');
+ if (!file_exists(CASSANDRA_CONF_PATH)) {
+ throw new \RuntimeException('Cannot build models, file not found ('.CASSANDRA_CONF_PATH.')\n');
}
- $tokens = explode('/', \cassandra_CONF_PATH);
+ $tokens = explode('/', CASSANDRA_CONF_PATH);
$file = array_pop($tokens);
list($f, $ext) = explode('.', $file);
$ext = strtolower($ext);
$conf = NULL;
if ($ext == 'xml') {
- $conf = simplexml_load_file(\cassandra_CONF_PATH);
+ $conf = simplexml_load_file(CASSANDRA_CONF_PATH);
} elseif ($ext == 'yaml') {
if (!function_exists('syck_load')) {
throw new \RuntimeException('YAML config found but syck module not supported');
} else {
- $conf = syck_load(file_get_contents(\cassandra_CONF_PATH));
+ $conf = syck_load(file_get_contents(CASSANDRA_CONF_PATH));
}
}
return $conf;
View
@@ -1,12 +1,16 @@
<?php
+
namespace Pandra;
+
require_once 'PHPUnit/Framework.php';
class ColumnFamilyTestObject extends ColumnFamily {
+
public function init() {
$this->setKeySpace('Keyspace1');
$this->setName('Standard1');
}
+
}
/**
@@ -17,7 +21,6 @@ class ColumnTest extends \PHPUnit_Framework_TestCase {
public $obj = NULL;
public $parent = NULL;
-
public $columnName = 'mycolumn';
/**
@@ -29,8 +32,7 @@ class ColumnTest extends \PHPUnit_Framework_TestCase {
* @access protected
*/
protected function setUp() {
- //Core::auto('localhost');
- Core::connect('Keyspace1', 'localhost');
+ Core::connectSeededKeyspace('localhost');
$this->parent = new ColumnFamily();
$this->parent->setKeySpace('Keyspace1');
@@ -120,7 +122,7 @@ public function testCast() {
$column->name = 'castedColumn';
$column->value = 'THRIFT COLUMN VALUE';
- $Column =Column::cast($column, $this->parent);
+ $Column = Column::cast($column, $this->parent);
$this->assertEquals(get_class($Column), 'Column');
$this->assertEquals($Column->getValue(), $column->value);
@@ -132,9 +134,9 @@ public function testCast() {
$sc->column = new \cassandra_Column();
$sc->column->name = 'new column';
$sc->column->value = 'value';
- $sc->column->timestamp =Core::getTime();
+ $sc->column->timestamp = Core::getTime();
- $Column =Column::cast($sc);
+ $Column = Column::cast($sc);
$this->assertEquals(get_class($Column), 'Column');
$this->assertEquals($Column->getValue(), $sc->column->value);
}
@@ -186,17 +188,17 @@ public function testSaveLoadDelete() {
//$column = array_pop(Core::getCFSlice($keySpace, $keyID, $columnFamily))->column;
$this->assertTrue($this->obj->load());
$column = $this->obj;
- $this->assertTrue($column->value == $value && $column->name == $this->obj->getName() && empty(Core::$lastError),Core::$lastError);
+ $this->assertTrue($column->value == $value && $column->name == $this->obj->getName() && empty(Core::$lastError), Core::$lastError);
$this->obj->delete();
$this->assertTrue($this->obj->isModified() && $this->obj->isDeleted());
$this->assertTrue($this->obj->save(), $this->obj->getLastError());
- $columnParent = new \cassandra_ColumnParent(array('column_family'=>$columnFamily));
+ $columnParent = new \cassandra_ColumnParent(array('column_family' => $columnFamily));
$predicate = newSlicePredicate('Column', array('column' => $this->obj->getName()));
- $result =Core::getCFSlice($keySpace, $keyID, $columnParent, $predicate);
- $this->assertTrue(empty($result) && empty(Core::$lastError),Core::$lastError);
+ $result = Core::getCFSlice($keySpace, $keyID, $columnParent, $predicate);
+ $this->assertTrue(empty($result) && empty(Core::$lastError), Core::$lastError);
// save using parent
$this->obj->setKeyID(NULL);
@@ -222,16 +224,15 @@ public function testSaveLoadDelete() {
$this->assertTrue($this->obj->isModified());
$this->assertTrue($this->obj->save(), $this->obj->getLastError());
- $columnParent = new \cassandra_ColumnParent(array('column_family'=>$columnFamily));
+ $columnParent = new \cassandra_ColumnParent(array('column_family' => $columnFamily));
$predicate = newSlicePredicate('Column', array('column' => $this->obj->getName()));
$column = array_pop(Core::getCFSlice($keySpace, $keyID, $columnParent, $predicate))->column;
- $this->assertTrue($column->value == $value && $column->name = $this->obj->name && empty(Core::$lastError),Core::$lastError);
+ $this->assertTrue($column->value == $value && $column->name = $this->obj->name && empty(Core::$lastError), Core::$lastError);
$this->obj->delete();
$this->assertTrue($this->obj->isModified() && $this->obj->isDeleted());
$this->assertTrue($this->obj->save(), $this->obj->getLastError());
-
}
public function testRegisterError() {
@@ -241,8 +242,8 @@ public function testRegisterError() {
$errors = $this->obj->getErrors();
$this->assertTrue(array_pop($errors) == $errorMsg);
-
}
}
+
?>

0 comments on commit e9a1d35

Please sign in to comment.