Complex classes like AssertTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AssertTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
7 | class AssertTest extends \PHPUnit_Framework_TestCase |
||
8 | { |
||
9 | public static function dataInvalidFloat() |
||
10 | { |
||
11 | return array( |
||
12 | array(1), |
||
13 | array(false), |
||
14 | array("test"), |
||
15 | array(null), |
||
16 | array("1.23"), |
||
17 | array("10"), |
||
18 | ); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @dataProvider dataInvalidFloat |
||
23 | */ |
||
24 | public function testInvalidFloat($nonFloat) |
||
25 | { |
||
26 | $this->setExpectedException('Assert\AssertionFailedException', null, Assertion::INVALID_FLOAT); |
||
27 | Assertion::float($nonFloat); |
||
28 | } |
||
29 | |||
30 | public function testValidFloat() |
||
31 | { |
||
32 | $this->assertTrue(Assertion::float(1.0)); |
||
33 | $this->assertTrue(Assertion::float(0.1)); |
||
34 | $this->assertTrue(Assertion::float(-1.1)); |
||
35 | } |
||
36 | |||
37 | public static function dataInvalidInteger() |
||
49 | |||
50 | /** |
||
51 | * @dataProvider dataInvalidInteger |
||
52 | */ |
||
53 | public function testInvalidInteger($nonInteger) |
||
58 | |||
59 | public function testValidInteger() |
||
64 | |||
65 | public function testValidIntegerish() |
||
70 | |||
71 | public static function dataInvalidIntegerish() |
||
72 | { |
||
73 | return array( |
||
74 | array(1.23), |
||
75 | array(false), |
||
76 | array("test"), |
||
77 | array(null), |
||
78 | array("1.23"), |
||
79 | ); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @dataProvider dataInvalidIntegerish |
||
84 | */ |
||
85 | public function testInvalidIntegerish($nonInteger) |
||
90 | |||
91 | public function testValidBoolean() |
||
96 | |||
97 | public function testInvalidBoolean() |
||
102 | |||
103 | public function testInvalidScalar() |
||
104 | { |
||
105 | $this->setExpectedException('Assert\AssertionFailedException', null, Assertion::INVALID_SCALAR); |
||
106 | Assertion::scalar(new \stdClass); |
||
107 | } |
||
108 | |||
109 | public function testValidScalar() |
||
110 | { |
||
111 | $this->assertTrue(Assertion::scalar("foo")); |
||
112 | $this->assertTrue(Assertion::scalar(52)); |
||
113 | $this->assertTrue(Assertion::scalar(12.34)); |
||
114 | $this->assertTrue(Assertion::scalar(false)); |
||
115 | } |
||
116 | |||
117 | public static function dataInvalidNotEmpty() |
||
127 | |||
128 | /** |
||
129 | * @dataProvider dataInvalidNotEmpty |
||
130 | */ |
||
131 | public function testInvalidNotEmpty($value) |
||
136 | |||
137 | public function testNotEmpty() |
||
144 | |||
145 | public function testEmpty() |
||
146 | { |
||
147 | $this->assertTrue(Assertion::noContent("")); |
||
148 | $this->assertTrue(Assertion::noContent(0)); |
||
149 | $this->assertTrue(Assertion::noContent(false)); |
||
150 | $this->assertTrue(Assertion::noContent(array())); |
||
151 | } |
||
152 | |||
153 | public static function dataInvalidEmpty() |
||
154 | { |
||
155 | return array( |
||
156 | array("foo"), |
||
157 | array(true), |
||
158 | array(12), |
||
159 | array( array('foo') ), |
||
160 | array( new \stdClass() ), |
||
161 | ); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @dataProvider dataInvalidEmpty |
||
166 | */ |
||
167 | public function testInvalidEmpty($value) |
||
168 | { |
||
169 | $this->setExpectedException('Assert\AssertionFailedException', null, Assertion::VALUE_NOT_EMPTY); |
||
170 | Assertion::noContent($value); |
||
171 | } |
||
172 | |||
173 | public static function dataInvalidNull() |
||
174 | { |
||
175 | return array( |
||
176 | array("foo"), |
||
177 | array(""), |
||
178 | array(false), |
||
179 | array(12), |
||
180 | array(0), |
||
181 | array(array()), |
||
182 | ); |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * @dataProvider dataInvalidNull |
||
187 | */ |
||
188 | public function testInvalidNull($value) |
||
189 | { |
||
190 | $this->setExpectedException('Assert\AssertionFailedException', null, Assertion::VALUE_NOT_NULL); |
||
191 | Assertion::null($value); |
||
192 | } |
||
193 | |||
194 | public function testNull() |
||
195 | { |
||
196 | $this->assertTrue(Assertion::null(null)); |
||
197 | } |
||
198 | |||
199 | public function testNotNull() |
||
207 | |||
208 | public function testInvalidNotNull() |
||
213 | |||
214 | public function testString() |
||
215 | { |
||
216 | $this->assertTrue(Assertion::string("test-string")); |
||
217 | $this->assertTrue(Assertion::string("")); |
||
218 | } |
||
219 | |||
220 | /** |
||
221 | * @dataProvider dataInvalidString |
||
222 | */ |
||
223 | public function testInvalidString($invalidString) |
||
228 | |||
229 | public static function dataInvalidString() |
||
240 | |||
241 | public function testValidRegex() |
||
245 | |||
246 | public function testInvalidRegex() |
||
251 | |||
252 | public function testInvalidRegexValueNotString() |
||
257 | |||
258 | public function testInvalidMinLength() |
||
263 | |||
264 | public function testValidMinLength() |
||
272 | |||
273 | public function testInvalidMaxLength() |
||
278 | |||
279 | public function testValidMaxLength() |
||
286 | |||
287 | public function testInvalidBetweenLengthMin() |
||
292 | |||
293 | public function testInvalidBetweenLengthMax() |
||
298 | |||
299 | public function testValidBetweenLength() |
||
304 | |||
305 | public function testInvalidStartsWith() |
||
310 | |||
311 | public function testInvalidStartsWithDueToWrongEncoding() |
||
316 | |||
317 | public function testValidStartsWith() |
||
324 | |||
325 | public function testInvalidEndsWith() |
||
330 | |||
331 | public function testInvalidEndsWithDueToWrongEncoding() |
||
336 | |||
337 | public function testValidEndsWith() |
||
344 | |||
345 | public function testInvalidContains() |
||
350 | |||
351 | public function testValidContains() |
||
356 | |||
357 | public function testInvalidChoice() |
||
362 | |||
363 | public function testValidChoice() |
||
367 | |||
368 | public function testInvalidInArray() |
||
373 | |||
374 | public function testValidInArray() |
||
378 | |||
379 | public function testInvalidNumeric() |
||
384 | |||
385 | public function testValidNumeric() |
||
391 | |||
392 | public static function dataInvalidArray() |
||
404 | |||
405 | /** |
||
406 | * @dataProvider dataInvalidArray |
||
407 | */ |
||
408 | public function testInvalidArray($value) |
||
413 | |||
414 | public function testValidArray() |
||
420 | |||
421 | public function testInvalidKeyExists() |
||
426 | |||
427 | public function testValidKeyExists() |
||
431 | |||
432 | public function testInvalidKeyNotExists() |
||
437 | |||
438 | public function testValidKeyNotExists() |
||
442 | |||
443 | public static function dataInvalidNotBlank() |
||
456 | |||
457 | /** |
||
458 | * @dataProvider dataInvalidNotBlank |
||
459 | */ |
||
460 | public function testInvalidNotBlank($notBlank) |
||
465 | |||
466 | public function testValidNotBlank() |
||
470 | |||
471 | public function testInvalidNotInstanceOf() |
||
476 | |||
477 | public function testValidNotIsInstanceOf() |
||
481 | |||
482 | public function testInvalidInstanceOf() |
||
487 | |||
488 | public function testValidInstanceOf() |
||
492 | |||
493 | public function testInvalidSubclassOf() |
||
498 | |||
499 | public function testValidSubclassOf() |
||
503 | |||
504 | public function testInvalidRange() |
||
505 | { |
||
506 | $this->setExpectedException('Assert\AssertionFailedException', null, Assertion::INVALID_RANGE); |
||
507 | Assertion::range(1, 2, 3); |
||
508 | Assertion::range(1.5, 2, 3); |
||
509 | } |
||
510 | |||
511 | public function testValidRange() |
||
512 | { |
||
513 | $this->assertTrue(Assertion::range(1, 1, 2)); |
||
514 | $this->assertTrue(Assertion::range(2, 1, 2)); |
||
515 | $this->assertTrue(Assertion::range(2, 0, 100)); |
||
516 | $this->assertTrue(Assertion::range(2.5, 2.25, 2.75)); |
||
517 | } |
||
518 | |||
519 | public function testInvalidEmail() |
||
524 | |||
525 | public function testValidEmail() |
||
529 | |||
530 | /** |
||
531 | * @dataProvider dataInvalidUrl |
||
532 | */ |
||
533 | public function testInvalidUrl($url) |
||
539 | |||
540 | public static function dataInvalidUrl() |
||
562 | |||
563 | /** |
||
564 | * @dataProvider dataValidUrl |
||
565 | */ |
||
566 | public function testValidUrl($url) |
||
570 | |||
571 | public static function dataValidUrl() |
||
631 | |||
632 | public function testInvalidDigit() |
||
637 | |||
638 | public function testValidDigit() |
||
644 | |||
645 | public function testValidAlnum() |
||
652 | |||
653 | public function testInvalidAlnum() |
||
658 | |||
659 | public function testValidTrue() |
||
663 | |||
664 | public function testInvalidTrue() |
||
669 | |||
670 | public function testValidFalse() |
||
674 | |||
675 | public function testInvalidFalse() |
||
680 | |||
681 | public function testInvalidClass() |
||
686 | |||
687 | public function testValidClass() |
||
691 | |||
692 | public function testSame() |
||
700 | |||
701 | public function testEq() |
||
709 | |||
710 | public function testNotEq() |
||
711 | { |
||
712 | $this->assertTrue(Assertion::notEq("1", false)); |
||
713 | $this->assertTrue(Assertion::notEq(new \stdClass(), array())); |
||
714 | $this->setExpectedException('Assert\AssertionFailedException', null, Assertion::INVALID_NOT_EQ); |
||
715 | Assertion::notEq("1", 1); |
||
716 | } |
||
717 | |||
718 | public function testNotSame() |
||
725 | |||
726 | public function testNotInArray() |
||
734 | |||
735 | public function testMin() |
||
736 | { |
||
737 | $this->assertTrue(Assertion::min(1, 1)); |
||
738 | $this->assertTrue(Assertion::min(2, 1)); |
||
739 | $this->assertTrue(Assertion::min(2.5, 1)); |
||
740 | |||
741 | try { |
||
742 | Assertion::min(0, 1); |
||
743 | $this->fail('Expected exception `Assert\AssertionFailedException` not thrown'); |
||
744 | } catch (AssertionFailedException $e) { |
||
745 | $this->assertEquals(Assertion::INVALID_MIN, $e->getCode()); |
||
746 | $this->assertEquals('Number "0" was expected to be at least "1".', $e->getMessage()); |
||
747 | } |
||
748 | |||
749 | try { |
||
750 | Assertion::min(0.5, 2.5); |
||
751 | $this->fail('Expected exception `Assert\AssertionFailedException` not thrown'); |
||
752 | } catch (AssertionFailedException $e) { |
||
753 | $this->assertEquals(Assertion::INVALID_MIN, $e->getCode()); |
||
754 | $this->assertEquals('Number "0.5" was expected to be at least "2.5".', $e->getMessage()); |
||
755 | } |
||
756 | } |
||
757 | |||
758 | public function testMax() |
||
759 | { |
||
760 | $this->assertTrue(Assertion::max(1, 1)); |
||
761 | $this->assertTrue(Assertion::max(0.5, 1)); |
||
762 | $this->assertTrue(Assertion::max(0, 1)); |
||
763 | |||
764 | try { |
||
765 | Assertion::max(2, 1); |
||
766 | $this->fail('Expected exception `Assert\AssertionFailedException` not thrown'); |
||
767 | } catch (AssertionFailedException $e) { |
||
768 | $this->assertEquals(Assertion::INVALID_MAX, $e->getCode()); |
||
769 | $this->assertEquals('Number "2" was expected to be at most "1".', $e->getMessage()); |
||
770 | } |
||
771 | |||
772 | try { |
||
773 | Assertion::max(2.5, 0.5); |
||
774 | $this->fail('Expected exception `Assert\AssertionFailedException` not thrown'); |
||
775 | } catch (AssertionFailedException $e) { |
||
776 | $this->assertEquals(Assertion::INVALID_MAX, $e->getCode()); |
||
777 | $this->assertEquals('Number "2.5" was expected to be at most "0.5".', $e->getMessage()); |
||
778 | } |
||
779 | } |
||
780 | |||
781 | public function testNullOr() |
||
786 | |||
787 | public function testNullOrWithNoValueThrows() |
||
788 | { |
||
789 | $this->setExpectedException('BadMethodCallException'); |
||
790 | Assertion::nullOrMax(); |
||
|
|||
791 | } |
||
792 | |||
793 | public function testLength() |
||
798 | |||
799 | public static function dataLengthUtf8Characters() |
||
806 | |||
807 | /** |
||
808 | * @dataProvider dataLengthUtf8Characters |
||
809 | */ |
||
810 | public function testLenghtUtf8Characters($value, $expected) |
||
814 | |||
815 | public function testLengthFailed() |
||
820 | |||
821 | public function testLengthFailedForWrongEncoding() |
||
826 | |||
827 | public function testLengthValidForGivenEncoding() |
||
831 | |||
832 | public function testFile() |
||
836 | |||
837 | public function testFileWithEmptyFilename() |
||
842 | |||
843 | public function testFileDoesNotExists() |
||
848 | |||
849 | public function testDirectory() |
||
856 | |||
857 | public function testReadable() |
||
864 | |||
865 | public function testWriteable() |
||
872 | |||
873 | /** |
||
874 | * @expectedException \BadMethodCallException |
||
875 | * @expectedExceptionMessage No assertion |
||
876 | */ |
||
877 | public function testFailedNullOrMethodCall() |
||
881 | |||
882 | public function testImplementsInterface() |
||
895 | |||
896 | public function testImplementsInterfaceWithClassObject() |
||
911 | |||
912 | /** |
||
913 | * @dataProvider isJsonStringDataprovider |
||
914 | */ |
||
915 | public function testIsJsonString($content) |
||
919 | |||
920 | public static function isJsonStringDataprovider() |
||
929 | |||
930 | /** |
||
931 | * @dataProvider isJsonStringInvalidStringDataprovider |
||
932 | */ |
||
933 | public function testIsJsonStringExpectingException($invalidString) |
||
938 | |||
939 | public static function isJsonStringInvalidStringDataprovider() |
||
946 | |||
947 | /** |
||
948 | * @dataProvider providesValidUuids |
||
949 | */ |
||
950 | public function testValidUuids($uuid) |
||
954 | |||
955 | /** |
||
956 | * @dataProvider providesInvalidUuids |
||
957 | */ |
||
958 | public function testInvalidUuids($uuid) |
||
963 | |||
964 | public static function providesValidUuids() |
||
975 | |||
976 | public static function providesInvalidUuids() |
||
986 | |||
987 | /** |
||
988 | * @dataProvider providesValidE164s |
||
989 | */ |
||
990 | public function testValidE164s($e164) |
||
994 | |||
995 | /** |
||
996 | * @dataProvider providesInvalidE164s |
||
997 | */ |
||
998 | public function testInvalidE164s($e164) |
||
1003 | |||
1004 | public static function providesValidE164s() |
||
1012 | |||
1013 | public static function providesInvalidE164s() |
||
1020 | |||
1021 | public function testValidNotEmptyKey() |
||
1025 | |||
1026 | /** |
||
1027 | * @dataProvider invalidNotEmptyKeyDataprovider |
||
1028 | */ |
||
1029 | public function testInvalidNotEmptyKey($invalidArray, $key) |
||
1034 | |||
1035 | public static function invalidNotEmptyKeyDataprovider() |
||
1042 | |||
1043 | public function testAllWithSimpleAssertion() |
||
1047 | |||
1048 | public function testAllWithSimpleAssertionThrowsExceptionOnElementThatFailsAssertion() |
||
1053 | |||
1054 | public function testAllWithComplexAssertion() |
||
1058 | |||
1059 | public function testAllWithComplexAssertionThrowsExceptionOnElementThatFailsAssertion() |
||
1065 | |||
1066 | public function testAllWithNoValueThrows() |
||
1067 | { |
||
1068 | $this->setExpectedException('BadMethodCallException'); |
||
1069 | Assertion::allTrue(); |
||
1070 | } |
||
1071 | |||
1072 | public function testValidCount() |
||
1073 | { |
||
1074 | $this->assertTrue(Assertion::count(array('Hi'), 1)); |
||
1075 | $this->assertTrue(Assertion::count(new OneCountable(), 1)); |
||
1076 | } |
||
1077 | |||
1078 | public static function dataInvalidCount() |
||
1079 | { |
||
1080 | return array( |
||
1081 | array(array('Hi', 'There'), 3), |
||
1082 | array(new OneCountable(), 2), |
||
1083 | ); |
||
1084 | } |
||
1085 | |||
1086 | /** |
||
1087 | * @dataProvider dataInvalidCount |
||
1088 | */ |
||
1089 | public function testInvalidCount($countable, $count) |
||
1090 | { |
||
1091 | $this->setExpectedException('Assert\AssertionFailedException', 'List does not contain exactly "'.$count.'" elements.', Assertion::INVALID_COUNT); |
||
1092 | Assertion::count($countable, $count); |
||
1093 | } |
||
1094 | |||
1095 | public function testChoicesNotEmpty() |
||
1096 | { |
||
1097 | $this->assertTrue(Assertion::choicesNotEmpty( |
||
1098 | array('tux' => 'linux', 'Gnu' => 'dolphin'), |
||
1099 | array('tux') |
||
1100 | )); |
||
1101 | } |
||
1102 | |||
1103 | /** |
||
1104 | * @dataProvider invalidChoicesProvider |
||
1105 | */ |
||
1106 | public function testChoicesNotEmptyExpectingException($values, $choices, $exceptionCode) |
||
1107 | { |
||
1108 | $this->setExpectedException('Assert\AssertionFailedException', null, $exceptionCode); |
||
1109 | Assertion::choicesNotEmpty( |
||
1110 | $values, |
||
1111 | $choices |
||
1112 | ); |
||
1113 | } |
||
1114 | |||
1115 | public function invalidChoicesProvider() |
||
1116 | { |
||
1117 | return array( |
||
1118 | 'empty values' => array(array(), array('tux'), Assertion::VALUE_EMPTY), |
||
1119 | 'empty recodes in $values' => array(array('tux' => ''), array('tux'), Assertion::VALUE_EMPTY), |
||
1120 | 'choice not found in values' => array(array('tux' => ''), array('invalidChoice'), Assertion::INVALID_KEY_ISSET), |
||
1121 | ); |
||
1122 | } |
||
1123 | |||
1124 | public function testIsObject() |
||
1125 | { |
||
1126 | $this->assertTrue(Assertion::isObject(new \stdClass)); |
||
1127 | } |
||
1128 | |||
1129 | public function testIsObjectExpectingException() |
||
1130 | { |
||
1131 | $this->setExpectedException('Assert\AssertionFailedException', null, Assertion::INVALID_OBJECT); |
||
1132 | Assertion::isObject('notAnObject'); |
||
1133 | } |
||
1134 | |||
1135 | public function testMethodExists() |
||
1136 | { |
||
1137 | $this->assertTrue(Assertion::methodExists('methodExists', new Assertion())); |
||
1138 | } |
||
1139 | |||
1140 | public function testMethodExistsFailure() |
||
1145 | |||
1146 | /** |
||
1147 | * @test |
||
1148 | */ |
||
1149 | public function it_passes_values_and_constraints_to_exception() |
||
1150 | { |
||
1151 | try { |
||
1152 | Assertion::range(0, 10, 20); |
||
1153 | |||
1154 | $this->fail('Exception expected'); |
||
1155 | } catch (AssertionFailedException $e) { |
||
1156 | $this->assertEquals(0, $e->getValue()); |
||
1157 | $this->assertEquals(array('min' => 10, 'max' => 20), $e->getConstraints()); |
||
1158 | } |
||
1159 | } |
||
1160 | |||
1161 | public function testLessThan() |
||
1168 | |||
1169 | public function invalidLessProvider() |
||
1180 | |||
1181 | /** |
||
1182 | * @dataProvider invalidLessProvider |
||
1183 | */ |
||
1184 | public function testLessThanThrowsException($value, $limit) |
||
1189 | |||
1190 | public function testLessOrEqualThan() |
||
1200 | |||
1201 | public function invalidLessOrEqualProvider() |
||
1209 | |||
1210 | /** |
||
1211 | * @dataProvider invalidLessOrEqualProvider |
||
1212 | */ |
||
1213 | public function testLessOrEqualThanThrowsException($value, $limit) |
||
1218 | |||
1219 | public function testGreaterThan() |
||
1226 | |||
1227 | public function invalidGreaterProvider() |
||
1238 | |||
1239 | /** |
||
1240 | * @dataProvider validDateProvider |
||
1241 | */ |
||
1242 | public function testValidDate($value, $format) |
||
1246 | |||
1247 | public function validDateProvider() |
||
1256 | |||
1257 | /** |
||
1258 | * @dataProvider invalidGreaterProvider |
||
1259 | */ |
||
1260 | public function testGreaterThanThrowsException($value, $limit) |
||
1265 | |||
1266 | public function testGreaterOrEqualThan() |
||
1276 | |||
1277 | public function invalidGreaterOrEqualProvider() |
||
1285 | |||
1286 | /** |
||
1287 | * @dataProvider invalidGreaterOrEqualProvider |
||
1288 | * |
||
1289 | * @param mixed $value |
||
1290 | * @param mixed $limit |
||
1291 | */ |
||
1292 | public function testGreaterOrEqualThanThrowsException($value, $limit) |
||
1297 | |||
1298 | /** |
||
1299 | * @dataProvider invalidDateProvider |
||
1300 | */ |
||
1301 | public function testInvalidDate($value, $format) |
||
1306 | |||
1307 | public function invalidDateProvider() |
||
1315 | |||
1316 | public function testValidTraversable() |
||
1320 | |||
1321 | public function testInvalidTraversable() |
||
1326 | |||
1327 | public function testValidArrayAccessible() |
||
1331 | |||
1332 | public function testInvalidArrayAccessible() |
||
1337 | |||
1338 | public function testInvalidCallable() |
||
1343 | |||
1344 | public function testValidCallable() |
||
1352 | |||
1353 | public function testInvalidSatisfy() |
||
1360 | |||
1361 | public function testValidSatisfy() |
||
1375 | |||
1376 | /** |
||
1377 | * @dataProvider validIpProvider |
||
1378 | */ |
||
1379 | public function testValidIp($value) |
||
1383 | |||
1384 | public function validIpProvider() |
||
1393 | |||
1394 | /** |
||
1395 | * @dataProvider invalidIpProvider |
||
1396 | */ |
||
1397 | public function testInvalidIp($value, $flag = null) |
||
1402 | |||
1403 | public function invalidIpProvider() |
||
1415 | |||
1416 | public function testValidIpv4() |
||
1420 | |||
1421 | public function testInvalidIpv4() |
||
1426 | |||
1427 | public function testValidIpv6() |
||
1431 | |||
1432 | public function testInvalidIpv6() |
||
1437 | |||
1438 | public function testInvalidInterfaceExists() |
||
1443 | |||
1444 | public function testValidInterfaceExists() |
||
1448 | |||
1449 | /** |
||
1450 | * @dataProvider providerInvalidBetween |
||
1451 | * |
||
1452 | * @param mixed $value |
||
1453 | * @param mixed $lowerLimit |
||
1454 | * @param mixed $upperLimit |
||
1455 | */ |
||
1456 | public function testInvalidBetween($value, $lowerLimit, $upperLimit) |
||
1462 | |||
1463 | /** |
||
1464 | * @return array |
||
1465 | */ |
||
1466 | public function providerInvalidBetween() |
||
1477 | |||
1478 | /** |
||
1479 | * @dataProvider providerValidBetween |
||
1480 | * |
||
1481 | * @param mixed $value |
||
1482 | * @param mixed $lowerLimit |
||
1483 | * @param mixed $upperLimit |
||
1484 | */ |
||
1485 | public function testValidBetween($value, $lowerLimit, $upperLimit) |
||
1489 | |||
1490 | /** |
||
1491 | * @return array |
||
1492 | */ |
||
1493 | public function providerValidBetween() |
||
1504 | |||
1505 | /** |
||
1506 | * @dataProvider providerInvalidBetweenExclusive |
||
1507 | * |
||
1508 | * @param mixed $value |
||
1509 | * @param mixed $lowerLimit |
||
1510 | * @param mixed $upperLimit |
||
1511 | */ |
||
1512 | public function testInvalidBetweenExclusive($value, $lowerLimit, $upperLimit) |
||
1518 | |||
1519 | /** |
||
1520 | * @return array |
||
1521 | */ |
||
1522 | public function providerInvalidBetweenExclusive() |
||
1533 | |||
1534 | /** |
||
1535 | * @dataProvider providerValidBetweenExclusive |
||
1536 | * |
||
1537 | * @param mixed $value |
||
1538 | * @param mixed $lowerLimit |
||
1539 | * @param mixed $upperLimit |
||
1540 | */ |
||
1541 | public function testValidBetweenExclusive($value, $lowerLimit, $upperLimit) |
||
1545 | |||
1546 | /** |
||
1547 | * @return array |
||
1548 | */ |
||
1549 | public function providerValidBetweenExclusive() |
||
1557 | |||
1558 | public function testStringifyTruncatesStringValuesLongerThan100CharactersAppropriately() |
||
1566 | |||
1567 | public function testStringifyReportsResourceType() |
||
1573 | |||
1574 | public function testValidConstant() |
||
1575 | { |
||
1576 | $this->assertTrue(Assertion::defined('PHP_VERSION')); |
||
1577 | } |
||
1578 | |||
1579 | /** |
||
1580 | * @expectedException \Assert\InvalidArgumentException |
||
1581 | */ |
||
1582 | public function testInvalidConstant() |
||
1583 | { |
||
1584 | Assertion::defined('NOT_A_CONSTANT'); |
||
1585 | } |
||
1586 | } |
||
1587 | |||
1588 | class ChildStdClass extends \stdClass |
||
1589 | { |
||
1590 | } |
||
1591 | |||
1592 | class OneCountable implements \Countable |
||
1593 | { |
||
1594 | public function count() |
||
1595 | { |
||
1603 |