Code Duplication    Length = 16-19 lines in 4 locations

tests/model/DataObjectTest.php 4 locations

@@ 1108-1123 (lines=16) @@
1105
		return $reflectionMethod;
1106
	}
1107
1108
	public function testValidateModelDefinitionsFailsWithArray() {
1109
		Config::nest();
1110
1111
		$object = new DataObjectTest_Team;
1112
		$method = $this->makeAccessible($object, 'validateModelDefinitions');
1113
1114
		Config::inst()->update('DataObjectTest_Team', 'has_one', array('NotValid' => array('NoArraysAllowed')));
1115
		$this->setExpectedException('LogicException');
1116
1117
		try {
1118
			$method->invoke($object);
1119
		} catch(Exception $e) {
1120
			Config::unnest(); // Catch the exception so we can unnest config before failing the test
1121
			throw $e;
1122
		}
1123
	}
1124
1125
	public function testValidateModelDefinitionsFailsWithIntKey() {
1126
		Config::nest();
@@ 1125-1140 (lines=16) @@
1122
		}
1123
	}
1124
1125
	public function testValidateModelDefinitionsFailsWithIntKey() {
1126
		Config::nest();
1127
1128
		$object = new DataObjectTest_Team;
1129
		$method = $this->makeAccessible($object, 'validateModelDefinitions');
1130
1131
		Config::inst()->update('DataObjectTest_Team', 'has_many', array(12 => 'DataObjectTest_Player'));
1132
		$this->setExpectedException('LogicException');
1133
1134
		try {
1135
			$method->invoke($object);
1136
		} catch(Exception $e) {
1137
			Config::unnest(); // Catch the exception so we can unnest config before failing the test
1138
			throw $e;
1139
		}
1140
	}
1141
1142
	public function testValidateModelDefinitionsFailsWithIntValue() {
1143
		Config::nest();
@@ 1142-1157 (lines=16) @@
1139
		}
1140
	}
1141
1142
	public function testValidateModelDefinitionsFailsWithIntValue() {
1143
		Config::nest();
1144
1145
		$object = new DataObjectTest_Team;
1146
		$method = $this->makeAccessible($object, 'validateModelDefinitions');
1147
1148
		Config::inst()->update('DataObjectTest_Team', 'many_many', array('Players' => 12));
1149
		$this->setExpectedException('LogicException');
1150
1151
		try {
1152
			$method->invoke($object);
1153
		} catch(Exception $e) {
1154
			Config::unnest(); // Catch the exception so we can unnest config before failing the test
1155
			throw $e;
1156
		}
1157
	}
1158
1159
	/**
1160
	 * many_many_extraFields is allowed to have an array value, so shouldn't throw an exception
@@ 1162-1180 (lines=19) @@
1159
	/**
1160
	 * many_many_extraFields is allowed to have an array value, so shouldn't throw an exception
1161
	 */
1162
	public function testValidateModelDefinitionsPassesWithExtraFields() {
1163
		Config::nest();
1164
1165
		$object = new DataObjectTest_Team;
1166
		$method = $this->makeAccessible($object, 'validateModelDefinitions');
1167
1168
		Config::inst()->update('DataObjectTest_Team', 'many_many_extraFields',
1169
			array('Relations' => array('Price' => 'Int')));
1170
1171
		try {
1172
			$method->invoke($object);
1173
		} catch(Exception $e) {
1174
			Config::unnest();
1175
			$this->fail('Exception should not be thrown');
1176
			throw $e;
1177
		}
1178
1179
		Config::unnest();
1180
	}
1181
1182
	public function testNewClassInstance() {
1183
		$dataObject = $this->objFromFixture('DataObjectTest_Team', 'team1');