Add IsInteger function to ColumnMap #526

Merged
merged 4 commits into from Dec 4, 2012
@@ -212,6 +212,16 @@ public function isNumeric()
}
/**
+ * Whether this column is an integer
+ *
+ * @return boolean
+ */
+ public function isInteger()
+ {
+ return $this->getPdoType() === PDO::PARAM_INT;
+ }
+
+ /**
* Whether this column is a text column (varchar, char, longvarchar).
* @return boolean
*/
@@ -149,4 +149,14 @@ public function testIsPrimaryString()
$titleColumn->setPrimaryString(true);
$this->assertTrue($titleColumn->isPrimaryString(), 'isPrimaryString() returns true if set.');
}
+
+ public function testIsInteger()
+ {
+ $bookTable = BookPeer::getTableMap();
+ $idColumn = $bookTable->getColumn('id'); // INTEGER
+ $titleColumn = $bookTable->getColumn('title'); // VARCHAR
+
+ $this->assertTrue($idColumn->isInteger(), 'isInteger() returns true');
+ $this->assertFalse($titleColumn->isInteger(), 'isInteger() returns false');
+ }
}