Annotation of embedaddon/php/ext/oci8/tests/lob_029.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: reading/writing BFILE LOBs
        !             3: --SKIPIF--
        !             4: <?php
        !             5: $target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
        !             6: require(dirname(__FILE__).'/skipif.inc');
        !             7: ob_start();
        !             8: phpinfo(INFO_MODULES);
        !             9: $phpinfo = ob_get_clean();
        !            10: if (preg_match('/Compile-time ORACLE_HOME/', $phpinfo) !== 1) {
        !            11:     // Assume building PHP with an ORACLE_HOME means the tested DB is on the same machine as PHP
        !            12:     die("skip this test won't work with remote Oracle");
        !            13: }
        !            14: if (substr(PHP_OS, 0, 3) == 'WIN') die("skip Test script not ported to Windows");
        !            15: ?>
        !            16: --FILE--
        !            17: <?php
        !            18: 
        !            19: require(dirname(__FILE__).'/connect.inc');
        !            20: 
        !            21: $realdirname = "/tmp";  // Use /tmp because a local dir can give ORA-22288 depending on perms
        !            22: $realfilename1 = "oci8bfiletest1.txt";
        !            23: $fullname1 = $realdirname."/".$realfilename1;
        !            24: $realfilename2 = "oci8bfiletest2.txt";
        !            25: $fullname2 = $realdirname."/".$realfilename2;
        !            26: $realfilename3 = "oci8bfiletest3.txt";
        !            27: $fullname3 = $realdirname."/".$realfilename3;
        !            28: 
        !            29: // Setup
        !            30: $s = oci_parse($c, "drop table FileTest");
        !            31: @oci_execute($s);
        !            32: 
        !            33: $s = oci_parse($c, "drop directory TestDir");
        !            34: @oci_execute($s);
        !            35: 
        !            36: $s = oci_parse($c, "create directory TestDir as '$realdirname'");
        !            37: oci_execute($s);
        !            38: 
        !            39: file_put_contents($fullname1, 'Some text in the bfile 1');
        !            40: file_put_contents($fullname2, 'Some text in the bfile 2');
        !            41: file_put_contents($fullname3, 'Some text in the bfile 3');
        !            42: 
        !            43: $s = oci_parse($c, "create table FileTest (FileNum number, FileDesc varchar2(30), Image bfile)");
        !            44: oci_execute($s);
        !            45: 
        !            46: $s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (1, 'Description 1', bfilename('TESTDIR', '$realfilename1'))");
        !            47: oci_execute($s);
        !            48: 
        !            49: $s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (2, 'Description 2', bfilename('TESTDIR', '$realfilename2'))");
        !            50: oci_execute($s);
        !            51: 
        !            52: $s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (3, 'Description 3', bfilename('TESTDIR', '$realfilename3'))");
        !            53: oci_execute($s);
        !            54: 
        !            55: // Run tests
        !            56: 
        !            57: echo "Test 1. Check how many rows in the table\n";
        !            58: 
        !            59: $s = oci_parse($c, "select count(*) numrows from FileTest");
        !            60: oci_execute($s);
        !            61: oci_fetch_all($s, $res);
        !            62: var_dump($res);
        !            63: 
        !            64: echo "Test 2\n";
        !            65: $s = oci_parse($c, "select * from FileTest order by FileNum");
        !            66: oci_execute($s);
        !            67: oci_fetch_all($s, $res);
        !            68: var_dump($res);
        !            69: 
        !            70: echo "Test 3\n";
        !            71: $d = oci_new_descriptor($c, OCI_D_FILE);
        !            72: 
        !            73: $s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (2, 'Description 2', bfilename('TESTDIR', '$realfilename1')) returning Image into :im");
        !            74: oci_bind_by_name($s, ":im", $d, -1, OCI_B_BFILE);
        !            75: oci_execute($s);
        !            76: 
        !            77: $r = $d->read(40);
        !            78: var_dump($r);
        !            79: 
        !            80: unlink($fullname1);
        !            81: unlink($fullname2);
        !            82: unlink($fullname3);
        !            83: 
        !            84: $s = oci_parse($c, "drop table FileTest");
        !            85: oci_execute($s);
        !            86: 
        !            87: $s = oci_parse($c, "drop directory TestDir");
        !            88: oci_execute($s);
        !            89: 
        !            90: echo "Done\n";
        !            91: ?>
        !            92: --EXPECTF-- 
        !            93: Test 1. Check how many rows in the table
        !            94: array(1) {
        !            95:   ["NUMROWS"]=>
        !            96:   array(1) {
        !            97:     [0]=>
        !            98:     string(1) "3"
        !            99:   }
        !           100: }
        !           101: Test 2
        !           102: array(3) {
        !           103:   ["FILENUM"]=>
        !           104:   array(3) {
        !           105:     [0]=>
        !           106:     string(1) "1"
        !           107:     [1]=>
        !           108:     string(1) "2"
        !           109:     [2]=>
        !           110:     string(1) "3"
        !           111:   }
        !           112:   ["FILEDESC"]=>
        !           113:   array(3) {
        !           114:     [0]=>
        !           115:     string(13) "Description 1"
        !           116:     [1]=>
        !           117:     string(13) "Description 2"
        !           118:     [2]=>
        !           119:     string(13) "Description 3"
        !           120:   }
        !           121:   ["IMAGE"]=>
        !           122:   array(3) {
        !           123:     [0]=>
        !           124:     string(24) "Some text in the bfile 1"
        !           125:     [1]=>
        !           126:     string(24) "Some text in the bfile 2"
        !           127:     [2]=>
        !           128:     string(24) "Some text in the bfile 3"
        !           129:   }
        !           130: }
        !           131: Test 3
        !           132: string(24) "Some text in the bfile 1"
        !           133: Done

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