|
@@ 1128-1143 (lines=16) @@
|
| 1125 |
|
return $reflectionMethod; |
| 1126 |
|
} |
| 1127 |
|
|
| 1128 |
|
public function testValidateModelDefinitionsFailsWithArray() { |
| 1129 |
|
Config::nest(); |
| 1130 |
|
|
| 1131 |
|
$object = new DataObjectTest_Team; |
| 1132 |
|
$method = $this->makeAccessible($object, 'validateModelDefinitions'); |
| 1133 |
|
|
| 1134 |
|
Config::inst()->update('DataObjectTest_Team', 'has_one', array('NotValid' => array('NoArraysAllowed'))); |
| 1135 |
|
$this->setExpectedException('LogicException'); |
| 1136 |
|
|
| 1137 |
|
try { |
| 1138 |
|
$method->invoke($object); |
| 1139 |
|
} catch(Exception $e) { |
| 1140 |
|
Config::unnest(); // Catch the exception so we can unnest config before failing the test |
| 1141 |
|
throw $e; |
| 1142 |
|
} |
| 1143 |
|
} |
| 1144 |
|
|
| 1145 |
|
public function testValidateModelDefinitionsFailsWithIntKey() { |
| 1146 |
|
Config::nest(); |
|
@@ 1145-1160 (lines=16) @@
|
| 1142 |
|
} |
| 1143 |
|
} |
| 1144 |
|
|
| 1145 |
|
public function testValidateModelDefinitionsFailsWithIntKey() { |
| 1146 |
|
Config::nest(); |
| 1147 |
|
|
| 1148 |
|
$object = new DataObjectTest_Team; |
| 1149 |
|
$method = $this->makeAccessible($object, 'validateModelDefinitions'); |
| 1150 |
|
|
| 1151 |
|
Config::inst()->update('DataObjectTest_Team', 'has_many', array(12 => 'DataObjectTest_Player')); |
| 1152 |
|
$this->setExpectedException('LogicException'); |
| 1153 |
|
|
| 1154 |
|
try { |
| 1155 |
|
$method->invoke($object); |
| 1156 |
|
} catch(Exception $e) { |
| 1157 |
|
Config::unnest(); // Catch the exception so we can unnest config before failing the test |
| 1158 |
|
throw $e; |
| 1159 |
|
} |
| 1160 |
|
} |
| 1161 |
|
|
| 1162 |
|
public function testValidateModelDefinitionsFailsWithIntValue() { |
| 1163 |
|
Config::nest(); |
|
@@ 1162-1177 (lines=16) @@
|
| 1159 |
|
} |
| 1160 |
|
} |
| 1161 |
|
|
| 1162 |
|
public function testValidateModelDefinitionsFailsWithIntValue() { |
| 1163 |
|
Config::nest(); |
| 1164 |
|
|
| 1165 |
|
$object = new DataObjectTest_Team; |
| 1166 |
|
$method = $this->makeAccessible($object, 'validateModelDefinitions'); |
| 1167 |
|
|
| 1168 |
|
Config::inst()->update('DataObjectTest_Team', 'many_many', array('Players' => 12)); |
| 1169 |
|
$this->setExpectedException('LogicException'); |
| 1170 |
|
|
| 1171 |
|
try { |
| 1172 |
|
$method->invoke($object); |
| 1173 |
|
} catch(Exception $e) { |
| 1174 |
|
Config::unnest(); // Catch the exception so we can unnest config before failing the test |
| 1175 |
|
throw $e; |
| 1176 |
|
} |
| 1177 |
|
} |
| 1178 |
|
|
| 1179 |
|
/** |
| 1180 |
|
* many_many_extraFields is allowed to have an array value, so shouldn't throw an exception |
|
@@ 1182-1200 (lines=19) @@
|
| 1179 |
|
/** |
| 1180 |
|
* many_many_extraFields is allowed to have an array value, so shouldn't throw an exception |
| 1181 |
|
*/ |
| 1182 |
|
public function testValidateModelDefinitionsPassesWithExtraFields() { |
| 1183 |
|
Config::nest(); |
| 1184 |
|
|
| 1185 |
|
$object = new DataObjectTest_Team; |
| 1186 |
|
$method = $this->makeAccessible($object, 'validateModelDefinitions'); |
| 1187 |
|
|
| 1188 |
|
Config::inst()->update('DataObjectTest_Team', 'many_many_extraFields', |
| 1189 |
|
array('Relations' => array('Price' => 'Int'))); |
| 1190 |
|
|
| 1191 |
|
try { |
| 1192 |
|
$method->invoke($object); |
| 1193 |
|
} catch(Exception $e) { |
| 1194 |
|
Config::unnest(); |
| 1195 |
|
$this->fail('Exception should not be thrown'); |
| 1196 |
|
throw $e; |
| 1197 |
|
} |
| 1198 |
|
|
| 1199 |
|
Config::unnest(); |
| 1200 |
|
} |
| 1201 |
|
|
| 1202 |
|
public function testNewClassInstance() { |
| 1203 |
|
$dataObject = $this->objFromFixture('DataObjectTest_Team', 'team1'); |