| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Doctrine\Tests\ORM\Functional\Ticket; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | class DDC2182Test extends \Doctrine\Tests\OrmFunctionalTestCase | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 6 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  |     public function testPassColumnOptionsToJoinColumns() | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  |         if ($this->_em->getConnection()->getDatabasePlatform()->getName() != 'mysql') { | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  |             $this->markTestSkipped("This test is useful for all databases, but designed only for mysql."); | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |         $sql = $this->_schemaTool->getCreateSchemaSql( | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |             $this->_em->getClassMetadata(DDC2182OptionParent::class), | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |             $this->_em->getClassMetadata(DDC2182OptionChild::class), | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |             ] | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |         $collation = $this->getColumnCollationDeclarationSQL('utf8_unicode_ci'); | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |         $this->assertEquals("CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 $collation ENGINE = InnoDB", $sql[0]); | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |         $this->assertEquals("CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 $collation ENGINE = InnoDB", $sql[1]); | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |         $this->assertEquals("ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)", $sql[2]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private function getColumnCollationDeclarationSQL(string $collation) : string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         if (method_exists($this->_em->getConnection()->getDatabasePlatform(), 'getColumnCollationDeclarationSQL')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |             return $this->_em->getConnection()->getDatabasePlatform()->getColumnCollationDeclarationSQL($collation); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         return 'COLLATE ' . $collation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * @Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * @Table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | class DDC2182OptionParent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     /** @Id @Column(type="integer", options={"unsigned": true}) */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     private $id; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  * @Entity | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  * @Table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | class DDC2182OptionChild | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** @Id @Column */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     private $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @ManyToOne(targetEntity="DDC2182OptionParent") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @JoinColumn(referencedColumnName="id") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     private $parent; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 60 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 61 |  |  |  |