Skip to content
Permalink
Browse files

Adding a Type::getBaseType() to hint other part of the framework abou…

…t extensions
  • Loading branch information...
lorenzo committed Jul 9, 2015
1 parent 7e89611 commit 8488eed87c7f81e180c677cc8d60641d4c9f312a
Showing with 19 additions and 0 deletions.
  1. +13 −0 src/Database/Type.php
  2. +6 −0 tests/TestCase/Database/TypeTest.php
@@ -163,6 +163,19 @@ public function getName()
return $this->_name;
}
/**
* Returns the base type name that this class is inheriting.
* This is useful when extending base type for adding extra functionality
* but still want the rest of the framework to use the same assumptions it would
* do about the base type it inherits from.
*
* @return string
*/
public function getBaseType()
{
return $this->_name;
}
/**
* Casts given value from a PHP type to one acceptable by database
*
@@ -25,6 +25,10 @@
class FooType extends \Cake\Database\Type
{
public function getBaseType()
{
return 'text';
}
}
/**
@@ -74,6 +78,7 @@ public function testBuildBasicTypes($name)
$type = Type::build($name);
$this->assertInstanceOf('Cake\Database\Type', $type);
$this->assertEquals($name, $type->getName());
$this->assertEquals($name, $type->getBaseType());
}
/**
@@ -133,6 +138,7 @@ public function testMapAndBuild()
$type = Type::build('foo');
$this->assertInstanceOf($fooType, $type);
$this->assertEquals('foo', $type->getName());
$this->assertEquals('text', $type->getBaseType());
}
/**

0 comments on commit 8488eed

Please sign in to comment.
You can’t perform that action at this time.