[Solar-svn] Revision 2722
pmjones at solarphp.com
pmjones at solarphp.com
Thu Aug 16 16:44:23 CDT 2007
Branch: continued model testing; all existing tests now work for mysql, pgsql, and sqlite
Modified: branches/orm/tests/Solar/Sql/AdapterTestCase.php
===================================================================
--- branches/orm/tests/Solar/Sql/AdapterTestCase.php 2007-08-16 21:41:52 UTC (rev 2721)
+++ branches/orm/tests/Solar/Sql/AdapterTestCase.php 2007-08-16 21:44:23 UTC (rev 2722)
@@ -152,8 +152,8 @@
$result = $this->_sql->insert($this->_table_name, $data);
$this->assertEquals($result, 1);
- $result = $this->_sql->fetchRow("SELECT * FROM $this->_table_name WHERE id = 1");
- $this->assertEquals($result->toArray(), $data);
+ $result = $this->_sql->fetchOne("SELECT * FROM $this->_table_name WHERE id = 1");
+ $this->assertEquals($result, $data);
}
public function testUpdate()
@@ -168,8 +168,8 @@
$this->assertEquals($result, 1);
$expect = array('id' => '1', 'name' => 'Bar');
- $actual = $this->_sql->fetchRow("SELECT * FROM $this->_table_name WHERE id = 1");
- $this->assertEquals($actual->toArray(), $expect);
+ $actual = $this->_sql->fetchOne("SELECT * FROM $this->_table_name WHERE id = 1");
+ $this->assertEquals($actual, $expect);
}
public function testDelete()
@@ -191,8 +191,8 @@
);
// did it work?
- $actual = $this->_sql->fetchRowset("SELECT * FROM $this->_table_name ORDER BY id");
- $this->assertEquals($actual->toArray(), $expect);
+ $actual = $this->_sql->fetchAll("SELECT * FROM $this->_table_name ORDER BY id");
+ $this->assertEquals($actual, $expect);
}
public function testFetchAll()
@@ -271,14 +271,14 @@
$this->assertType($expect, $actual);
}
- public function testFetchRow()
+ public function testFetchOne()
{
$this->_insertData();
$cmd = "SELECT id, name FROM $this->_table_name WHERE id = :id";
$data = array('id' => 5);
- $actual = $this->_sql->fetchRow($cmd, $data);
+ $actual = $this->_sql->fetchOne($cmd, $data);
$expect = array('id' => '5', 'name' => 'Zim');
- $this->assertEquals($actual->toArray(), $expect);
+ $this->assertEquals($actual, $expect);
}
public function testFetchSql()
@@ -351,18 +351,18 @@
$this->_sql->addColumn($this->_table_name, 'email', $info);
$this->_sql->update($this->_table_name, array('email' => 'nobody at example.com'), '1=1');
- $actual = $this->_sql->fetchRow("SELECT * FROM $this->_table_name WHERE id = 1");
+ $actual = $this->_sql->fetchOne("SELECT * FROM $this->_table_name WHERE id = 1");
$expect = array('id' => '1', 'name' => 'Foo', 'email' => 'nobody at example.com');
- $this->assertEquals($actual->toArray(), $expect);
+ $this->assertEquals($actual, $expect);
}
public function testDropColumn()
{
$this->_insertData();
$this->_sql->dropColumn($this->_table_name, 'name');
- $actual = $this->_sql->fetchRow("SELECT * FROM $this->_table_name WHERE id = 1");
+ $actual = $this->_sql->fetchOne("SELECT * FROM $this->_table_name WHERE id = 1");
$expect = array('id' => '1');
- $this->assertEquals($actual->toArray(), $expect);
+ $this->assertEquals($actual, $expect);
}
public function testCreateIndex_singleNormal()
Modified: branches/orm/tests/Test/Solar/Sql/Model.php
===================================================================
--- branches/orm/tests/Test/Solar/Sql/Model.php 2007-08-16 21:41:52 UTC (rev 2721)
+++ branches/orm/tests/Test/Solar/Sql/Model.php 2007-08-16 21:44:23 UTC (rev 2722)
@@ -22,14 +22,8 @@
*
* - reads table properly (and overrides local settings)
*
- * - create a new record
- * - make sure inheritance gets honored on save, and modify record to correct type
+ * - fetching with One and All
*
- * - update an existing record
- * - make sure inheritance gets honored on save, and modify record to correct type
- *
- * - fetching
- *
* - lazy-fetch a has_one related
*
* - lazy-fetch a belongs_to related
@@ -46,7 +40,7 @@
*
* - eager-fetch a has_many_through related
*
- * - test various params on fetchAll: where, group, having, etc
+ * - test honoring of $_fetch_cols
*
* - collections
*
@@ -114,6 +108,7 @@
parent::setup();
$this->_sql = Solar::factory('Solar_Sql');
+
$this->_sql->setProfiling(true);
$this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', array(
@@ -175,10 +170,8 @@
$record->name = chr($i+96); //ascii 'a', 'b', etc
$record->save();
}
-
}
-
// -----------------------------------------------------------------
//
// Test methods.
@@ -203,7 +196,8 @@
/**
*
- * Test -- Magic call implements "fetchOneBy...()" and "fetchAllBy...()" for columns listed in the method name.
+ * Test -- Magic call implements "fetchOneBy...()" and "fetchAllBy...()"
+ * for columns listed in the method name.
*
*/
public function test__call()
@@ -219,7 +213,8 @@
$record = $model->fetchNew();
$record->name = 'z';
$record->seq_foo = 88;
- $record->save();
+ $valid = $model->insertRecord($record);
+ $this->assertTrue($valid);
}
// add some extras so we can see if fetchAll() grabs more than it should
@@ -228,7 +223,8 @@
$record = $model->fetchNew();
$record->name = 'z';
$record->seq_foo = 99;
- $record->save();
+ $valid = $model->insertRecord($record);
+ $this->assertTrue($valid);
}
/**
@@ -549,7 +545,7 @@
'i' => '9',
'j' => '10',
);
- $this->assertSame($actual, $expect);
+ $this->assertEquals($actual, $expect);
}
/**
@@ -966,7 +962,7 @@
*/
$record = $model->fetchNew();
- $record->save();
+ $model->insertRecord($record);
$now = date('Y-m-d H:i:s');
// autoincremented id
@@ -986,7 +982,7 @@
*/
$record = $model->fetch(1);
$record->seq_bar = null;
- $record->save();
+ $model->updateRecord($record);
$now = date('Y-m-d H:i:s');
// created should be as original
Modified: branches/orm/tests/test.config.php
===================================================================
--- branches/orm/tests/test.config.php 2007-08-16 21:41:52 UTC (rev 2721)
+++ branches/orm/tests/test.config.php 2007-08-16 21:44:23 UTC (rev 2722)
@@ -16,21 +16,21 @@
*/
$config['Solar_Sql'] = array(
- 'adapter' => 'Solar_Sql_Adapter_Mysql',
+ 'adapter' => 'Solar_Sql_Adapter_Sqlite',
);
$config['Solar_Sql_Adapter_Mysql'] = array(
'host' => '127.0.0.1',
- 'name' => 'test'
+ 'name' => 'test',
);
$config['Solar_Sql_Adapter_Pgsql'] = array(
'host' => '127.0.0.1',
- 'name' => 'test'
+ 'name' => 'test',
);
$config['Solar_Sql_Adapter_Sqlite'] = array(
- 'name' => '/tmp/solar-test.sq3',
+ 'name' => ':memory:',
);
return $config;
More information about the Solar-svn
mailing list