Permalink
Browse files

Merge branch 'master' into survos

  • Loading branch information...
kcivey committed Nov 18, 2013
2 parents f55871d + 93f9fc8 commit 609b65a5e632d2717942d1655aa72a890b624685
@@ -1986,8 +1986,16 @@ protected function addDefaultMutator(&$script, Column $col)
// Perform type-casting to ensure that we can use type-sensitive
// checking in mutators.
if ($col->isPhpPrimitiveType()) {
+ if($col->isTextType()) {
+ $script .= "
+ if (\$v !== null) {";
+ } else {
+ $script .= "
+ if (\$v !== null && is_numeric(\$v)) {";
+ }
+
+
$script .= "
- if (\$v !== null && is_numeric(\$v)) {
\$v = (" . $col->getPhpType() . ") \$v;
}
";
@@ -11,6 +11,7 @@
require_once dirname(__FILE__) . '/../model/Table.php';
require_once dirname(__FILE__) . '/../model/Column.php';
require_once dirname(__FILE__) . '/PropelSQLParser.php';
+require_once dirname(__FILE__) . '/../../../runtime/lib/Propel.php';
/**
* Service class for preparing and executing migrations
@@ -100,6 +100,48 @@ public function testDefaultValues()
$acct->setPassword("testpass");
$this->assertTrue($acct->isModified());
}
+
+
+ public function testTypeHintingValues()
+ {
+ $test_name = 'test name';
+ $a = new Author();
+ $a2 = new Author();
+ $a2->setFirstName($test_name);
+
+
+ $a->setAge(2);
+ $this->assertEquals(2, $a->getAge());
+ $this->assertTrue(is_int($a->getAge()));
+
+
+ $a->clear();
+ $a->setAge('2');
+ $this->assertEquals(2, $a->getAge());
+ $this->assertTrue(is_int($a->getAge()));
+
+
+ $a->clear();
+ $a->setAge('wrong integer');
+ $this->assertTrue(!is_int($a->getAge()));
+
+
+ $a->clear();
+ $a->setFirstName($test_name);
+ $this->assertEquals($test_name, $a->getFirstName());
+ $this->assertTrue(is_string($a->getFirstName()));
+
+
+ $a->clear();
+ $a->setFirstName($a2);
+ $this->assertTrue(is_string($a->getFirstName()));
+ $this->assertEquals($a->getFirstName(), (string)$a2);
+
+
+ $a->clear();
+ $a->setFirstName(true);
+ $this->assertTrue(is_string($a->getFirstName()));
+ }
/**
* Tests the use of default expressions and the reloadOnInsert and reloadOnUpdate attributes.

0 comments on commit 609b65a

Please sign in to comment.