98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
1 |
--TEST-- |
2 |
Stream based insert BLOB data with md5 digest |
|
3 |
--SKIPIF-- |
|
4 |
<?php if (!extension_loaded("PBMS")) print "skip"; ?> |
|
5 |
--POST-- |
|
6 |
--GET-- |
|
7 |
--FILE-- |
|
8 |
<?php |
|
9 |
// Functions tested: |
|
10 |
// pbms_connect() |
|
190
by Barry.Leslie at PrimeBase
Pulled the BLOB alias support out of the daemon. This was done because |
11 |
// pbms_read_stream() |
12 |
// pbms_write_stream() |
|
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
13 |
// pbms_get_md5_digest() |
14 |
// pbms_close() |
|
15 |
||
16 |
include "pbms_utils.php"; |
|
17 |
||
18 |
pbms_connect($host, $port, $database) |
|
148
by Barry.Leslie at PrimeBase
Chances made to the PHP module and tests to support S3 cloud storage. |
19 |
or pbms_error_and_die("Could not connect\n"); |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
20 |
|
21 |
$mysql = mysql_connect() |
|
148
by Barry.Leslie at PrimeBase
Chances made to the PHP module and tests to support S3 cloud storage. |
22 |
or mysql_error_and_die("Could not connect\n"); |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
23 |
|
24 |
print "Connected successfully\n"; |
|
127
by Barry.Leslie at PrimeBase
PHP module cleanup. |
25 |
init_php_test_database($mysql, $engine, $database); |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
26 |
|
27 |
mysql_query("Use $database;") |
|
148
by Barry.Leslie at PrimeBase
Chances made to the PHP module and tests to support S3 cloud storage. |
28 |
or mysql_error_and_die("Use $database failed\n"); |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
29 |
|
127
by Barry.Leslie at PrimeBase
PHP module cleanup. |
30 |
if (mysql_query("Delete from test1; ") == FALSE) { |
148
by Barry.Leslie at PrimeBase
Chances made to the PHP module and tests to support S3 cloud storage. |
31 |
mysql_error_and_die("Delete from test1 Failed: \n"); |
127
by Barry.Leslie at PrimeBase
PHP module cleanup. |
32 |
}
|
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
33 |
|
34 |
// Create a few BLOBs |
|
35 |
$blob_file[0] = create_a_blob(1, "A BLOB"); |
|
36 |
$blob_file[1] = create_a_blob(2, "This is a some what larger BLOB, but still very tiny by BLOB standards."); |
|
37 |
$blob_file[2] = create_a_blob(3, build_a_blob(1024)); |
|
38 |
$blob_file[3] = create_a_blob(4, build_a_blob(10 *1024)); |
|
39 |
$blob_file[4] = create_a_big_blob(5, 1024 * 1024); |
|
40 |
||
41 |
$cnt = 1; |
|
42 |
foreach ($blob_file as $val) { |
|
43 |
||
44 |
$fh = fopen($val, "r") |
|
127
by Barry.Leslie at PrimeBase
PHP module cleanup. |
45 |
or die("fopen() error\n"); |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
46 |
|
190
by Barry.Leslie at PrimeBase
Pulled the BLOB alias support out of the daemon. This was done because |
47 |
// Stream the file data to the PBMS daemon. |
48 |
$blob_ref = pbms_read_stream($fh, filesize($val), "test1", md5_file($val, true)) |
|
148
by Barry.Leslie at PrimeBase
Chances made to the PHP module and tests to support S3 cloud storage. |
49 |
or pbms_error_and_die("pbms_read_stream($val) error\n"); |
123
by Barry.Leslie at PrimeBase
Added more php test cases and renamed the old ones. |
50 |
|
51 |
fclose($fh); |
|
52 |
||
53 |
$query = sprintf ("Insert into test1(c1, c2) values( %d, '%s');", $cnt, $blob_ref) ; |
|
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
54 |
//printf("%s\n", $query); |
55 |
mysql_query($query) |
|
148
by Barry.Leslie at PrimeBase
Chances made to the PHP module and tests to support S3 cloud storage. |
56 |
or mysql_error_and_die("Query Failed: $query"); |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
57 |
|
190
by Barry.Leslie at PrimeBase
Pulled the BLOB alias support out of the daemon. This was done because |
58 |
$blob_refs[$cnt] = $blob_ref; |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
59 |
$cnt++; |
60 |
}
|
|
61 |
||
190
by Barry.Leslie at PrimeBase
Pulled the BLOB alias support out of the daemon. This was done because |
62 |
$cnt = 1; |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
63 |
foreach ($blob_file as $val) { |
64 |
// Test stream access: |
|
65 |
$fh = fopen("phptest.blob", "w+") |
|
66 |
or die("fopen() error"); |
|
67 |
||
190
by Barry.Leslie at PrimeBase
Pulled the BLOB alias support out of the daemon. This was done because |
68 |
// Get the BLOB back |
69 |
pbms_write_stream($fh, $blob_refs[$cnt]) |
|
148
by Barry.Leslie at PrimeBase
Chances made to the PHP module and tests to support S3 cloud storage. |
70 |
or pbms_error_and_die("pbms_write_stream($val) error"); |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
71 |
|
72 |
$pbms_checksum = pbms_get_md5_digest(); |
|
73 |
$php_checksum = md5_file($val, true); |
|
74 |
||
75 |
if (strcmp($pbms_checksum, $php_checksum)) { |
|
127
by Barry.Leslie at PrimeBase
PHP module cleanup. |
76 |
printf("Checksum error for %s : %s != %s\n", $val, bin2hex($pbms_checksum), bin2hex($php_checksum)); |
77 |
die("Checksum test failed between phptest.blob and $val\n"); |
|
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
78 |
}
|
79 |
||
80 |
fclose($fh); |
|
81 |
||
82 |
compare_blob_files("phptest.blob", $val); |
|
83 |
unlink("phptest.blob"); |
|
190
by Barry.Leslie at PrimeBase
Pulled the BLOB alias support out of the daemon. This was done because |
84 |
$cnt++; |
98
by Barry.Leslie at PrimeBase
Added PHP extension with a set of basic test cases. |
85 |
}
|
86 |
||
87 |
foreach ($blob_file as $val) |
|
88 |
unlink($val); |
|
89 |
||
90 |
print "Stream insert BLOB data using md5 digest done.\n"; |
|
91 |
||
92 |
// Closing connection |
|
93 |
pbms_close(); |
|
94 |
mysql_close($mysql); |
|
95 |
?> |
|
96 |
--EXPECT-- |
|
97 |
Connected successfully |
|
98 |
Stream insert BLOB data using md5 digest done. |
|
99 |