Permalink
Browse files

Merge pull request #526 from woodspire/IsInteger

Add IsInteger function to ColumnMap
  • Loading branch information...
2 parents 918cd5f + 7bc0414 commit 894e89dd338e6a8bdc04d5db6cbad6c9eeda3b30 @willdurand willdurand committed Dec 4, 2012
Showing with 20 additions and 0 deletions.
  1. +10 −0 runtime/lib/map/ColumnMap.php
  2. +10 −0 test/testsuite/runtime/map/ColumnMapTest.php
View
10 runtime/lib/map/ColumnMap.php
@@ -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
*/
View
10 test/testsuite/runtime/map/ColumnMapTest.php
@@ -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');
+ }
}

0 comments on commit 894e89d

Please sign in to comment.