|
@@ 1025-1044 (lines=20) @@
|
| 1022 |
|
* |
| 1023 |
|
* @since Method available since Release 3.1.0 |
| 1024 |
|
*/ |
| 1025 |
|
public static function assertClassHasAttribute($attributeName, $className, $message = '') |
| 1026 |
|
{ |
| 1027 |
|
if (!is_string($attributeName)) { |
| 1028 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1029 |
|
} |
| 1030 |
|
|
| 1031 |
|
if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) { |
| 1032 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name'); |
| 1033 |
|
} |
| 1034 |
|
|
| 1035 |
|
if (!is_string($className) || !class_exists($className)) { |
| 1036 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className); |
| 1037 |
|
} |
| 1038 |
|
|
| 1039 |
|
$constraint = new PHPUnit_Framework_Constraint_ClassHasAttribute( |
| 1040 |
|
$attributeName |
| 1041 |
|
); |
| 1042 |
|
|
| 1043 |
|
self::assertThat($className, $constraint, $message); |
| 1044 |
|
} |
| 1045 |
|
|
| 1046 |
|
/** |
| 1047 |
|
* Asserts that a class does not have a specified attribute. |
|
@@ 1055-1074 (lines=20) @@
|
| 1052 |
|
* |
| 1053 |
|
* @since Method available since Release 3.1.0 |
| 1054 |
|
*/ |
| 1055 |
|
public static function assertClassNotHasAttribute($attributeName, $className, $message = '') |
| 1056 |
|
{ |
| 1057 |
|
if (!is_string($attributeName)) { |
| 1058 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1059 |
|
} |
| 1060 |
|
|
| 1061 |
|
if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) { |
| 1062 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name'); |
| 1063 |
|
} |
| 1064 |
|
|
| 1065 |
|
if (!is_string($className) || !class_exists($className)) { |
| 1066 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className); |
| 1067 |
|
} |
| 1068 |
|
|
| 1069 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 1070 |
|
new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName) |
| 1071 |
|
); |
| 1072 |
|
|
| 1073 |
|
self::assertThat($className, $constraint, $message); |
| 1074 |
|
} |
| 1075 |
|
|
| 1076 |
|
/** |
| 1077 |
|
* Asserts that a class has a specified static attribute. |
|
@@ 1085-1104 (lines=20) @@
|
| 1082 |
|
* |
| 1083 |
|
* @since Method available since Release 3.1.0 |
| 1084 |
|
*/ |
| 1085 |
|
public static function assertClassHasStaticAttribute($attributeName, $className, $message = '') |
| 1086 |
|
{ |
| 1087 |
|
if (!is_string($attributeName)) { |
| 1088 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1089 |
|
} |
| 1090 |
|
|
| 1091 |
|
if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) { |
| 1092 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name'); |
| 1093 |
|
} |
| 1094 |
|
|
| 1095 |
|
if (!is_string($className) || !class_exists($className)) { |
| 1096 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className); |
| 1097 |
|
} |
| 1098 |
|
|
| 1099 |
|
$constraint = new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( |
| 1100 |
|
$attributeName |
| 1101 |
|
); |
| 1102 |
|
|
| 1103 |
|
self::assertThat($className, $constraint, $message); |
| 1104 |
|
} |
| 1105 |
|
|
| 1106 |
|
/** |
| 1107 |
|
* Asserts that a class does not have a specified static attribute. |
|
@@ 1115-1136 (lines=22) @@
|
| 1112 |
|
* |
| 1113 |
|
* @since Method available since Release 3.1.0 |
| 1114 |
|
*/ |
| 1115 |
|
public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') |
| 1116 |
|
{ |
| 1117 |
|
if (!is_string($attributeName)) { |
| 1118 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1119 |
|
} |
| 1120 |
|
|
| 1121 |
|
if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) { |
| 1122 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name'); |
| 1123 |
|
} |
| 1124 |
|
|
| 1125 |
|
if (!is_string($className) || !class_exists($className)) { |
| 1126 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'class name', $className); |
| 1127 |
|
} |
| 1128 |
|
|
| 1129 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 1130 |
|
new PHPUnit_Framework_Constraint_ClassHasStaticAttribute( |
| 1131 |
|
$attributeName |
| 1132 |
|
) |
| 1133 |
|
); |
| 1134 |
|
|
| 1135 |
|
self::assertThat($className, $constraint, $message); |
| 1136 |
|
} |
| 1137 |
|
|
| 1138 |
|
/** |
| 1139 |
|
* Asserts that an object has a specified attribute. |
|
@@ 1147-1166 (lines=20) @@
|
| 1144 |
|
* |
| 1145 |
|
* @since Method available since Release 3.0.0 |
| 1146 |
|
*/ |
| 1147 |
|
public static function assertObjectHasAttribute($attributeName, $object, $message = '') |
| 1148 |
|
{ |
| 1149 |
|
if (!is_string($attributeName)) { |
| 1150 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1151 |
|
} |
| 1152 |
|
|
| 1153 |
|
if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) { |
| 1154 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name'); |
| 1155 |
|
} |
| 1156 |
|
|
| 1157 |
|
if (!is_object($object)) { |
| 1158 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object'); |
| 1159 |
|
} |
| 1160 |
|
|
| 1161 |
|
$constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute( |
| 1162 |
|
$attributeName |
| 1163 |
|
); |
| 1164 |
|
|
| 1165 |
|
self::assertThat($object, $constraint, $message); |
| 1166 |
|
} |
| 1167 |
|
|
| 1168 |
|
/** |
| 1169 |
|
* Asserts that an object does not have a specified attribute. |
|
@@ 1177-1196 (lines=20) @@
|
| 1174 |
|
* |
| 1175 |
|
* @since Method available since Release 3.0.0 |
| 1176 |
|
*/ |
| 1177 |
|
public static function assertObjectNotHasAttribute($attributeName, $object, $message = '') |
| 1178 |
|
{ |
| 1179 |
|
if (!is_string($attributeName)) { |
| 1180 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 1181 |
|
} |
| 1182 |
|
|
| 1183 |
|
if (!preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $attributeName)) { |
| 1184 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'valid attribute name'); |
| 1185 |
|
} |
| 1186 |
|
|
| 1187 |
|
if (!is_object($object)) { |
| 1188 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'object'); |
| 1189 |
|
} |
| 1190 |
|
|
| 1191 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 1192 |
|
new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName) |
| 1193 |
|
); |
| 1194 |
|
|
| 1195 |
|
self::assertThat($object, $constraint, $message); |
| 1196 |
|
} |
| 1197 |
|
|
| 1198 |
|
/** |
| 1199 |
|
* Asserts that two variables have the same type and value. |