Annotation of embedaddon/php/ext/standard/tests/file/fwrite_variation3-win32.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test fwrite() function : usage variations - a, ab, at, a+, a+b & a+t mode
        !             3: --SKIPIF--
        !             4: <?php
        !             5: if( substr(PHP_OS, 0, 3) != 'WIN' ) {
        !             6:    die('skip...Not valid for Linux');
        !             7: }
        !             8: ?>
        !             9: --FILE--
        !            10: <?php
        !            11: /*
        !            12:  Prototype: int fwrite ( resource $handle,string string, [, int $length] );
        !            13:  Description: fwrite() writes the contents of string to the file stream pointed to by handle.
        !            14:               If the length arquement is given,writing will stop after length bytes have been
        !            15:               written or the end of string reached, whichever comes first.
        !            16:               fwrite() returns the number of bytes written or FALSE on error
        !            17: */
        !            18: 
        !            19: 
        !            20: echo "*** Testing fwrite() various  operations ***\n";
        !            21: 
        !            22: // include the file.inc for Function: function delete_file($filename)
        !            23: include ("file.inc");
        !            24: 
        !            25: /*
        !            26:  Test fwrite with file opened in mode : a,ab,at,a+,a+b,a+
        !            27:  File having content of type numeric, text,text_with_new_line & alphanumeric
        !            28: */
        !            29: 
        !            30: $file_modes = array("a","ab","at","a+","a+b","a+t");
        !            31: $file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
        !            32: 
        !            33: 
        !            34: foreach($file_content_types as $file_content_type) {
        !            35:   echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
        !            36: 
        !            37:   /* open the file using $files_modes and perform fwrite() on it */
        !            38:   foreach($file_modes as $file_mode) {
        !            39:     echo "-- Opening file in $file_mode --\n";
        !            40: 
        !            41:     // create temp file and fill it content of type $file_content_type
        !            42:     $filename = dirname(__FILE__)."/fwrite_variation3.tmp"; // this is name of the file
        !            43:     create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fwrite_variation", 3);
        !            44: 
        !            45:     $file_handle = fopen($filename, $file_mode);
        !            46:     if(!$file_handle) {
        !            47:       echo "Error: failed to fopen() file: $filename!";
        !            48:       exit();
        !            49:     }
        !            50: 
        !            51:     $data_to_be_written="";
        !            52:     fill_buffer($data_to_be_written,$file_content_type,1024);  //get the data of size 1024
        !            53: 
        !            54:     /*  Write the data into the file, verify it by checking the file pointer position, eof position, 
        !            55:         filesize & by displaying the content */
        !            56:     // append the data to the file, starting from current position of the file pointer
        !            57:     var_dump( ftell($file_handle) ); // expected: 1024
        !            58:     var_dump( fwrite($file_handle,$data_to_be_written,400) );
        !            59:     var_dump( ftell($file_handle) ); // expected: 1024 + 400
        !            60:     var_dump( feof($file_handle) );  // expected : true
        !            61: 
        !            62:     /*overwrite data in middle of the file*/
        !            63:     fseek($file_handle, SEEK_SET, (1024 + 400)/2 );
        !            64:     var_dump( ftell($file_handle));  // expected: (1024 + 400)/2
        !            65:     var_dump( fwrite($file_handle, $data_to_be_written, 200) );
        !            66:     var_dump( ftell($file_handle) );
        !            67:     var_dump( feof($file_handle) );  //Expecting bool(false)
        !            68: 
        !            69:     /* check the filesize and display file content */
        !            70:     // close the file, get the size and content of the file.
        !            71:     var_dump( fclose($file_handle) );
        !            72:     clearstatcache();//clears file status cache
        !            73:     var_dump( filesize($filename) );
        !            74:     var_dump(md5(file_get_contents($filename)));
        !            75:     // delete the file created
        !            76:     delete_file($filename); // delete file with name fwrite_variation3.tmp
        !            77:   } // end of inner foreach loop
        !            78: } // end of outer foreach loop
        !            79: 
        !            80: echo "Done\n";
        !            81: ?>
        !            82: --EXPECTF--
        !            83: *** Testing fwrite() various  operations ***
        !            84: 
        !            85: -- Testing fwrite() with file having content of type numeric --
        !            86: -- Opening file in a --
        !            87: int(0)
        !            88: int(400)
        !            89: int(400)
        !            90: bool(false)
        !            91: int(400)
        !            92: int(200)
        !            93: int(600)
        !            94: bool(false)
        !            95: bool(true)
        !            96: int(1624)
        !            97: string(32) "59ce5bf03b69069d00d6354bdc969ff6"
        !            98: -- Opening file in ab --
        !            99: int(0)
        !           100: int(400)
        !           101: int(400)
        !           102: bool(false)
        !           103: int(400)
        !           104: int(200)
        !           105: int(600)
        !           106: bool(false)
        !           107: bool(true)
        !           108: int(1624)
        !           109: string(32) "59ce5bf03b69069d00d6354bdc969ff6"
        !           110: -- Opening file in at --
        !           111: int(0)
        !           112: int(400)
        !           113: int(400)
        !           114: bool(false)
        !           115: int(400)
        !           116: int(200)
        !           117: int(600)
        !           118: bool(false)
        !           119: bool(true)
        !           120: int(1624)
        !           121: string(32) "59ce5bf03b69069d00d6354bdc969ff6"
        !           122: -- Opening file in a+ --
        !           123: int(0)
        !           124: int(400)
        !           125: int(400)
        !           126: bool(false)
        !           127: int(400)
        !           128: int(200)
        !           129: int(600)
        !           130: bool(false)
        !           131: bool(true)
        !           132: int(1624)
        !           133: string(32) "59ce5bf03b69069d00d6354bdc969ff6"
        !           134: -- Opening file in a+b --
        !           135: int(0)
        !           136: int(400)
        !           137: int(400)
        !           138: bool(false)
        !           139: int(400)
        !           140: int(200)
        !           141: int(600)
        !           142: bool(false)
        !           143: bool(true)
        !           144: int(1624)
        !           145: string(32) "59ce5bf03b69069d00d6354bdc969ff6"
        !           146: -- Opening file in a+t --
        !           147: int(0)
        !           148: int(400)
        !           149: int(400)
        !           150: bool(false)
        !           151: int(400)
        !           152: int(200)
        !           153: int(600)
        !           154: bool(false)
        !           155: bool(true)
        !           156: int(1624)
        !           157: string(32) "59ce5bf03b69069d00d6354bdc969ff6"
        !           158: 
        !           159: -- Testing fwrite() with file having content of type text --
        !           160: -- Opening file in a --
        !           161: int(0)
        !           162: int(400)
        !           163: int(400)
        !           164: bool(false)
        !           165: int(400)
        !           166: int(200)
        !           167: int(600)
        !           168: bool(false)
        !           169: bool(true)
        !           170: int(1624)
        !           171: string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
        !           172: -- Opening file in ab --
        !           173: int(0)
        !           174: int(400)
        !           175: int(400)
        !           176: bool(false)
        !           177: int(400)
        !           178: int(200)
        !           179: int(600)
        !           180: bool(false)
        !           181: bool(true)
        !           182: int(1624)
        !           183: string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
        !           184: -- Opening file in at --
        !           185: int(0)
        !           186: int(400)
        !           187: int(400)
        !           188: bool(false)
        !           189: int(400)
        !           190: int(200)
        !           191: int(600)
        !           192: bool(false)
        !           193: bool(true)
        !           194: int(1624)
        !           195: string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
        !           196: -- Opening file in a+ --
        !           197: int(0)
        !           198: int(400)
        !           199: int(400)
        !           200: bool(false)
        !           201: int(400)
        !           202: int(200)
        !           203: int(600)
        !           204: bool(false)
        !           205: bool(true)
        !           206: int(1624)
        !           207: string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
        !           208: -- Opening file in a+b --
        !           209: int(0)
        !           210: int(400)
        !           211: int(400)
        !           212: bool(false)
        !           213: int(400)
        !           214: int(200)
        !           215: int(600)
        !           216: bool(false)
        !           217: bool(true)
        !           218: int(1624)
        !           219: string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
        !           220: -- Opening file in a+t --
        !           221: int(0)
        !           222: int(400)
        !           223: int(400)
        !           224: bool(false)
        !           225: int(400)
        !           226: int(200)
        !           227: int(600)
        !           228: bool(false)
        !           229: bool(true)
        !           230: int(1624)
        !           231: string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
        !           232: 
        !           233: -- Testing fwrite() with file having content of type text_with_new_line --
        !           234: -- Opening file in a --
        !           235: int(0)
        !           236: int(400)
        !           237: int(400)
        !           238: bool(false)
        !           239: int(400)
        !           240: int(200)
        !           241: int(600)
        !           242: bool(false)
        !           243: bool(true)
        !           244: int(1624)
        !           245: string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
        !           246: -- Opening file in ab --
        !           247: int(0)
        !           248: int(400)
        !           249: int(400)
        !           250: bool(false)
        !           251: int(400)
        !           252: int(200)
        !           253: int(600)
        !           254: bool(false)
        !           255: bool(true)
        !           256: int(1624)
        !           257: string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
        !           258: -- Opening file in at --
        !           259: int(0)
        !           260: int(400)
        !           261: int(400)
        !           262: bool(false)
        !           263: int(400)
        !           264: int(200)
        !           265: int(600)
        !           266: bool(false)
        !           267: bool(true)
        !           268: int(1690)
        !           269: string(32) "656648355b64df6fded53b12fb355ab8"
        !           270: -- Opening file in a+ --
        !           271: int(0)
        !           272: int(400)
        !           273: int(400)
        !           274: bool(false)
        !           275: int(400)
        !           276: int(200)
        !           277: int(600)
        !           278: bool(false)
        !           279: bool(true)
        !           280: int(1624)
        !           281: string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
        !           282: -- Opening file in a+b --
        !           283: int(0)
        !           284: int(400)
        !           285: int(400)
        !           286: bool(false)
        !           287: int(400)
        !           288: int(200)
        !           289: int(600)
        !           290: bool(false)
        !           291: bool(true)
        !           292: int(1624)
        !           293: string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
        !           294: -- Opening file in a+t --
        !           295: int(0)
        !           296: int(400)
        !           297: int(400)
        !           298: bool(false)
        !           299: int(400)
        !           300: int(200)
        !           301: int(600)
        !           302: bool(false)
        !           303: bool(true)
        !           304: int(1690)
        !           305: string(32) "656648355b64df6fded53b12fb355ab8"
        !           306: 
        !           307: -- Testing fwrite() with file having content of type alphanumeric --
        !           308: -- Opening file in a --
        !           309: int(0)
        !           310: int(400)
        !           311: int(400)
        !           312: bool(false)
        !           313: int(400)
        !           314: int(200)
        !           315: int(600)
        !           316: bool(false)
        !           317: bool(true)
        !           318: int(1624)
        !           319: string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
        !           320: -- Opening file in ab --
        !           321: int(0)
        !           322: int(400)
        !           323: int(400)
        !           324: bool(false)
        !           325: int(400)
        !           326: int(200)
        !           327: int(600)
        !           328: bool(false)
        !           329: bool(true)
        !           330: int(1624)
        !           331: string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
        !           332: -- Opening file in at --
        !           333: int(0)
        !           334: int(400)
        !           335: int(400)
        !           336: bool(false)
        !           337: int(400)
        !           338: int(200)
        !           339: int(600)
        !           340: bool(false)
        !           341: bool(true)
        !           342: int(1624)
        !           343: string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
        !           344: -- Opening file in a+ --
        !           345: int(0)
        !           346: int(400)
        !           347: int(400)
        !           348: bool(false)
        !           349: int(400)
        !           350: int(200)
        !           351: int(600)
        !           352: bool(false)
        !           353: bool(true)
        !           354: int(1624)
        !           355: string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
        !           356: -- Opening file in a+b --
        !           357: int(0)
        !           358: int(400)
        !           359: int(400)
        !           360: bool(false)
        !           361: int(400)
        !           362: int(200)
        !           363: int(600)
        !           364: bool(false)
        !           365: bool(true)
        !           366: int(1624)
        !           367: string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
        !           368: -- Opening file in a+t --
        !           369: int(0)
        !           370: int(400)
        !           371: int(400)
        !           372: bool(false)
        !           373: int(400)
        !           374: int(200)
        !           375: int(600)
        !           376: bool(false)
        !           377: bool(true)
        !           378: int(1624)
        !           379: string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
        !           380: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>