[+BUGFIX] Extbase: fixed testcases
authorSebastian Kurfürst <sebastian@typo3.org>
Mon, 14 Sep 2009 17:35:52 +0000 (17:35 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Mon, 14 Sep 2009 17:35:52 +0000 (17:35 +0000)
typo3/sysext/extbase/Tests/MVC/Controller/Argument_testcase.php
typo3/sysext/extbase/Tests/MVC/Web/Routing/UriBuilder_testcase.php
typo3/sysext/extbase/Tests/Validation/ValidatorResolver_testcase.php

index f3e97c7..2393ee2 100644 (file)
@@ -72,57 +72,19 @@ class Tx_Extbase_MVC_Controller_Argument_testcase extends Tx_Extbase_Base_testca
        /**
         * @test
         */
-       public function setValueTriesToConvertAnUIDIntoTheRealObject() {
+       public function setValueTriesToConvertAnUIDIntoTheRealObjectIfTheDataTypeClassSchemaIsSet() {
                $object = new StdClass();
                
                $argument = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_Argument'), array('findObjectByUid'), array(), '', FALSE);
                $argument->expects($this->once())->method('findObjectByUid')->with('42')->will($this->returnValue($object));
-               $argument->setValue(array('uid' => '42'));
-       
-               $this->assertSame($object, $argument->_get('value'));
-       }
-       
-       /**
-        * @test
-        */
-       public function setValueTriesToConvertAnIdentityArrayContainingIdentifiersIntoTheRealObject() {
-               $object = new stdClass();
-                       
-               // $mockQuery = $this->getMock('Tx_Extbase_Persistence_Query', array(), array(), '', FALSE);
-               # TODO Insert more expectations here
-               // $mockQuery->expects($this->once())->method('execute')->will($this->returnValue(array($object)));
-       
-               // $mockQueryFactory = $this->getMock('Tx_Extbase_Persistence_QueryFactory', array(), array(), '', FALSE);
-               // $mockQueryFactory->expects($this->once())->method('create')->with('MyClass')->will($this->returnValue($mockQuery));
-       
-               $argument = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_Argument'), array('findObjectByUid'), array(), '', FALSE);
-               $argument->expects($this->once())->method('findObjectByUid')->with('42')->will($this->returnValue($object));
-               $argument->_set('dataType', 'MyClass');
+               $argument->_set('dataTypeClassSchema', 'stdClass');
+               $argument->_set('dataType', 'stdClass');
                // $argument->_set('queryFactory', $mockQueryFactory);
-               $argument->setValue(array('uid' => '42'));
-       
+               $argument->setValue('42');
+
                $this->assertSame($object, $argument->_get('value'));
        }
-       
-       /**
-        * @test
-        */
-       public function setValueConvertsAnArrayIntoAFreshObjectWithThePropertiesSetToTheArrayValuesIfDataTypeIsAClassAndNoIdentityInformationIsFoundInTheValue() {
-               eval('class MyClass {}');               
-               $object = new MyClass;
-               
-               $theValue = array('property1' => 'value1', 'property2' => 'value2');
-       
-               $mockPropertyMapper = $this->getMock('Tx_Extbase_Property_Mapper', array('map'), array(), '', FALSE);
-               $mockPropertyMapper->expects($this->once())->method('map')->with(array('property1', 'property2'), $theValue, $object)->will($this->returnValue(TRUE));
-       
-               $argument = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_Argument'), array('dummy'), array(), '', FALSE);
-               $argument->_set('dataType', 'MyClass');
-               $argument->_set('propertyMapper', $mockPropertyMapper);
-               $argument->setValue($theValue);
-       
-               $this->assertTrue($argument->_get('value') instanceof MyClass);
-       }
+
                
        /**
         * @test
index f776f78..536eb61 100644 (file)
@@ -236,7 +236,7 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder_testcase extends Tx_Extbase_Base_tes
 
                $this->uriBuilder->setArguments(array('somePrefix' => array('someDomainObject' => $mockDomainObject)));
 
-               $expectedResult = 'mod.php?M=moduleKey&somePrefix%5BsomeDomainObject%5D%5Buid%5D=123';
+               $expectedResult = 'mod.php?M=moduleKey&somePrefix%5BsomeDomainObject%5D=123';
                $actualResult = $this->uriBuilder->buildBackendUri();
 
                $this->assertEquals($expectedResult, $actualResult);
@@ -376,7 +376,7 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder_testcase extends Tx_Extbase_Base_tes
                $this->uriBuilder->setTargetPageUid(123);
                $this->uriBuilder->setArguments(array('someDomainObject' => $mockDomainObject1, 'baz' => array('someOtherDomainObject' => $mockDomainObject2)));
 
-               $expectedConfiguration = array('parameter' => 123, 'useCacheHash' => 1, 'additionalParams' => '&someDomainObject%5Buid%5D=123&baz%5BsomeOtherDomainObject%5D%5Buid%5D=321');
+               $expectedConfiguration = array('parameter' => 123, 'useCacheHash' => 1, 'additionalParams' => '&someDomainObject=123&baz%5BsomeOtherDomainObject%5D=321');
                $actualConfiguration = $this->uriBuilder->_call('buildTypolinkConfiguration');
 
                $this->assertEquals($expectedConfiguration, $actualConfiguration);
@@ -457,7 +457,7 @@ class Tx_Extbase_MVC_Web_Routing_UriBuilder_testcase extends Tx_Extbase_Base_tes
                $mockDomainObject2 = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_DomainObject_AbstractEntity'), array('dummy'));
                $mockDomainObject2->_set('uid', '321');
 
-               $expectedResult = array('foo' => array('bar' => 'baz'), 'domainObject1' => array('uid' => '123'), 'second' => array('domainObject2' => array('uid' => '321')));
+               $expectedResult = array('foo' => array('bar' => 'baz'), 'domainObject1' => '123', 'second' => array('domainObject2' =>'321'));
                $actualResult = $this->uriBuilder->_call('convertDomainObjectsToIdentityArrays', array('foo' => array('bar' => 'baz'), 'domainObject1' => $mockDomainObject1, 'second' => array('domainObject2' => $mockDomainObject2)));
 
                $this->assertEquals($expectedResult, $actualResult);
index b6bb241..ee978ac 100644 (file)
@@ -49,7 +49,7 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_Base_t
         */
        public function resolveValidatorObjectNameReturnsTheGivenArgumentIfAnObjectOfThatNameIsRegistered() {
                $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
-               $validatorName = uniqid('FooValidator_');
+               $validatorName = uniqid('FooValidator_') . 'Validator';
                eval('class ' . $validatorName . ' {}');
                $validatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'));
                $validatorResolver->_set('objectManager', $mockObjectManager);