Changeset 4776 for trunk/tests

Show
Ignore:
Timestamp:
08/16/08 20:40:59 (5 months ago)
Author:
romanb
Message:

continued refactorings.

Location:
trunk/tests
Files:
3 added
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/tests/lib/mocks/Doctrine_ConnectionMock.php

    r4723 r4776  
    99    private $_sequenceModuleMock; 
    1010    private $_platformMock; 
     11    private $_inserts = array(); 
    1112     
    1213    public function __construct(array $params) 
     
    3132    } 
    3233     
     34    /** 
     35     * @override 
     36     */ 
     37    public function insert($tableName, array $data) 
     38    { 
     39        $this->_inserts[$tableName][] = $data; 
     40    } 
     41     
    3342    /* Mock API */ 
    3443     
     
    4251        $this->_sequenceModuleMock = $seqManager; 
    4352    } 
     53     
     54    public function getInserts() 
     55    { 
     56        return $this->_inserts; 
     57    } 
     58     
     59    public function reset() 
     60    { 
     61        $this->_inserts = array(); 
     62    } 
    4463} 
    4564 
  • trunk/tests/models/cms/CmsArticle.php

    r4718 r4776  
    3535            'length' => 4 
    3636        )); 
    37         $mapping->hasMany('CmsComment as comments', array( 
    38               'local' => 'id', 'foreign' => 'article_id')); 
     37         
     38        /*$mapping->hasMany('CmsComment as comments', array( 
     39              'local' => 'id', 'foreign' => 'article_id'));*/ 
     40         
     41        $mapping->mapOneToMany(array( 
     42            'fieldName' => 'comments', 
     43            'targetEntity' => 'CmsComment', 
     44        )); 
     45         
     46        /*$mapping->mapManyToOne(array( 
     47            'fieldName' => 'author', 
     48            'joinColumns' => array('user_id' => 'id') 
     49        ));*/ 
    3950    } 
    4051} 
  • trunk/tests/models/cms/CmsUser.php

    r4718 r4776  
    3737        )); 
    3838 
    39         $mapping->hasMany('CmsPhonenumber as phonenumbers', array( 
     39        /*$mapping->hasMany('CmsPhonenumber as phonenumbers', array( 
    4040              'local' => 'id', 'foreign' => 'user_id')); 
    4141        $mapping->hasMany('CmsArticle as articles', array( 
    42               'local' => 'id', 'foreign' => 'user_id')); 
     42              'local' => 'id', 'foreign' => 'user_id'));*/ 
     43         
     44        $mapping->mapOneToMany(array( 
     45            'fieldName' => 'phonenumbers', 
     46            'targetEntity' => 'CmsPhonenumber', 
     47             
     48        )); 
     49         
     50        $mapping->mapOneToMany(array( 
     51            'fieldName' => 'articles', 
     52            'targetEntity' => 'CmsArticle', 
     53        )); 
     54         
    4355    } 
    4456} 
  • trunk/tests/models/forum/ForumBoard.php

    r4699 r4776  
    2626        )); 
    2727         
    28         $mapping->hasOne('ForumCategory as category', 
    29                 array('local' => 'category_id', 'foreign' => 'id')); 
    30         /*        
    31         $metadata->mapOneToOne(array( 
    32             'fieldName' => 'category', // optional, defaults to targetEntity 
     28        /*$mapping->hasOne('ForumCategory as category', 
     29                array('local' => 'category_id', 'foreign' => 'id'));*/ 
     30                
     31        $mapping->mapOneToOne(array( 
     32            'fieldName' => 'category', 
    3333            'targetEntity' => 'ForumCategory', 
    3434            'joinColumns' => array('category_id' => 'id') 
    35             ));  
    36         */        
     35        )); 
    3736    } 
    3837} 
  • trunk/tests/models/forum/ForumCategory.php

    r4699 r4776  
    2121        )); 
    2222         
    23         $mapping->hasMany('ForumBoard as boards', array( 
    24                 'local' => 'id' , 'foreign' => 'category_id'));  
     23        /*$mapping->hasMany('ForumBoard as boards', array( 
     24                'local' => 'id' , 'foreign' => 'category_id'));*/ 
     25         
     26        $mapping->mapOneToMany(array( 
     27            'fieldName' => 'boards', 
     28            'targetEntity' => 'ForumBoard' 
     29        )); 
    2530    } 
    2631} 
  • trunk/tests/models/forum/ForumUser.php

    r4718 r4776  
    77class ForumUser extends Doctrine_Entity 
    88{ 
    9     #protected $dtype; 
    109    #protected $id; 
    1110    #protected $username; 
     11    #protected $avatar; 
    1212     
    1313    public static function initMetadata($mapping)  
     
    4343        )); 
    4444         
     45        $mapping->mapOneToOne(array( 
     46            'fieldName' => 'avatar', 
     47            'targetEntity' => 'ForumAvatar', 
     48            'joinColumns' => array('avatar_id' => 'id'), 
     49        )); 
     50         
    4551    } 
    4652     
  • trunk/tests/Orm/AllTests.php

    r4523 r4776  
    1616require_once 'Orm/UnitOfWorkTest.php'; 
    1717require_once 'Orm/EntityManagerFactoryTest.php'; 
     18require_once 'Orm/EntityManagerTest.php'; 
     19require_once 'Orm/EntityPersisterTest.php'; 
    1820 
    1921class Orm_AllTests 
     
    3032        $suite->addTestSuite('Orm_UnitOfWorkTest'); 
    3133        $suite->addTestSuite('Orm_EntityManagerFactoryTest'); 
    32         //$suite->addTestSuite('Orm_ConfigurableTestCase'); 
     34        $suite->addTestSuite('Orm_EntityManagerTest'); 
     35        $suite->addTestSuite('Orm_EntityPersisterTest'); 
    3336         
    3437        $suite->addTest(Orm_Component_AllTests::suite()); 
  • trunk/tests/Orm/Associations/OneToOneMappingTest.php

    r4699 r4776  
    1010            'targetEntity' => 'Address', 
    1111            'joinColumns' => array('address_id' => 'id'), 
    12             'sourceEntity' => 'Person' // This is normally filled by ClassMetadata 
     12            'sourceEntity' => 'Person', // This is normally filled by ClassMetadata 
    1313        ); 
    1414         
     
    2424         
    2525        $inverseSideMapping = array( 
     26            'fieldName' => 'person', 
     27            'sourceEntity' => 'Address', 
     28            'targetEntity' => 'Person', 
    2629            'mappedBy' => 'address' 
    2730        ); 
     
    2932        $oneToOneMapping = new Doctrine_Association_OneToOne($inverseSideMapping); 
    3033        $this->assertEquals('address', $oneToOneMapping->getMappedByFieldName()); 
     34        $this->assertEquals('Address', $oneToOneMapping->getSourceEntityName()); 
     35        $this->assertEquals('Person', $oneToOneMapping->getTargetEntityName()); 
    3136        $this->assertTrue($oneToOneMapping->isInverseSide()); 
    3237         
  • trunk/tests/Orm/Component/AccessTest.php

    r4374 r4776  
    2727 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL 
    2828 * @link        www.phpdoctrine.org 
    29  * @since       1.0 
     29 * @since       2.0 
    3030 * @version     $Revision: 3754 $ 
    3131 */ 
     
    9898    /** 
    9999     * @test  
    100      */ 
    101     public function shouldSetArrayOfValusInRecord() 
    102     { 
    103         $this->user->setArray(array( 
    104             'username' => 'meus', 
    105             'id'       => 22)); 
    106  
    107         $this->assertEquals('meus', $this->user->username); 
    108         $this->assertEquals('meus', $this->user['username']); 
    109  
    110         $this->assertEquals(22, $this->user->id); 
    111         $this->assertEquals(22, $this->user['id']); 
    112     } 
    113  
    114  
    115     /** 
    116      * @test  
    117100     * @expectedException Doctrine_Entity_Exception 
    118101     */ 
     
    129112    { 
    130113        $this->user['rat'] = 'meus'; 
    131     } 
    132  
    133     /** 
    134      * @test  
    135      * @expectedException Doctrine_Entity_Exception 
    136      */ 
    137     public function shouldNotBeAbleToSetNonExistantFieldAsPartInSetArray() 
    138     { 
    139         $this->user->setArray(array( 
    140             'rat' => 'meus', 
    141             'id'  => 22)); 
    142114    } 
    143115 
     
    175147        unset($col->test); 
    176148        $this->assertFalse(isset($col->test)); 
    177     } 
    178  
    179  
    180     /** 
    181      *   
    182      * @test 
    183      * @expectedException Doctrine_Exception 
    184      */ 
    185     public function shouldNotBeAbleToSetNullFieldInRecord() 
    186     { 
    187         $this->user->offsetSet(null, 'test'); 
    188  
    189149    } 
    190150 
  • trunk/tests/Orm/Hydration/BasicHydrationTest.php

    r4523 r4776  
    124124                'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'), 
    125125                'parent' => 'u', 
    126                 'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'), 
     126                'relation' => $this->_em->getClassMetadata('CmsUser')->getAssociationMapping('phonenumbers'), 
    127127                'map' => null 
    128128                ) 
     
    227227                'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'), 
    228228                'parent' => 'u', 
    229                 'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'), 
     229                'relation' => $this->_em->getClassMetadata('CmsUser')->getAssociationMapping('phonenumbers'), 
    230230                'map' => null, 
    231231                'agg' => array('0' => 'numPhones') 
     
    312312                'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'), 
    313313                'parent' => 'u', 
    314                 'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'), 
     314                'relation' => $this->_em->getClassMetadata('CmsUser')->getAssociationMapping('phonenumbers'), 
    315315                'map' => 'phonenumber' 
    316316                ) 
     
    416416                'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'), 
    417417                'parent' => 'u', 
    418                 'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'), 
     418                'relation' => $this->_em->getClassMetadata('CmsUser')->getAssociationMapping('phonenumbers'), 
    419419                'map' => null 
    420420                ), 
     
    422422                'metadata' => $this->_em->getClassMetadata('CmsArticle'), 
    423423                'parent' => 'u', 
    424                 'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('articles'), 
     424                'relation' => $this->_em->getClassMetadata('CmsUser')->getAssociationMapping('articles'), 
    425425                'map' => null 
    426426                ), 
     
    572572                'metadata' => $this->_em->getClassMetadata('CmsPhonenumber'), 
    573573                'parent' => 'u', 
    574                 'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('phonenumbers'), 
     574                'relation' => $this->_em->getClassMetadata('CmsUser')->getAssociationMapping('phonenumbers'), 
    575575                'map' => null 
    576576                ), 
     
    578578                'metadata' => $this->_em->getClassMetadata('CmsArticle'), 
    579579                'parent' => 'u', 
    580                 'relation' => $this->_em->getClassMetadata('CmsUser')->getRelation('articles'), 
     580                'relation' => $this->_em->getClassMetadata('CmsUser')->getAssociationMapping('articles'), 
    581581                'map' => null 
    582582                ), 
     
    584584                'metadata' => $this->_em->getClassMetadata('CmsComment'), 
    585585                'parent' => 'a', 
    586                 'relation' => $this->_em->getClassMetadata('CmsArticle')->getRelation('comments'), 
     586                'relation' => $this->_em->getClassMetadata('CmsArticle')->getAssociationMapping('comments'), 
    587587                'map' => null 
    588588                ), 
     
    780780                'metadata' => $this->_em->getClassMetadata('ForumBoard'), 
    781781                'parent' => 'c', 
    782                 'relation' => $this->_em->getClassMetadata('ForumCategory')->getRelation('boards'), 
     782                'relation' => $this->_em->getClassMetadata('ForumCategory')->getAssociationMapping('boards'), 
    783783                'map' => null 
    784784                ), 
  • trunk/tests/Orm/Query/IdentifierRecognitionTest.php

    r4523 r4776  
    8585 
    8686        $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); 
    87         $this->assertTrue($decl['relation'] instanceof Doctrine_Relation); 
     87        $this->assertTrue($decl['relation'] instanceof Doctrine_Association); 
    8888        $this->assertEquals('u', $decl['parent']); 
    8989        $this->assertEquals(null, $decl['scalar']); 
     
    109109 
    110110        $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); 
    111         $this->assertTrue($decl['relation'] instanceof Doctrine_Relation); 
     111        $this->assertTrue($decl['relation'] instanceof Doctrine_Association); 
    112112        $this->assertEquals('u', $decl['parent']); 
    113113        $this->assertEquals(null, $decl['scalar']); 
     
    117117 
    118118        $this->assertTrue($decl['metadata'] instanceof Doctrine_ClassMetadata); 
    119         $this->assertTrue($decl['relation'] instanceof Doctrine_Relation); 
     119        $this->assertTrue($decl['relation'] instanceof Doctrine_Association); 
    120120        $this->assertEquals('u', $decl['parent']); 
    121121        $this->assertEquals(null, $decl['scalar']);