ExtBase:
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Persistence / Mapper / ObjectRelationalMapper_testcase.php
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