| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace AlgoWeb\ODataMetadata\Tests; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use AlgoWeb\ODataMetadata\IsOK; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use AlgoWeb\ODataMetadata\MetadataManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer\EntitySetAnonymousType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\Schema; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TAssociationType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TComplexTypePropertyType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TComplexTypeType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityPropertyType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TNavigationPropertyType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edm\TTextType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edmx\Edmx; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use AlgoWeb\ODataMetadata\MetadataV3\edmx\TDataServicesType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Mockery as m; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class MetadataManagerTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     public function testIsOKAtDefault() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $ds = DIRECTORY_SEPARATOR; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $edmx = $metadataManager->getEdmx(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertTrue($edmx->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->assertNull($msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $d = $metadataManager->getEdmxXML(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->v3MetadataAgainstXSD($d); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 38 |  | View Code Duplication |     public function v3MetadataAgainstXSD($data) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $ds = DIRECTORY_SEPARATOR; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $goodxsd = dirname(__DIR__) . $ds . 'xsd' . $ds . 'Microsoft.Data.Entity.Design.Edmx_3.Fixed.xsd'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         if (!file_exists($goodxsd)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $xml = new \DOMDocument(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $xml->loadXML($data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         return $xml->schemaValidate($goodxsd); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     public function testEntitysAndProperties() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $result = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         list($eType, $result) = $metadataManager->addEntityType('Category'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $this->assertNotFalse($eType, 'Etype is false not type ' . $metadataManager->getLastError()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $metadataManager->addPropertyToEntityType($eType, 'CategoryID', 'Int32', null, false, true, 'Identity'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $metadataManager->addPropertyToEntityType($eType, 'CategoryName', 'String'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $metadataManager->addPropertyToEntityType($eType, 'Description', 'String'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $metadataManager->addPropertyToEntityType($eType, 'Picture', 'Binary'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         list($eType, $result) = $metadataManager->addEntityType('CustomerDemographic'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $metadataManager->addPropertyToEntityType($eType, 'CustomerTypeID', 'String', null, false, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $metadataManager->addPropertyToEntityType($eType, 'CustomerDesc', 'String'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $edmx = $metadataManager->getEdmx(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $this->assertTrue($edmx->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->assertNull($msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $d = $metadataManager->getEdmxXML(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $this->v3MetadataAgainstXSD($d); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function testEntitysAndPropertiesAndNavigationProperties() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $result = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         list($CategoryType, $result) = $metadataManager->addEntityType('Category'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $this->assertNotFalse($CategoryType, 'Etype is false not type ' . $metadataManager->getLastError()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $metadataManager->addPropertyToEntityType($CategoryType, 'CategoryID', 'Int32', null, false, true, 'Identity'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $metadataManager->addPropertyToEntityType($CategoryType, 'CategoryName', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $metadataManager->addPropertyToEntityType($CategoryType, 'Description', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $metadataManager->addPropertyToEntityType($CategoryType, 'Picture', 'Binary'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         list($CustomerDemographicType, $result) = $metadataManager->addEntityType('CustomerDemographic'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $metadataManager->addPropertyToEntityType($CustomerDemographicType, 'CustomerTypeID', 'String', null, false, true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $metadataManager->addPropertyToEntityType($CustomerDemographicType, 'CustomerDesc', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         list($CustomerType, $result) = $metadataManager->addEntityType('Customer'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'CustomerID', 'String', null, false, true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'CompanyName', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'ContactName', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'ContactTitle', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'Address', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'City', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'Region', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'PostalCode', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'Country', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'Phone', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $metadataManager->addPropertyToEntityType($CustomerType, 'Fax', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         list($EmployeeType, $result) = $metadataManager->addEntityType('Employee'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'EmployeeID', 'Int32', null, false, true, 'Identity'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'LastName', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'FirstName', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'Title', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'TitleOfCourtesy', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'BirthDate', 'DateTime'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'HireDate', 'DateTime'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'Address', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'City', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'Region', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'PostalCode', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'Country', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'HomePhone', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'Extension', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'Photo', 'Binary'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'Notes', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'ReportsTo', 'Int32'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         $metadataManager->addPropertyToEntityType($EmployeeType, 'PhotoPath', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         list($Order_DetailType, $result) = $metadataManager->addEntityType('Order_Detail'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $metadataManager->addPropertyToEntityType($Order_DetailType, 'OrderID', 'Int32', null, false, true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $metadataManager->addPropertyToEntityType($Order_DetailType, 'ProductID', 'Int32', null, false, true); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         $metadataManager->addPropertyToEntityType($Order_DetailType, 'UnitPrice', 'Decimal'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         $metadataManager->addPropertyToEntityType($Order_DetailType, 'Quantity', 'Int16'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         $metadataManager->addPropertyToEntityType($Order_DetailType, 'Discount', 'Single'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         list($OrderType, $result) = $metadataManager->addEntityType('Order'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'OrderID', 'Int32', null, false, true, 'Identity'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'CustomerID', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'EmployeeID', 'Int32'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'OrderDate', 'DateTime'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'RequiredDate', 'DateTime'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShippedDate', 'DateTime'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShipVia', 'DateTime'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'Freight', 'Decimal'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShipName', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShipAddress', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShipCity', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShipRegion', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShipPostalCode', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         $metadataManager->addPropertyToEntityType($OrderType, 'ShipCountry', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         list($ProductType, $result) = $metadataManager->addEntityType('Product'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'ProductID', 'Int32', null, false, true, 'Identity'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'ProductName', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'SupplierID', 'Int32'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'CategoryID', 'Int32'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'QuantityPerUnit', 'String'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'UnitPrice', 'Decimal'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'UnitsInStock', 'Int16'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'UnitsOnOrder', 'Int16'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'ReorderLevel', 'Int16'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $metadataManager->addPropertyToEntityType($ProductType, 'Discontinued', 'Boolean'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         $expectedRelation = 'Data.Category_Products_Product_Category'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         list($principalNav, ) = $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             $CategoryType, '*', 'Products', $ProductType, '1', 'Category', ['CategoryID'], ['CategoryID'] | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         $this->assertEquals($expectedRelation, $principalNav->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             $Order_DetailType, '1', 'Order', $ProductType, '*', 'Order_Details', ['OrderID'], ['CategoryID'] | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | //        <NavigationProperty Name="Order_Details" Relationship="NorthwindModel.FK_Order_Details_Products" ToRole="Order_Details" FromRole="Products"/> | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $edmx = $metadataManager->getEdmx(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         $this->assertTrue($edmx->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         $this->assertNull($msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         $d = $metadataManager->getEdmxXML(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $this->v3MetadataAgainstXSD($d); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     public function testAddManyToManyNavProperty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         $expectedRelation = 'Data.Category_custom_Customer_categor'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             'custom', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             'categor' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $this->assertEquals('custom', $principal->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         $this->assertEquals('categor', $dependent->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $this->assertEquals($expectedRelation, $principal->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |         $this->assertEquals($expectedRelation, $dependent->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         $navProps = [$principal, $dependent]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         $this->assertEquals(1, count($assoc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         $assoc = $assoc[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         $this->assertTrue($assoc instanceof TAssociationType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         $this->assertTrue($assoc->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |         $ends = $assoc->getEnd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         $this->assertEquals(2, count($ends)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $this->checkNavProps($navProps, $ends); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $this->assertEquals('*', $principalEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $this->assertEquals('*', $dependentEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 226 |  | View Code Duplication |     public function testAddOneToManyNavProperty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |             'custom', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |             $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             'categor' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         $this->assertEquals('custom', $principal->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         $this->assertEquals('categor', $dependent->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         $navProps = [$principal, $dependent]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         $this->assertEquals(1, count($assoc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         $assoc = $assoc[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         $this->assertTrue($assoc instanceof TAssociationType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         $this->assertTrue($assoc->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         $ends = $assoc->getEnd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         $this->assertEquals(2, count($ends)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         $this->checkNavProps($navProps, $ends); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $this->assertEquals('*', $principalEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         $this->assertEquals('1', $dependentEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 260 |  | View Code Duplication |     public function testAddManyToOneNavProperty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |         list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             'custom', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |             '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |             'categor' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |         $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         $this->assertEquals('custom', $principal->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |         $this->assertEquals('categor', $dependent->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |         $navProps = [$principal, $dependent]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         $this->assertEquals(1, count($assoc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         $assoc = $assoc[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         $this->assertTrue($assoc instanceof TAssociationType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         $this->assertTrue($assoc->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |         $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |         $ends = $assoc->getEnd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         $this->assertEquals(2, count($ends)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         $this->checkNavProps($navProps, $ends); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         $this->assertEquals('1', $principalEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         $this->assertEquals('*', $dependentEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 294 |  | View Code Duplication |     public function testAddOneToOneForwardNavProperty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |             $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |             '0..1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             'custom', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |             $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |             '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |             'categor' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |         $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |         $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |         $this->assertEquals('custom', $principal->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         $this->assertEquals('categor', $dependent->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |         $navProps = [$principal, $dependent]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |         $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |         $this->assertEquals(1, count($assoc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         $assoc = $assoc[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         $this->assertTrue($assoc instanceof TAssociationType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |         $this->assertTrue($assoc->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |         $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         $ends = $assoc->getEnd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |         $this->assertEquals(2, count($ends)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |         $this->checkNavProps($navProps, $ends); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |         $this->assertEquals('0..1', $principalEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |         $this->assertEquals('1', $dependentEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 328 |  | View Code Duplication |     public function testAddOneToOneReverseNavProperty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         list($msg, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         list($principal, $dependent) = $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |             $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |             '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |             'custom', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |             $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |             '0..1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |             'categor' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         $this->assertEquals($principal->getFromRole(), $dependent->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         $this->assertEquals($dependent->getFromRole(), $principal->getToRole()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |         $this->assertEquals('custom', $principal->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         $this->assertEquals('categor', $dependent->getName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         $navProps = [$principal, $dependent]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         $assoc = $metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getAssociation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         $this->assertEquals(1, count($assoc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |         $assoc = $assoc[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         $this->assertTrue($assoc instanceof TAssociationType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         $this->assertTrue($assoc->isOK($msg), $msg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |         $this->assertEquals('Data.'.$assoc->getName(), $principal->getRelationship()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |         $ends = $assoc->getEnd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $this->assertEquals(2, count($ends)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |         $this->checkNavProps($navProps, $ends); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         list($principalEnd, $dependentEnd) = $this->figureOutEnds($ends, $principal, $dependent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         $this->assertEquals('1', $principalEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |         $this->assertEquals('0..1', $dependentEnd->getMultiplicity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |     public function testMetadataSerialiseRoundTrip() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         $bar = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |         $foo = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         $cereal = serialize($foo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $foo = unserialize($cereal); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         $this->assertTrue(null != $foo->getSerialiser()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         $this->assertEquals($bar, $foo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 374 |  | View Code Duplication |     public function testCreateSingletonBadReturnType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         $returnType = m::mock(IsOK::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         $foo = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |         $expected = 'Expected return type must be either TEntityType or TComplexType'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |             $foo->createSingleton(null, $returnType, null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 390 |  | View Code Duplication |     public function testCreateSingletonEmptyName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |         $returnType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         $this->assertTrue($returnType instanceof TEntityTypeType, get_class($returnType)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         $foo = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |         $expected = 'Name must be a non-empty string'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |             $foo->createSingleton(null, $returnType, null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 407 |  | View Code Duplication |     public function testCreateSingletonNonStringName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |         $returnType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |         $this->assertTrue($returnType instanceof TEntityTypeType, get_class($returnType)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |         $foo = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |         $expected = 'Name must be a non-empty string'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |             $foo->createSingleton($returnType, $returnType, null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |     public function testCreateSingletonSuccessful() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |         $name = 'singleton'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         $returnType = m::mock(TEntityTypeType::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         $returnType->shouldReceive('getName')->andReturn('doubleton'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         $entityContainer = m::mock(EntityContainer::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |         $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |         $schema = m::mock(Schema::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |         $services = m::mock(TDataServicesType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |         $services->shouldReceive('getSchema')->andReturn([$schema])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |         $edmx = m::mock(Edmx::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |         $edmx->shouldReceive('getDataServiceType')->andReturn($services); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |         $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |         $foo->shouldReceive('getEdmx')->andReturn($edmx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |         $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |         $result = $foo->createSingleton($name, $returnType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |         $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         $this->assertTrue($result->isOK($msg)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 452 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 453 |  |  |     public function testCreateSingletonSuccessfulWithEntitySet() | 
            
                                                                        
                            
            
                                    
            
            
                | 454 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 455 |  |  |         $msg = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 456 |  |  |         $name = 'singleton'; | 
            
                                                                        
                            
            
                                    
            
            
                | 457 |  |  |         $returnType = m::mock(TEntityTypeType::class)->makePartial(); | 
            
                                                                        
                            
            
                                    
            
            
                | 458 |  |  |         $returnType->shouldReceive('getName')->andReturn('doubleton'); | 
            
                                                                        
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 460 |  |  |         $entityContainer = m::mock(EntityContainer::class)->makePartial(); | 
            
                                                                        
                            
            
                                    
            
            
                | 461 |  |  |         $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once(); | 
            
                                                                        
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 463 |  |  |         $schema = m::mock(Schema::class)->makePartial(); | 
            
                                                                        
                            
            
                                    
            
            
                | 464 |  |  |         $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once(); | 
            
                                                                        
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 466 |  |  |         $services = m::mock(TDataServicesType::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 467 |  |  |         $services->shouldReceive('getSchema')->andReturn([$schema])->once(); | 
            
                                                                        
                            
            
                                    
            
            
                | 468 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 469 |  |  |         $edmx = m::mock(Edmx::class)->makePartial(); | 
            
                                                                        
                            
            
                                    
            
            
                | 470 |  |  |         $edmx->shouldReceive('getDataServiceType')->andReturn($services); | 
            
                                                                        
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 472 |  |  |         $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods(); | 
            
                                                                        
                            
            
                                    
            
            
                | 473 |  |  |         $foo->shouldReceive('getEdmx')->andReturn($edmx); | 
            
                                                                        
                            
            
                                    
            
            
                | 474 |  |  |         $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1); | 
            
                                                                        
                            
            
                                    
            
            
                | 475 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 476 |  |  |         $entitySet = m::mock(EntitySetAnonymousType::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 477 |  |  |         $entitySet->shouldReceive('getName')->andReturn('BorkBorkBorken')->atLeast(1); | 
            
                                                                        
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 479 |  |  |         $result = $foo->createSingleton($name, $returnType, $entitySet); | 
            
                                                                        
                            
            
                                    
            
            
                | 480 |  |  |         $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result)); | 
            
                                                                        
                            
            
                                    
            
            
                | 481 |  |  |         $this->assertTrue($result->isOK($msg)); | 
            
                                                                        
                            
            
                                    
            
            
                | 482 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                        
                            
            
                                    
            
            
                | 483 |  |  |         $this->assertEquals('BorkBorkBorken', $result->getReturnType()[0]->getEntitySetAttribute()); | 
            
                                                                        
                            
            
                                    
            
            
                | 484 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 486 |  | View Code Duplication |     public function testCreateSingletonWithDocumentation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |         $name = 'singleton'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         $shortDesc = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         $longDesc = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |         $returnType = m::mock(TEntityTypeType::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |         $returnType->shouldReceive('getName')->andReturn('doubleton'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |         $entityContainer = m::mock(EntityContainer::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |         $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |         $schema = m::mock(Schema::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |         $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |         $edmx = m::mock(Edmx::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |         $edmx->shouldReceive('getDataServiceType->getSchema')->andReturn([$schema])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |         $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |         $foo->shouldReceive('getEdmx')->andReturn($edmx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         $result = $foo->createSingleton($name, $returnType, null, $shortDesc, $longDesc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |         $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         $this->assertTrue($result->isOK($msg)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |         $this->assertNotNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 514 |  | View Code Duplication |     public function testCreateSingletonWithDocumentationOnlyShortDesc() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |         $name = 'singleton'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |         $shortDesc = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |         $longDesc = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |         $returnType = m::mock(TEntityTypeType::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |         $returnType->shouldReceive('getName')->andReturn('doubleton'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |         $entityContainer = m::mock(EntityContainer::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |         $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |         $schema = m::mock(Schema::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |         $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |         $edmx = m::mock(Edmx::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |         $edmx->shouldReceive('getDataServiceType->getSchema')->andReturn([$schema])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |         $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |         $foo->shouldReceive('getEdmx')->andReturn($edmx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |         $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |         $result = $foo->createSingleton($name, $returnType, null, $shortDesc, $longDesc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |         $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |         $this->assertTrue($result->isOK($msg)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 542 |  | View Code Duplication |     public function testCreateSingletonWithDocumentationOnlyLongDesc() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |         $name = 'singleton'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |         $shortDesc = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |         $longDesc = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         $returnType = m::mock(TEntityTypeType::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |         $returnType->shouldReceive('getName')->andReturn('doubleton'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |         $entityContainer = m::mock(EntityContainer::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |         $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |         $schema = m::mock(Schema::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |         $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |         $edmx = m::mock(Edmx::class)->makePartial(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |         $edmx->shouldReceive('getDataServiceType->getSchema')->andReturn([$schema])->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |         $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |         $foo->shouldReceive('getEdmx')->andReturn($edmx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |         $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |         $result = $foo->createSingleton($name, $returnType, $shortDesc, $longDesc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |         $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |         $this->assertTrue($result->isOK($msg)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 570 |  | View Code Duplication |     public function testMalformedMultiplicity() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |         list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |         $expected = 'Malformed multiplicity - valid values are *, 0..1 and 1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |             $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |                 $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |                 '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |                 'Customers', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |                 $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |                 'ABC', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |                 'Categories' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 592 |  | View Code Duplication |     public function testInvalidMultiplicityBelongsOnBothEnds() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |         list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |         $expected =  'Invalid multiplicity combination - 1 1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |             $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |                 $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |                 '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |                 'Customers', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |                 $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |                 '1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |                 'Categories' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 614 |  | View Code Duplication |     public function testInvalidMultiplicityManyToHasMany() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |         list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |         $expected =  'Invalid multiplicity combination - * 0..1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |             $metadataManager->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |                 $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |                 '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |                 'Customers', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |                 $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |                 '0..1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |                 'Categories' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 636 |  | View Code Duplication |     public function testAddComplexType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |         $name = 'Name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |         $accessType = 'Public'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |         $oldCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |         $result = $metadataManager->addComplexType($name, $accessType, $summary, $longDescription); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |         $newCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |         $this->assertEquals($oldCount+1, $newCount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |         $this->assertNotNull($result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |         $this->assertTrue($result instanceof TComplexTypeType, get_class($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |         $this->assertNotNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 656 |  | View Code Duplication |     public function testAddComplexTypeWithOnlySummary() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |         $name = 'Name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |         $accessType = 'Public'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |         $longDescription = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |         $oldCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |         $result = $metadataManager->addComplexType($name, $accessType, $summary, $longDescription); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |         $newCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |         $this->assertEquals($oldCount+1, $newCount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |         $this->assertNotNull($result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |         $this->assertTrue($result instanceof TComplexTypeType, get_class($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 676 |  | View Code Duplication |     public function testAddComplexTypeWithOnlyDescription() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |         $name = 'Name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |         $accessType = 'Public'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |         $summary = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |         $oldCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |         $result = $metadataManager->addComplexType($name, $accessType, $summary, $longDescription); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |         $newCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |         $this->assertEquals($oldCount+1, $newCount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |         $this->assertNotNull($result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |         $this->assertTrue($result instanceof TComplexTypeType, get_class($result)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 696 |  | View Code Duplication |     public function testAddPropertyToComplexTypeDefaultValueArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |         $expected = 'Default value cannot be object or array'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |         $complex = m::mock(TComplexTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |         $defaultValue = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |             $metadataManager->addPropertyToComplexType($complex, $name, $type, $defaultValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 715 |  | View Code Duplication |     public function testAddPropertyToComplexTypeDefaultValueObject() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |         $expected = 'Default value cannot be object or array'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |         $complex = m::mock(TComplexTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |         $defaultValue = new \stdClass(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |             $metadataManager->addPropertyToComplexType($complex, $name, $type, $defaultValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 734 |  | View Code Duplication |     public function testAddPropertyToComplexTypeDefaultValueBoolean() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  |         $complex = m::mock(TComplexTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  |         $complex->shouldReceive('addToProperty') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  |             ->with(m::type(TComplexTypePropertyType::class))->andReturnNull()->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  |         $defaultValue = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |         $expectedDefault = 'true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  |         $result = $metadataManager->addPropertyToComplexType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  |             $complex, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  |             $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |             $type, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  |             $defaultValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  |             $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  |             $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  |         $this->assertEquals(1, count($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  |         $this->assertEquals($expectedDefault, $result->getDefaultValue()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 760 |  | View Code Duplication |     public function testAddPropertyToComplexTypeDefaultValueBooleanOnlySummary() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  |         $complex = m::mock(TComplexTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  |         $complex->shouldReceive('addToProperty') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |             ->with(m::type(TComplexTypePropertyType::class))->andReturnNull()->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |         $defaultValue = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |         $longDescription = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |         $expectedDefault = 'true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |         $result = $metadataManager->addPropertyToComplexType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |             $complex, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |             $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |             $type, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |             $defaultValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |             $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |             $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  |         $this->assertNotNull($result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  |         $this->assertEquals(0, count($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |         $this->assertEquals($expectedDefault, $result->getDefaultValue()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 787 |  | View Code Duplication |     public function testAddPropertyToComplexTypeDefaultValueBooleanOnlyDescription() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  |         list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  |         $complex = m::mock(TComplexTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |         $complex->shouldReceive('addToProperty') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  |             ->with(m::type(TComplexTypePropertyType::class))->andReturnNull()->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |         $defaultValue = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |         $summary = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |         $expectedDefault = 'true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |         $result = $metadataManager->addPropertyToComplexType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  |             $complex, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |             $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |             $type, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |             $defaultValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |             $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  |             $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |         $this->assertEquals(0, count($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |         $this->assertEquals($expectedDefault, $result->getDefaultValue()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 813 |  | View Code Duplication |     public function testAddPropertyToEntityType() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |         $entity = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |         $entity->shouldReceive('addToProperty') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |             ->with(m::type(TEntityPropertyType::class))->andReturnNull()->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |         $defaultValue = 'true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |         $result = $metadataManager->addPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  |             $entity, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |             $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |             $type, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |             $defaultValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |             null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |             $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  |             $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |         $this->assertNotNull($result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |         $this->assertTrue(is_array($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |         $this->assertEquals(1, count($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |         $this->assertEquals('true', $result->getDefaultValue()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 842 |  | View Code Duplication |     public function testAddPropertyToEntityTypeOnlySummary() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  |         $entity = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  |         $entity->shouldReceive('addToProperty') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |             ->with(m::type(TEntityPropertyType::class))->andReturnNull()->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  |         $defaultValue = 'true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |         $longDescription = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |         $result = $metadataManager->addPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |             $entity, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |             $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |             $type, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |             $defaultValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |             null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |             $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |             $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |         $this->assertNotNull($result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |         $this->assertTrue(is_array($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |         $this->assertEquals(0, count($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |         $this->assertEquals('true', $result->getDefaultValue()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 871 |  | View Code Duplication |     public function testAddPropertyToEntityTypeOnlyDescription() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |         $entity = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  |         $entity->shouldReceive('addToProperty') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |             ->with(m::type(TEntityPropertyType::class))->andReturnNull()->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |         $type = 'type'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |         $summary = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |         $defaultValue = 'true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |         $result = $metadataManager->addPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |             $entity, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |             $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |             $type, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |             $defaultValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |             null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |             $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |             $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |         $this->assertNotNull($result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |         $this->assertTrue(is_array($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |         $this->assertEquals(0, count($result->getDocumentation())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |         $this->assertEquals('true', $result->getDefaultValue()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 900 |  | View Code Duplication |     public function testAddEntityTypeWithDocumentation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |         $accessType = 'Public'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |         list($result, ) = $metadataManager->addEntityType($name, null, false, $accessType, $summary, $longDescription); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |         $this->assertNotNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 912 |  | View Code Duplication |     public function testAddEntityTypeWithDocumentationFromOnlySummary() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |         $accessType = 'Public'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |         $longDescription = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |         list($result, ) = $metadataManager->addEntityType($name, null, false, $accessType, $summary, $longDescription); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 924 |  | View Code Duplication |     public function testAddEntityTypeWithDocumentationFromOnlyDocumentation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |         $name = 'name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  |         $accessType = 'Public'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  |         $summary = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |         $metadataManager = new MetadataManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |         list($result, ) = $metadataManager->addEntityType($name, null, false, $accessType, $summary, $longDescription); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |         $this->assertNull($result->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 936 |  | View Code Duplication |     public function testAddNavigationPropertyToEntityTypeWithDocumentation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |         list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  |         $mult = '*'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |         $principalProperty = 'Categories'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |         $dependentProperty = 'Customers'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |         list($principal, $dependent) = $metadataManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |             ->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |                 $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  |                 $mult, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |                 $principalProperty, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  |                 $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |                 $mult, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  |                 $dependentProperty, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |                 $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |                 $longDescription, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |                 $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  |                 $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  |         $this->assertNotNull($principal->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  |         $this->assertNotNull($dependent->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 970 |  | View Code Duplication |     public function testAddNavigationPropertyToEntityTypeWithDocumentationWithOnlySummary() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  |         list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  |         $summary = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  |         $longDescription = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  |         $mult = '*'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  |         $principalProperty = 'Categories'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  |         $dependentProperty = 'Customers'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  |         list($principal, $dependent) = $metadataManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  |             ->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  |                 $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  |                 $mult, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  |                 $principalProperty, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  |                 $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  |                 $mult, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  |                 $dependentProperty, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  |                 $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  |                 $longDescription, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  |                 $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  |                 $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  |         $this->assertNull($principal->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  |         $this->assertNull($dependent->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1004 |  | View Code Duplication |     public function testAddNavigationPropertyToEntityTypeWithDocumentationWithOnlyDescription() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  |         list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  |         $summary = new TTextType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  |         $longDescription = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  |         $mult = '*'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  |         $principalProperty = 'Categories'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  |         $dependentProperty = 'Customers'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  |         list($principal, $dependent) = $metadataManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  |             ->addNavigationPropertyToEntityType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  |                 $CategoryType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  |                 $mult, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  |                 $principalProperty, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  |                 $CustomerType, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  |                 $mult, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  |                 $dependentProperty, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  |                 'Public', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  |                 $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  |                 $longDescription, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  |                 $summary, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  |                 $longDescription | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  |         $this->assertNull($principal->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  |         $this->assertNull($dependent->getDocumentation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  |     public function testCreateAssociationFromNavigationPropertyRelationMismatch() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  |         $principalType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  |         $dependentType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  |         $principalNav = m::mock(TNavigationPropertyType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  |         $principalNav->shouldReceive('getRelationship')->andReturn('foo')->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  |         $dependentNav = m::mock(TNavigationPropertyType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  |         $dependentNav->shouldReceive('getRelationship')->andReturn('bar')->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  |         $metadataManager = new MetadataManagerDummy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  |         $expected = 'If you have both a dependent property and a principal property, relationship should match'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  |             $metadataManager->createAssocationFromNavigationProperty( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  |                 $principalType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  |                 $dependentType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  |                 $principalNav, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  |                 $dependentNav, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  |                 '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  |                 '*' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1067 |  | View Code Duplication |     public function testCreateAssociationFromNavigationPropertyForwardRoleMismatch() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  |         $principalType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  |         $dependentType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  |         $principalNav = m::mock(TNavigationPropertyType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  |         $principalNav->shouldReceive('getRelationship')->andReturn('foo')->once(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  |         $principalNav->shouldReceive('getToRole')->andReturn('Forwards'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  |         $principalNav->shouldReceive('getFromRole')->andReturn('Reverse'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  |         $dependentNav = m::mock(TNavigationPropertyType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  |         $dependentNav->shouldReceive('getRelationship')->andReturn('foo')->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  |         $dependentNav->shouldReceive('getToRole')->andReturn('Reverse'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  |         $dependentNav->shouldReceive('getFromRole')->andReturn('Sideways'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  |         $metadataManager = new MetadataManagerDummy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  |         $expected = 'Principal to role should match dependent from role, and vice versa'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  |             $metadataManager->createAssocationFromNavigationProperty( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  |                 $principalType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  |                 $dependentType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  |                 $principalNav, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  |                 $dependentNav, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  |                 '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  |                 '*' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1100 |  | View Code Duplication |     public function testCreateAssociationFromNavigationPropertyReverseRoleMismatch() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  |         $principalType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  |         $dependentType = m::mock(TEntityTypeType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  |         $principalNav = m::mock(TNavigationPropertyType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  |         $principalNav->shouldReceive('getRelationship')->andReturn('foo')->once(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  |         $principalNav->shouldReceive('getToRole')->andReturn('Forwards'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  |         $principalNav->shouldReceive('getFromRole')->andReturn('Reverse'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  |         $dependentNav = m::mock(TNavigationPropertyType::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  |         $dependentNav->shouldReceive('getRelationship')->andReturn('foo')->once(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  |         $dependentNav->shouldReceive('getToRole')->andReturn('Sideways'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  |         $dependentNav->shouldReceive('getFromRole')->andReturn('Forwards'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  |         $metadataManager = new MetadataManagerDummy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  |         $expected = 'Principal to role should match dependent from role, and vice versa'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  |         $actual = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  |             $metadataManager->createAssocationFromNavigationProperty( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  |                 $principalType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  |                 $dependentType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  |                 $principalNav, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  |                 $dependentNav, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  |                 '*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  |                 '*' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  |         } catch (\InvalidArgumentException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  |             $actual = $e->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  |         $this->assertEquals($expected, $actual); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  |     private function setUpMetadataForNavTests() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  |         $msg = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  |         $metadataManager = new MetadataManager('Data', 'Container'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  |         $expectedCategorySetName = 'Categories'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  |         $expectedCustomerSetName = 'Customers'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  |         list($CategoryType, $CategorySet) = $metadataManager->addEntityType('Category'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  |         list($CustomerType, $CustomerSet) = $metadataManager->addEntityType('Customer'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  |         $this->assertTrue($CategoryType->isOK($msg), $msg); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  |         $this->assertTrue($CustomerType->isOK($msg), $msg); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  |         $this->assertEquals($expectedCategorySetName, $CategorySet->getName()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  |         $this->assertEquals($expectedCustomerSetName, $CustomerSet->getName()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  |         return [$msg, $metadataManager, $CategoryType, $CustomerType]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  |      * @param $navProps | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  |      * @param $ends | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  |     private function checkNavProps($navProps, $ends) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  |         foreach ($navProps as $prop) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  |             $propToRole = $prop->getToRole(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  |             $propFromRole = $prop->getFromRole(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  |             $fromMatch = $ends[0]->getRole() == $propToRole | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  |                          || $ends[1]->getRole() == $propToRole; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  |             $this->assertTrue($fromMatch, 'toRole must match at least one end role'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  |             if ($ends[0]->getRole() == $propToRole) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  |                 $this->assertEquals($ends[1]->getRole(), $propFromRole); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  |                 $this->assertNotEquals($ends[0]->getRole(), $propFromRole); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  |                 $this->assertEquals($ends[0]->getRole(), $propFromRole); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  |                 $this->assertNotEquals($ends[1]->getRole(), $propFromRole); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  |      * @param $ends | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  |      * @param $principal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  |      * @param $dependent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  |     private function figureOutEnds($ends, $principal, $dependent) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  |         // if role is from Products, then type must be from Products - ie, use getFromRole | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  |         $principalEnd = ($ends[0]->getRole() == $principal->getFromRole()) ? $ends[0] : $ends[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  |         $dependentEnd = ($ends[0]->getRole() == $dependent->getFromRole()) ? $ends[0] : $ends[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  |         return [$principalEnd, $dependentEnd]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1187 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 1188 |  |  |  | 
            
                        
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.