* @return string UpperCamelCasedWord
*/
public static function underscoredToUpperCamelCase($string) {
- $upperCamelCase = str_replace(' ', '', ucwords(preg_replace('![^A-Z^a-z^0-9]+!', ' ', strtolower($string))));
+ $upperCamelCase = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string))));
return $upperCamelCase;
}
* @return string lowerCamelCasedWord
*/
public static function underscoredToLowerCamelCase($string) {
- $upperCamelCase = str_replace(' ', '', ucwords(preg_replace('![^A-Z^a-z^0-9]+!', ' ', strtolower($string))));
+ $upperCamelCase = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string))));
$lowerCamelCase = strtolower(substr($upperCamelCase,0,1) ) . substr($upperCamelCase,1);
return $lowerCamelCase;
}
$GLOBALS['TYPO3_DB'] = $this->typo3Db;
}
- public function test_BuildQueryWithPlaceholders() {
+ public function test_QueryWithPlaceholdersCanBeBuild() {
$mapper = new Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper();
$GLOBALS['TYPO3_DB']->expects($this->at(0))
$this->assertEquals('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)', $query);
}
- public function test_BuildQueryWithExample() {
+ public function test_QueryWithExampleCanBeBuild() {
$mapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('getDataMap'));
$columnMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
$this->assertEquals('(tx_blogexample_domain_model_blog.blog_name = "foo") AND (tx_blogexample_domain_model_blog.hidden = 0)', $query);
}
- public function test_BuildQueryWithNestedExample() {
+ public function test_QueryWithNestedExampleCanBeBuild() {
$mapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('getDataMap'));
$columnMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
$this->assertEquals('(tx_blogexample_domain_model_blog.hidden = 0) AND ((tx_blogexample_domain_model_author.name = "Christopher"))', $query);
}
+ public function test_QueryWithExampleCanBeBuild() {
+ $mapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('getDataMap'));
+
+ $columnMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
+ $columnMap1->expects($this->once())
+ ->method('getColumnName')
+ ->will($this->returnValue('blog_name'));
+
+ $columnMap2 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
+ $columnMap2->expects($this->once())
+ ->method('getColumnName')
+ ->will($this->returnValue('hidden'));
+
+ $dataMap = $this->getMock('Tx_ExtBase_Persistence_Mapper_DataMap', array('getColumnMap', 'getTableName'), array(), '', FALSE);
+
+ $dataMap->expects($this->at(0))
+ ->method('getColumnMap')
+ ->with($this->equalTo('blogName'))
+ ->will($this->returnValue($columnMap1));
+
+ $dataMap->expects($this->at(1))
+ ->method('getTableName')
+ ->will($this->returnValue('tx_blogexample_domain_model_blog'));
+
+ $dataMap->expects($this->at(2))
+ ->method('getColumnMap')
+ ->with($this->equalTo('hidden'))
+ ->will($this->returnValue($columnMap2));
+
+ $dataMap->expects($this->at(3))
+ ->method('getTableName')
+ ->will($this->returnValue('tx_blogexample_domain_model_blog'));
+
+ $mapper->expects($this->any())
+ ->method('getDataMap')
+ ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'))
+ ->will($this->returnValue($dataMap));
+
+ $GLOBALS['TYPO3_DB']->expects($this->at(0))
+ ->method('fullQuoteStr')
+ ->with($this->equalTo('foo'))
+ ->will($this->returnValue('"foo"'));
+
+ $query = $mapper->buildQuery('Tx_BlogExample_Domain_Model_Blog',
+ array(
+ 'blogName' => 'foo',
+ 'hidden' => FALSE
+ ));
+
+ $this->assertEquals('(tx_blogexample_domain_model_blog.blog_name = "foo") AND (tx_blogexample_domain_model_blog.hidden = 0)', $query);
+ }
+
+
}
?>
\ No newline at end of file