ExtBase:
authorJochen Rau <j.rau@web.de>
Sat, 28 Mar 2009 10:23:59 +0000 (10:23 +0000)
committerJochen Rau <j.rau@web.de>
Sat, 28 Mar 2009 10:23:59 +0000 (10:23 +0000)
* Replaced preg_replace with str_replace in Utility String

typo3/sysext/extbase/Classes/Utility/Strings.php
typo3/sysext/extbase/Tests/Persistence/Mapper/ObjectRelationalMapper_testcase.php

index c18bd3b..62f9f6b 100644 (file)
@@ -38,7 +38,7 @@ abstract class Tx_ExtBase_Utility_Strings {
         * @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;
        }
        
@@ -49,7 +49,7 @@ abstract class Tx_ExtBase_Utility_Strings {
         * @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;
        }
index c5a8cdb..cbbd336 100644 (file)
@@ -38,7 +38,7 @@ class Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper_testcase extends Tx_E
                $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))
@@ -60,7 +60,7 @@ class Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper_testcase extends Tx_E
                $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);
@@ -112,7 +112,7 @@ class Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper_testcase extends Tx_E
                $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);
@@ -178,5 +178,58 @@ class Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper_testcase extends Tx_E
                $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