@@ -882,6 +882,67 @@ protected function provideResponse()
882
882
{
883
883
return new Response ();
884
884
}
885
+
886
+ /**
887
+ * @see http://github.com/zendframework/zend-diactoros for the canonical source repository
888
+ *
889
+ * @author Fábio Pacheco
890
+ * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
891
+ * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
892
+ */
893
+ public function ianaCodesReasonPhrasesProvider ()
894
+ {
895
+ if (!in_array ('https ' , stream_get_wrappers (), true )) {
896
+ $ this ->markTestSkipped ('The "https" wrapper is not available ' );
897
+ }
898
+
899
+ $ ianaHttpStatusCodes = new \DOMDocument ();
900
+
901
+ libxml_set_streams_context (stream_context_create (array (
902
+ 'http ' => array (
903
+ 'method ' => 'GET ' ,
904
+ 'timeout ' => 30 ,
905
+ ),
906
+ )));
907
+
908
+ $ ianaHttpStatusCodes ->load ('https://www.iana.org/assignments/http-status-codes/http-status-codes.xml ' );
909
+ if (!$ ianaHttpStatusCodes ->relaxNGValidate ('https://www.iana.org/assignments/http-status-codes/http-status-codes.rng ' )) {
910
+ self ::fail ('Invalid IANA \'s HTTP status code list. ' );
911
+ }
912
+
913
+ $ ianaCodesReasonPhrases = array ();
914
+
915
+ $ xpath = new \DomXPath ($ ianaHttpStatusCodes );
916
+ $ xpath ->registerNamespace ('ns ' , 'http://www.iana.org/assignments ' );
917
+
918
+ $ records = $ xpath ->query ('//ns:record ' );
919
+ foreach ($ records as $ record ) {
920
+ $ value = $ xpath ->query ('.//ns:value ' , $ record )->item (0 )->nodeValue ;
921
+ $ description = $ xpath ->query ('.//ns:description ' , $ record )->item (0 )->nodeValue ;
922
+
923
+ if (in_array ($ description , array ('Unassigned ' , '(Unused) ' ), true )) {
924
+ continue ;
925
+ }
926
+
927
+ if (preg_match ('/^([0-9]+)\s*\-\s*([0-9]+)$/ ' , $ value , $ matches )) {
928
+ for ($ value = $ matches [1 ]; $ value <= $ matches [2 ]; ++$ value ) {
929
+ $ ianaCodesReasonPhrases [] = array ($ value , $ description );
930
+ }
931
+ } else {
932
+ $ ianaCodesReasonPhrases [] = array ($ value , $ description );
933
+ }
934
+ }
935
+
936
+ return $ ianaCodesReasonPhrases ;
937
+ }
938
+
939
+ /**
940
+ * @dataProvider ianaCodesReasonPhrasesProvider
941
+ */
942
+ public function testReasonPhraseDefaultsAgainstIana ($ code , $ reasonPhrase )
943
+ {
944
+ $ this ->assertEquals ($ reasonPhrase , Response::$ statusTexts [$ code ]);
945
+ }
885
946
}
886
947
887
948
class StringableObject
0 commit comments