Permalink
Browse files

Add test for isset on rows

  • Loading branch information...
Floby committed Jul 25, 2012
1 parent 4a6d8e1 commit b153c3c06b8a73d8bcc5a9492917c00217f63dce
@@ -214,6 +214,44 @@ public function testFunction__Set()
}
+ /**
+ * @covers Centurion_Db_Table_Row_Abstract::__isset
+ */
+ public function testFunction__Isset()
+ {
+ $table = new Asset_Model_DbTable_Simple();
+ $row = $table->createRow();
+ $row->save();
+ $row->title = 'title';
+
+ // this column exists
+ $this->assertTrue(isset($row->title), 'calling isset on a set column returned false');
+
+ // this column doesn't exist
+ $this->assertFalse(isset($row->unexistent), 'calling isset on an unset column returned true');
+
+ $tableWithRef = new Asset_Model_DbTable_WithRef();
+ $withRef = $tableWithRef->createRow();
+ $withRef->simple_id = $row->id;
+ $withRef->save();
+
+ // this column is a referenceMap
+ $this->assertTrue(isset($withRef->simple), 'calling isset on a reference returned false');
+
+ // this column is a reference field
+ $this->assertTrue(isset($withRef->simple__title), 'calling isset on a reference\'s field returned false');
+
+ $tableSpecialGet = new Asset_Model_DbTable_WithSpecialGet();
+ $withSpecialGet = $tableSpecialGet->createRow();
+ $withSpecialGet->save();
+
+ // this column is a special get with a methodName as string
+ $this->assertTrue(isset($withSpecialGet->method), 'Calling isset on a specialget by string returned false');
+
+ // this column is a special get with a callable array as parameter
+ $this->assertTrue(isset($withSpecialGet->arrayGet), 'Calling isset on a specialget by callable array returned false');
+ }
+
/**
* @covers Centurion_Db_Table_Row_Abstract::getModifiedData
* @covers Centurion_Db_Table_Row_Abstract::reset
@@ -0,0 +1,16 @@
+<?php
+
+class Asset_Model_DbTable_Row_SimpleWithSpecialGet extends Centurion_Db_Table_Row
+{
+
+ public function __construct(array $config) {
+ $this->_specialGets['method'] = 'specialGetMethod';
+ $this->_specialGets['arrayGet'] = array($this, 'specialGetMethod');
+ parent::__construct($config);
+ }
+ public function specialGetMethod()
+ {
+ return 'success';
+ }
+}
+
@@ -0,0 +1,32 @@
+<?php
+
+class Asset_Model_DbTable_WithSpecialGet extends Asset_Model_DbTable_Abstract
+{
+ protected $_name = 'test_with_special_get';
+
+ protected $_rowClass = 'Asset_Model_DbTable_Row_SimpleWithSpecialGet';
+
+
+ protected function _createTable()
+ {
+ $this->getDefaultAdapter()->query(<<<EOS
+ CREATE TABLE IF NOT EXISTS test_with_special_get (
+ `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+ `title` VARCHAR( 255 ) NOT NULL
+ ) ENGINE = INNODB;
+EOS
+ );
+ }
+
+ protected function _destructTable()
+ {
+ $this->getDefaultAdapter()->query('Drop table test_with_special_get');
+ }
+
+ public function __construct($config = array())
+ {
+ parent::__construct($config);
+ }
+
+}
+

0 comments on commit b153c3c

Please sign in to comment.