| Current File : /home/mmdealscpanel/yummmdeals.com/tests.tar |
stats_rand_gen_exponential.phpt 0000644 00000000510 15041410411 0013025 0 ustar 00 --TEST--
stats_rand_gen_exponential()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_exponential(2)));
var_dump(stats_rand_gen_exponential(0));
// error cases
var_dump(stats_rand_gen_exponential(-0.1)); // av < 0
?>
--EXPECTF--
bool(true)
float(0)
Warning: stats_rand_gen_exponential(): av < 0.0 in %s on line %d
bool(false)
stats_rand_gen_chisquare.phpt 0000644 00000000703 15041410411 0012467 0 ustar 00 --TEST--
stats_rand_gen_chisquare()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_chisquare(3)));
// error cases
var_dump(stats_rand_gen_chisquare(-0.1)); // df < 0
var_dump(stats_rand_gen_chisquare(0)); // df == 0
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_chisquare(): df <= 0.0. df : -1.000000E-1 in %s on line %d
bool(false)
Warning: stats_rand_gen_chisquare(): df <= 0.0. df : 0.000000E+0 in %s on line %d
bool(false)
stats_cdf_exponential.phpt 0000644 00000001676 15041410411 0012022 0 ustar 00 --TEST--
stats_cdf_exponential()
--FILE--
<?php
// which = 1 : calculate P from (X, SCALE)
var_dump(round(stats_cdf_exponential(1, 2, 1), 6));
var_dump(round(stats_cdf_exponential(4, 3, 1), 6));
// which = 2 : calculate X from (P, SCALE)
var_dump(round(stats_cdf_exponential(0.39346934, 2, 2), 6));
var_dump(round(stats_cdf_exponential(0.736402862, 3, 2), 6));
// which = 3 : calculate SCALE from (P, X)
var_dump(round(stats_cdf_exponential(0.39346934, 1, 3), 6));
var_dump(round(stats_cdf_exponential(0.736402862, 4, 3), 6));
// error cases
var_dump(stats_cdf_exponential(1, 2, 0)); // which < 1
var_dump(stats_cdf_exponential(4, 3, 4)); // which > 3
?>
--EXPECTF--
float(0.393469)
float(0.736403)
float(1)
float(4)
float(2)
float(3)
Warning: stats_cdf_exponential(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
Warning: stats_cdf_exponential(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
bug68295.phpt 0000644 00000000253 15041410411 0006623 0 ustar 00 --TEST--
Bug #68295 Warning: stats_stat_powersum(): Both value and power are zero
--FILE--
<?php
var_dump(stats_stat_powersum(array(1, 2, 0), 2));
?>
--EXPECTF--
float(5)
stats_cdf_f.phpt 0000644 00000003276 15041410411 0007717 0 ustar 00 --TEST--
stats_cdf_f()
--FILE--
<?php
// which = 1 : calculate P from (F, DFN, DFD)
var_dump(round(stats_cdf_f(1, 3, 2, 1), 6));
// which = 2 : calculate F from (P, DFN, DFD)
var_dump(round(stats_cdf_f(0.464758002, 3, 2, 2), 6));
// which = 3 : calculate DFN from (P, F, DFD)
var_dump(round(stats_cdf_f(0.464758002, 1, 2, 3), 6));
// which = 4 : calculate DFD from (P, F, DFN)
var_dump(round(stats_cdf_f(0.464758002, 1, 3, 4), 6));
// error cases
var_dump(stats_cdf_f(1, 3, 2, 0)); // which < 1
var_dump(stats_cdf_f(1, 3, 2, 5)); // which > 4
var_dump(stats_cdf_f(-0.1, 3, 2, 2)); // P < 0
var_dump(stats_cdf_f(1.1, 3, 2, 2)); // P > 1
var_dump(stats_cdf_f(-0.1, 3, 2, 1)); // F < 0
var_dump(stats_cdf_f(1, -0.1, 2, 1)); // DFN < 0
var_dump(stats_cdf_f(1, 0, 2, 1)); // DFN == 0
var_dump(stats_cdf_f(1, 3, -0.1, 1)); // DFD < 0
var_dump(stats_cdf_f(1, 3, 0, 1)); // DFD == 0
?>
--EXPECTF--
float(0.464758)
float(1)
float(3)
float(2)
Warning: stats_cdf_f(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_f(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_f(): Computation Error in cdff in %s on line %d
bool(false)
Warning: stats_cdf_f(): Computation Error in cdff in %s on line %d
bool(false)
Warning: stats_cdf_f(): Computation Error in cdff in %s on line %d
bool(false)
Warning: stats_cdf_f(): Computation Error in cdff in %s on line %d
bool(false)
Warning: stats_cdf_f(): Computation Error in cdff in %s on line %d
bool(false)
Warning: stats_cdf_f(): Computation Error in cdff in %s on line %d
bool(false)
Warning: stats_cdf_f(): Computation Error in cdff in %s on line %d
bool(false)
stats_cdf_chisquare.phpt 0000644 00000002356 15041410411 0011454 0 ustar 00 --TEST--
stats_cdf_chisquare()
--FILE--
<?php
// which = 1 : calculate P from (X, DF)
var_dump(round(stats_cdf_chisquare(1, 2, 1), 6));
// which = 2 : calculate X from (P, DF)
var_dump(round(stats_cdf_chisquare(0.393469340, 2, 2), 6));
// which = 3 : calculate DF from (P, X)
var_dump(round(stats_cdf_chisquare(0.393469340, 1, 3), 6));
// error cases
var_dump(stats_cdf_chisquare(1, 2, 0)); // which < 1
var_dump(stats_cdf_chisquare(1, 2, 4)); // which > 3
var_dump(stats_cdf_chisquare(-0.1, 2, 2)); // P < 0
var_dump(stats_cdf_chisquare(1.1, 2, 2)); // P > 1
var_dump(stats_cdf_chisquare(-0.1, 2, 1)); // X < 0
var_dump(stats_cdf_chisquare(1, -0.1, 1)); // DF < 0
?>
--EXPECTF--
float(0.393469)
float(1)
float(2)
Warning: stats_cdf_chisquare(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
Warning: stats_cdf_chisquare(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
Warning: stats_cdf_chisquare(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_chisquare(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_chisquare(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_chisquare(): Computation Error in %s on line %d
bool(false)
stats_rand_gen_f.phpt 0000644 00000001011 15041410411 0010721 0 ustar 00 --TEST--
stats_rand_gen_f()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_f(3, 2)));
// error cases
var_dump(stats_rand_gen_f(-0.1, 2)); // dfn < 0
var_dump(stats_rand_gen_f(3, -0.1)); // dfr < 0
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_f(): Degrees of freedom nonpositive. DFN value: -1.000000E-1 DFD value: 2.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_f(): Degrees of freedom nonpositive. DFN value: 3.000000E+0 DFD value: -1.000000E-1 in %s on line %d
bool(false)
stats_rand_gen_beta.phpt 0000644 00000001051 15041410411 0011413 0 ustar 00 --TEST--
stats_rand_gen_beta()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_beta(2, 3)));
// error cases
var_dump(stats_rand_gen_beta(1e-38, 1)); // a < 1e-37
var_dump(stats_rand_gen_beta(1, 1e-38)); // b < 1e-37
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_beta(): 'a' or 'b' lower than 1.0E-37. 'a' value : 1.000000E-38 'b' value : 1.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_beta(): 'a' or 'b' lower than 1.0E-37. 'a' value : 1.000000E+0 'b' value : 1.000000E-38 in %s on line %d
bool(false)
bug59070.phpt 0000644 00000000404 15041410411 0006610 0 ustar 00 --TEST--
Bug #59070 Percentile Stat Function
--FILE--
<?php
$values = array(3, 1, 5, 2, 4);
stats_stat_percentile($values, 50);
var_dump($values);
?>
--EXPECTF--
array(5) {
[0]=>
int(3)
[1]=>
int(1)
[2]=>
int(5)
[3]=>
int(2)
[4]=>
int(4)
}
stats_dens_cauchy.phpt 0000644 00000001614 15041410411 0011135 0 ustar 00 --TEST--
stats_dens_cauchy()
--FILE--
<?php
// check for each x
foreach (range(-2, 2, 0.5) as $x) {
var_dump(round(stats_dens_cauchy($x, 2, 3), 6));
}
// check for each ave
foreach (range(-2, 2, 0.5) as $ave) {
var_dump(round(stats_dens_cauchy(1, $ave, 3), 6));
}
// check for each stdev
foreach (range(0.5, 2, 0.5) as $stdev) {
var_dump(round(stats_dens_cauchy(1, 2, $stdev), 6));
}
// error cases
var_dump(stats_dens_cauchy(1, 2, 0)); // stdev == 0
?>
--EXPECTF--
float(0.038197)
float(0.044938)
float(0.053052)
float(0.062618)
float(0.073456)
float(0.084883)
float(0.095493)
float(0.103236)
float(0.106103)
float(0.053052)
float(0.062618)
float(0.073456)
float(0.084883)
float(0.095493)
float(0.103236)
float(0.106103)
float(0.103236)
float(0.095493)
float(0.127324)
float(0.159155)
float(0.146912)
float(0.127324)
Warning: stats_dens_cauchy(): stdev is 0.0 in %s on line %d
bool(false)
stats_standard_deviation.phpt 0000644 00000000666 15041410411 0012520 0 ustar 00 --TEST--
stats_standard_deviation()
--INI--
serialize_precision=14
--FILE--
<?php
$a=array(4, 1, 7);
$dev=stats_standard_deviation($a);
var_dump(sprintf("%2.9f", $dev));
var_dump(stats_standard_deviation(array()));
$a=array(5,7,8,10,10);
var_dump(stats_standard_deviation($a,1));
?>
--EXPECTF--
string(11) "2.449489743"
Warning: stats_standard_deviation(): The array has zero elements in %s on line %d
bool(false)
float(2.1213203435596)
stats_cdf_gamma.phpt 0000644 00000003372 15041410411 0010551 0 ustar 00 --TEST--
stats_cdf_gamma()
--FILE--
<?php
// which = 1 : calculate P from (X, SHAPE, SCALE)
var_dump(round(stats_cdf_gamma(5, 3, 2, 1), 6));
// which = 2 : calculate X from (P, SHAPE, SCALE)
var_dump(round(stats_cdf_gamma(0.456186884, 3, 2, 2), 6));
// which = 3 : calculate SHAPE from (P, X, SCALE)
var_dump(round(stats_cdf_gamma(0.456186884, 5, 2, 3), 6));
// which = 4 : calculate SCALE from (P, X, SHAPE)
var_dump(round(stats_cdf_gamma(0.456186884, 5, 3, 4), 6));
// error cases
var_dump(stats_cdf_gamma(1, 0, 1, 0)); // which < 1
var_dump(stats_cdf_gamma(1, 0, 1, 5)); // which > 4
var_dump(stats_cdf_gamma(-0.1, 3, 2, 2)); // P < 0
var_dump(stats_cdf_gamma(1.1, 3, 2, 2)); // P > 1
var_dump(stats_cdf_gamma(-0.1, 3, 2, 1)); // X < 0
var_dump(stats_cdf_gamma(5, -0.1, 2, 1)); // SHAPE < 0
var_dump(stats_cdf_gamma(5, 0, 2, 1)); // SHAPE == 0
var_dump(stats_cdf_gamma(5, 3, -0.1, 1)); // SCALE < 0
var_dump(stats_cdf_gamma(5, 3, 0, 1)); // SCALE == 0
?>
--EXPECTF--
float(0.456187)
float(5)
float(3)
float(2)
Warning: stats_cdf_gamma(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_gamma(): Computation Error in %s on line %d
bool(false)
bug61318-11.phpt 0000644 00000000327 15041410411 0007031 0 ustar 00 --TEST--
Bug #61318 (stats_skew also casts values to floats)
--FILE--
<?php
$data = array(1, 2, 3);
stats_skew($data);
var_dump($data);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
stats_cdf_t.phpt 0000644 00000001564 15041410411 0007733 0 ustar 00 --TEST--
stats_cdf_t()
--FILE--
<?php
// which = 1 : calculate P from (T, DF)
var_dump(round(stats_cdf_t(1, 1, 1), 6));
// which = 2 : calculate T from (P, DF)
var_dump(round(stats_cdf_t(0.75, 1, 2), 6));
// which = 3 : calculate DF from (P, T)
var_dump(round(stats_cdf_t(0.75, 1, 3), 6));
// error cases
var_dump(stats_cdf_t(1, 1, 0)); // which < 1
var_dump(stats_cdf_t(1, 1, 4)); // which > 3
var_dump(stats_cdf_t(1, -0.1, 1)); // DF < 0
var_dump(stats_cdf_t(1, 0, 1)); // DF == 0
?>
--EXPECTF--
float(0.75)
float(1)
float(1)
Warning: stats_cdf_t(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
Warning: stats_cdf_t(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
Warning: stats_cdf_t(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_t(): Computation Error in %s on line %d
bool(false)
stats_absolute_deviation.phpt 0000644 00000000610 15041410411 0012523 0 ustar 00 --TEST--
stats_absolute_deviation()
--FILE--
<?php
var_dump(sprintf("%2.9f", stats_absolute_deviation(array(4,1,7))));
var_dump(sprintf("%2.9f", stats_absolute_deviation(array(2,1,3))));
var_dump(stats_absolute_deviation(array()));
?>
--EXPECTF--
string(11) "2.000000000"
string(11) "0.666666667"
Warning: stats_absolute_deviation(): The array has zero elements in %s on line %d
bool(false)
stats_cdf_logistic.phpt 0000644 00000002176 15041410411 0011305 0 ustar 00 --TEST--
stats_cdf_logistic()
--FILE--
<?php
// which = 1 : calculate P from (X, MEAN, SD)
var_dump(round(stats_cdf_logistic(1, 2, 3, 1), 6));
var_dump(round(stats_cdf_logistic(6, 5, 4, 1), 6));
// which = 2 : calculate X from (P, MEAN, SD)
var_dump(round(stats_cdf_logistic(0.417429794, 2, 3, 2), 6));
var_dump(round(stats_cdf_logistic(0.562176501, 5, 4, 2), 6));
// which = 3 : calcualte MEAN from (P, X, SD)
var_dump(round(stats_cdf_logistic(0.417429794, 1, 3, 3), 6));
var_dump(round(stats_cdf_logistic(0.562176501, 6, 4, 3), 6));
// which = 4 : calcualte SD from (P, X, MEAN)
var_dump(round(stats_cdf_logistic(0.417429794, 1, 2, 4), 6));
var_dump(round(stats_cdf_logistic(0.562176501, 6, 5, 4), 6));
// error cases
var_dump(stats_cdf_logistic(1, 2, 3, 0)); // which < 1
var_dump(stats_cdf_logistic(1, 2, 3, 5)); // which > 4
?>
--EXPECTF--
float(0.41743)
float(0.562177)
float(1)
float(6)
float(2)
float(5)
float(3)
float(4)
Warning: stats_cdf_logistic(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_logistic(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
stats_rand_phrase_to_seeds.phpt 0000644 00000000521 15041410411 0013017 0 ustar 00 --TEST--
stats_rand_phrase_to_seeds()
--FILE--
<?php
$retval = stats_rand_phrase_to_seeds('pecl_math_stats');
var_dump(is_int($retval[0]));
var_dump(is_int($retval[1]));
var_dump(1 <= $retval[0] && $retval[0] <= (1 << 30));
var_dump(1 <= $retval[1] && $retval[1] <= (1 << 30));
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
stats_dens_logistic.phpt 0000644 00000001625 15041410411 0011500 0 ustar 00 --TEST--
stats_dens_logistic()
--FILE--
<?php
// check for each x
foreach (range(-2, 2, 0.5) as $x) {
var_dump(round(stats_dens_logistic($x, 2, 3), 6));
}
// check for each ave
foreach (range(-2, 2, 0.5) as $ave) {
var_dump(round(stats_dens_logistic(1, $ave, 3), 6));
}
// check for each stdev
foreach (range(0.5, 2, 0.5) as $stdev) {
var_dump(round(stats_dens_logistic(1, 2, $stdev), 6));
}
// error cases
var_dump(stats_dens_logistic(1, 2, 0)); // stdev == 0
?>
--EXPECTF--
float(0.05503)
float(0.060357)
float(0.065537)
float(0.070389)
float(0.074719)
float(0.078335)
float(0.081061)
float(0.082757)
float(0.083333)
float(0.065537)
float(0.070389)
float(0.074719)
float(0.078335)
float(0.081061)
float(0.082757)
float(0.083333)
float(0.082757)
float(0.081061)
float(0.209987)
float(0.196612)
float(0.149438)
float(0.117502)
Warning: stats_dens_logistic(): stdev is 0.0 in %s on line %d
bool(false)
stats_cdf_binomial.phpt 0000644 00000004027 15041410411 0011257 0 ustar 00 --TEST--
stats_cdf_binomial()
--FILE--
<?php
// which = 1 : calculate P from (S, XN, PR)
var_dump(round(stats_cdf_binomial(1, 3, 0.7, 1), 6));
// which = 2 : calculate S from (P, XN, PR)
var_dump(round(stats_cdf_binomial(0.216, 3, 0.7, 2), 6));
// which = 3 : calculate XN from (P, S, PR)
var_dump(round(stats_cdf_binomial(0.216, 1, 0.7, 3), 6));
// which = 4 : calculate PR from (P, S, XN)
var_dump(round(stats_cdf_binomial(0.216, 1, 3, 4), 6));
// error cases
var_dump(stats_cdf_binomial(1, 3, 0.7, 0)); // which < 1
var_dump(stats_cdf_binomial(1, 3, 0.7, 5)); // which > 4
var_dump(stats_cdf_binomial(-0.1, 3, 0.7, 2)); // P < 0
var_dump(stats_cdf_binomial(1.1, 3, 0.7, 2)); // P > 1
var_dump(stats_cdf_binomial(-1, 3, 0.7, 1)); // S < 0
var_dump(stats_cdf_binomial(4, 3, 0.7, 1)); // S > XN
var_dump(stats_cdf_binomial(1, -1, 0.7, 1)); // XN < 0
var_dump(stats_cdf_binomial(1, 0, 0.7, 1)); // XN == 0
var_dump(stats_cdf_binomial(1, 3, -0.1, 1)); // PR < 0
var_dump(stats_cdf_binomial(1, 3, 1.1, 1)); // PR > 1
?>
--EXPECTF--
float(0.216)
float(1)
float(3)
float(0.7)
Warning: stats_cdf_binomial(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
Warning: stats_cdf_binomial(): Computation Error in binomialcdf in %s on line %d
bool(false)
stats_rand_gen_funiform.phpt 0000644 00000000731 15041410411 0012331 0 ustar 00 --TEST--
stats_rand_gen_funiform()
--FILE--
<?php
$x = stats_rand_gen_funiform(1.5, 2.5);
var_dump(is_float($x));
var_dump($x > 1.5);
var_dump($x < 2.5);
var_dump(stats_rand_gen_funiform(1.5, 1.5));
// error cases
var_dump(stats_rand_gen_funiform(2.5, 1.5)); // low > high
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
float(1.5)
Warning: stats_rand_gen_funiform(): low greater than high. low : 2.500000E+0 high : 1.500000E+0 in %s on line %d
bool(false)
stats_dens_laplace.phpt 0000644 00000001575 15041410411 0011270 0 ustar 00 --TEST--
stats_dens_laplace()
--FILE--
<?php
// check for each x
foreach (range(-2, 2, 0.5) as $x) {
var_dump(round(stats_dens_laplace($x, 1, 2), 6));
}
// check for each ave
foreach (range(-2, 2, 0.5) as $ave) {
var_dump(round(stats_dens_laplace(0, $ave, 2), 6));
}
// check for each stdev
foreach (range(0.5, 2, 0.5) as $stdev) {
var_dump(round(stats_dens_laplace(0, 1, $stdev), 6));
}
// error cases
var_dump(stats_dens_laplace(0, 1, 0)); // stdev == 0
?>
--EXPECTF--
float(0.055783)
float(0.071626)
float(0.09197)
float(0.118092)
float(0.151633)
float(0.1947)
float(0.25)
float(0.1947)
float(0.151633)
float(0.09197)
float(0.118092)
float(0.151633)
float(0.1947)
float(0.25)
float(0.1947)
float(0.151633)
float(0.118092)
float(0.09197)
float(0.135335)
float(0.18394)
float(0.171139)
float(0.151633)
Warning: stats_dens_laplace(): stdev is 0.0 in %s on line %d
bool(false)
stats_dens_chisquare.phpt 0000644 00000000744 15041410411 0011650 0 ustar 00 --TEST--
stats_dens_chisquare()
--FILE--
<?php
// check for each x
foreach (range(0.5, 3, 0.5) as $x) {
var_dump(round(stats_dens_chisquare($x, 3), 6));
}
// check for each dfr
foreach (range(0.5, 3, 0.5) as $dfr) {
var_dump(round(stats_dens_chisquare(1, $dfr), 6));
}
?>
--EXPECTF--
float(0.219696)
float(0.241971)
float(0.230799)
float(0.207554)
float(0.180722)
float(0.15418)
float(0.140674)
float(0.241971)
float(0.294304)
float(0.303265)
float(0.281348)
float(0.241971)
stats_rand_ranf.phpt 0000644 00000000234 15041410411 0010577 0 ustar 00 --TEST--
stats_rand_ranf()
--FILE--
<?php
$r = stats_rand_ranf();
var_dump(is_float($r));
var_dump(0 <= $r && $r < 1);
?>
--EXPECTF--
bool(true)
bool(true)
stats_rand_getsd.phpt 0000644 00000000233 15041410411 0010756 0 ustar 00 --TEST--
stats_rand_getsd()
--FILE--
<?php
stats_rand_setall(10, 20);
$sd = stats_rand_getsd();
echo $sd[0], "\n";
echo $sd[1], "\n";
?>
--EXPECTF--
10
20
stats_rand_gen_gamma.phpt 0000644 00000001613 15041410411 0011566 0 ustar 00 --TEST--
stats_rand_gen_gamma()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_gamma(1, 1)));
// error cases
var_dump(stats_rand_gen_gamma(-0.1, 1)); // a < 0
var_dump(stats_rand_gen_gamma(0, 1)); // a == 0
var_dump(stats_rand_gen_gamma(1, -.1)); // r < 0
var_dump(stats_rand_gen_gamma(1, 0)); // r == 0
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_gamma(): A or R nonpositive. A value : -1.000000E-1 , R value : 1.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_gamma(): A or R nonpositive. A value : 0.000000E+0 , R value : 1.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_gamma(): A or R nonpositive. A value : 1.000000E+0 , R value : -1.000000E-1 in %s on line %d
bool(false)
Warning: stats_rand_gen_gamma(): A or R nonpositive. A value : 1.000000E+0 , R value : 0.000000E+0 in %s on line %d
bool(false)
stats_covariance.phpt 0000644 00000001112 15041410411 0010753 0 ustar 00 --TEST--
math_covariance() tests
--FILE--
<?php
$a_1 = array(
15, 16, 8, 6, 15, 12, 12, 18, 12, 20, 12, 14,
);
$a_2 = array(
17.24, 15, 14.91, 4.5, 18, 6.29, 19.23, 18.69, 7.21, 42.06, 7.5, 8,
);
var_dump(sprintf("%2.9f", stats_covariance($a_1, $a_2)));
var_dump(stats_covariance(array(2,1), array(1)));
var_dump(stats_covariance(array(), array(0)));
?>
--EXPECTF--
string(12) "25.460555556"
Warning: stats_covariance(): The datasets are not of the same size in %s on line %d
bool(false)
Warning: stats_covariance(): The first array has zero elements in %s on line %d
bool(false)
stats_dens_pmf_negative_binomial.phpt 0000644 00000002141 15041410412 0014174 0 ustar 00 --TEST--
stats_dens_pmf_negative_binomial()
--INI--
serialize_precision=14
--FILE--
<?php
// check for each x
foreach (range(0, 3) as $x) {
var_dump(stats_dens_pmf_negative_binomial($x, 2, 0.4));
}
// check for each n
foreach (range(0, 3) as $n) {
var_dump(stats_dens_pmf_negative_binomial(1, $n, 0.4));
}
// check for each pi
foreach (range(0, 1, 0.2) as $pi) {
var_dump(stats_dens_pmf_negative_binomial(1, 2, $pi));
}
// error cases
var_dump(stats_dens_pmf_negative_binomial(1, 0, 0)); // n == 0 and pi == 0
var_dump(stats_dens_pmf_negative_binomial(0, 2, 1)); // x == 0 and pi == 1
?>
--EXPECTF--
float(0.16)
float(0.192)
float(0.1728)
float(0.13824)
float(0)
float(0.24)
float(0.192)
float(0.1152)
float(0)
float(0.064)
float(0.192)
float(0.288)
float(0.256)
float(0)
Warning: stats_dens_pmf_negative_binomial(): Params leading to pow(0, 0). x: 1.000000E+0 n: 0.000000E+0 pi: 0.000000E+0 in %s on line %d
bool(false)
Warning: stats_dens_pmf_negative_binomial(): Params leading to pow(0, 0). x: 0.000000E+0 n: 2.000000E+0 pi: 1.000000E+0 in %s on line %d
bool(false)
stats_stat_factorial.phpt 0000644 00000000356 15041410412 0011652 0 ustar 00 --TEST--
stats_stat_factorial()
--FILE--
<?php
var_dump(stats_stat_factorial(0));
var_dump(stats_stat_factorial(1));
var_dump(stats_stat_factorial(2));
var_dump(stats_stat_factorial(3));
?>
--EXPECTF--
float(1)
float(1)
float(2)
float(6)
bug57831.phpt 0000644 00000000542 15041410412 0006617 0 ustar 00 --TEST--
Bug #57831 wrong storage class for variable in C functions gscgn() and gssst()
--FILE--
<?php
$low = 0.6;
$high = 2.1;
$rand1 = stats_rand_gen_funiform($low, $high);
$rand2 = stats_rand_gen_funiform($low, $high);
$rand3 = stats_rand_gen_funiform($low, $high);
echo ($rand1 !== $rand2) . "\n";
echo ($rand2 !== $rand3) . "\n";
?>
--EXPECTF--
1
1
bug61318-4.phpt 0000644 00000000551 15041410412 0006753 0 ustar 00 --TEST--
Bug #61318 (stats_stat_independent_t also casts values to floats)
--FILE--
<?php
$data1 = array(1, 2, 3);
$data2 = array(4, 5, 6);
stats_stat_independent_t($data1, $data2);
var_dump($data1);
var_dump($data2);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
stats_rand_gen_ipoisson.phpt 0000644 00000000520 15041410412 0012344 0 ustar 00 --TEST--
stats_rand_gen_ipoisson()
--FILE--
<?php
var_dump(is_int(stats_rand_gen_ipoisson(1)));
var_dump(stats_rand_gen_ipoisson(0));
// error cases
var_dump(stats_rand_gen_ipoisson(-0.1)); // mu < 0
?>
--EXPECTF--
bool(true)
int(0)
Warning: stats_rand_gen_ipoisson(): mu < 0.0 . mu : -1.000000E-1 in %s on line %d
bool(false)
stats_rand_gen_t.phpt 0000644 00000000621 15041410412 0010746 0 ustar 00 --TEST--
stats_rand_gen_t()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_t(1)));
// error cases
var_dump(stats_rand_gen_t(-0.1)); // df < 0
var_dump(stats_rand_gen_t(0)); // df == 0
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_t(): df <= 0 . df : -1.000000E-1 in %s on line %d
bool(false)
Warning: stats_rand_gen_t(): df <= 0 . df : 0.000000E+0 in %s on line %d
bool(false)
stats_rand_ibinomial_negative.phpt 0000644 00000001213 15041410412 0013475 0 ustar 00 --TEST--
stats_rand_ibinomial_negative()
--FILE--
<?php
var_dump(is_int(stats_rand_ibinomial_negative(2, 0.5)));
// error cases
var_dump(stats_rand_ibinomial_negative(-1, 0.5)); // n < 0
var_dump(stats_rand_ibinomial_negative(1, -0.1)); // pp < 0
var_dump(stats_rand_ibinomial_negative(1, 1.1)); // pp > 1
?>
--EXPECTF--
bool(true)
Warning: stats_rand_ibinomial_negative(): n < 0. n : -1 in %s on line %d
bool(false)
Warning: stats_rand_ibinomial_negative(): p is out of range. p : -1E-1 in %s on line %d
bool(false)
Warning: stats_rand_ibinomial_negative(): p is out of range. p : 1E+0 in %s on line %d
bool(false)
stats_skew.phpt 0000644 00000000217 15041410412 0007620 0 ustar 00 --TEST--
stats_skew()
--FILE--
<?php
var_dump(sprintf("%2.9f", stats_skew(array(99,333,5, 7, 2, 4))));
?>
--EXPECTF--
string(11) "1.505674536"
stats_dens_pmf_binomial.phpt 0000644 00000002226 15041410412 0012316 0 ustar 00 --TEST--
stats_dens_pmf_binomial()
--INI--
serialize_precision=14
--FILE--
<?php
// check for each x
foreach (range(0, 3) as $x) {
var_dump(stats_dens_pmf_binomial($x, 3, 0.7));
}
// check for each n
foreach (range(0, 3) as $n) {
var_dump(stats_dens_pmf_binomial(1, $n, 0.7));
}
// check for each pi
foreach (range(0, 1, 0.2) as $pi) {
var_dump(stats_dens_pmf_binomial(1, 3, $pi));
}
// error cases
var_dump(stats_dens_pmf_binomial(0, 0, 0.7)); // x == n == 0
var_dump(stats_dens_pmf_binomial(0, 3, 0)); // x == pi == 0
var_dump(stats_dens_pmf_binomial(3, 3, 1)); // x == n, pi == 1
?>
--EXPECTF--
float(0.027)
float(0.189)
float(0.441)
float(0.343)
float(0)
float(0.7)
float(0.42)
float(0.189)
float(0)
float(0.384)
float(0.432)
float(0.288)
float(0.096)
float(0)
Warning: stats_dens_pmf_binomial(): Params leading to pow(0, 0). x: %f n: %f pi: %f in %s on line %d
bool(false)
Warning: stats_dens_pmf_binomial(): Params leading to pow(0, 0). x: %f n: %f pi: %f in %s on line %d
bool(false)
Warning: stats_dens_pmf_binomial(): Params leading to pow(0, 0). x: %f n: %f pi: %f in %s on line %d
bool(false)
stats_dens_beta.phpt 0000644 00000001164 15041410412 0010575 0 ustar 00 --TEST--
stats_dens_beta()
--FILE--
<?php
// check for each x
foreach (range(0.1, 0.9, 0.2) as $x) {
var_dump(round(stats_dens_beta($x, 2, 3), 6));
}
// check for each a
foreach (range(0.5, 3, 0.5) as $a) {
var_dump(round(stats_dens_beta(0.4, $a, 3), 6));
}
// check for each b
foreach (range(0.5, 3, 0.5) as $b) {
var_dump(round(stats_dens_beta(0.4, 2, $b), 6));
}
?>
--EXPECTF--
float(0.972)
float(1.764)
float(1.5)
float(0.756)
float(0.108)
float(0.533634)
float(1.08)
float(1.494176)
float(1.728)
float(1.793011)
float(1.728)
float(0.387298)
float(0.8)
float(1.161895)
float(1.44)
float(1.626653)
float(1.728)
stats_stat_percentile.phpt 0000644 00000000304 15041410412 0012031 0 ustar 00 --TEST--
stats_stat_percentile()
--FILE--
<?php
var_dump(stats_stat_percentile(array(1, 3, 2, 4), 50));
var_dump(stats_stat_percentile(array(1, 3, 5, 2, 4), 50));
?>
--EXPECTF--
float(2)
float(3)
bug61318-13.phpt 0000644 00000000531 15041410412 0007031 0 ustar 00 --TEST--
Bug #61318 (stats_covariance also casts values to floats)
--FILE--
<?php
$data1 = array(1, 2, 3);
$data2 = array(4, 5, 6);
stats_covariance($data1, $data2);
var_dump($data1);
var_dump($data2);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
bug61318-5.phpt 0000644 00000000537 15041410412 0006760 0 ustar 00 --TEST--
Bug #61318 (stats_stat_paired_t also casts values to floats)
--FILE--
<?php
$data1 = array(1, 2, 3);
$data2 = array(4, 5, 6);
stats_stat_paired_t($data1, $data2);
var_dump($data1);
var_dump($data2);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
stats_rand_gen_noncentral_chisquare.phpt 0000644 00000001154 15041410412 0014714 0 ustar 00 --TEST--
stats_rand_gen_noncentral_chisquare()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_noncentral_chisquare(2, 3)));
// error cases
var_dump(stats_rand_gen_noncentral_chisquare(0.9, 3)); // df < 1
var_dump(stats_rand_gen_noncentral_chisquare(2, -0.1)); // xnonc < 0
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_noncentral_chisquare(): df < 1 or xnonc < 0. df value : 9.000000E-1 xnonc value : 3.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_noncentral_chisquare(): df < 1 or xnonc < 0. df value : 2.000000E+0 xnonc value : -1.000000E-1 in %s on line %d
bool(false)
stats_kurtosis.phpt 0000644 00000000216 15041410412 0010531 0 ustar 00 --TEST--
stats_kurtosis()
--FILE--
<?php
var_dump(sprintf("%2.9f", stats_kurtosis(array(1,3,5,7))));
?>
--EXPECTF--
string(12) "-1.360000000"
bug61318-3.phpt 0000644 00000000547 15041410412 0006757 0 ustar 00 --TEST--
Bug #61318 (stats_stat_innerproduct also casts values to floats)
--FILE--
<?php
$data1 = array(1, 2, 3);
$data2 = array(4, 5, 6);
stats_stat_innerproduct($data1, $data2);
var_dump($data1);
var_dump($data2);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
stats_rand_gen_noncentral_f.phpt 0000644 00000002560 15041410412 0013157 0 ustar 00 --TEST--
stats_rand_gen_noncentral_f()
--INI--
serialize_precision=14
--FILE--
<?php
var_dump(is_float(stats_rand_gen_noncentral_f(2, 3, 4)));
// error cases
var_dump(stats_rand_gen_noncentral_f(0.9, 3, 4)); // dfn < 1
var_dump(stats_rand_gen_noncentral_f(2, -0.1, 4)); // dfd < 0
var_dump(stats_rand_gen_noncentral_f(2, 0, 4)); // dfd == 0
var_dump(stats_rand_gen_noncentral_f(2, 3, -0.1)); // xnonc < 0
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 9.000000E-1 dfd: 3.000000E+0 xnonc: 4.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 2.000000E+0 dfd: -1.000000E-1 xnonc: 4.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 2.000000E+0 dfd: 0.000000E+0 xnonc: 4.000000E+0 in %s on line %d
bool(false)
Warning: stats_rand_gen_noncentral_f(): Either (1) Numerator df < 1.0 or (2) Denominator df <= 0.0 or (3) Noncentrality parameter < 0.0. dfn: 2.000000E+0 dfd: 3.000000E+0 xnonc: -1.000000E-1 in %s on line %d
bool(false)
bug61318-6.phpt 0000644 00000000361 15041410412 0006754 0 ustar 00 --TEST--
Bug #61318 (stats_stat_percentile also casts values to floats)
--FILE--
<?php
$data = array(1, 2, 3);
stats_stat_percentile($data, 50);
var_dump($data);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
bug58394.phpt 0000644 00000000374 15041410412 0006627 0 ustar 00 --TEST--
Bug #58394 stats_cdf_chisquare() dies when which=2,3
--FILE--
<?php
var_dump(round(stats_cdf_chisquare(0.0525437064989, 283, 2), 6));
var_dump(round(stats_cdf_chisquare(0.0525437064989, 245.56, 3), 6));
?>
--EXPECTF--
float(245.56)
float(283)
bug61318-7.phpt 0000644 00000000545 15041410412 0006761 0 ustar 00 --TEST--
Bug #61318 (stats_stat_correlation also casts values to floats)
--FILE--
<?php
$data1 = array(1, 2, 3);
$data2 = array(4, 5, 6);
stats_stat_correlation($data1, $data2);
var_dump($data1);
var_dump($data2);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
bug61318-8.phpt 0000644 00000000337 15041410412 0006761 0 ustar 00 --TEST--
Bug #61318 (stats_variance also casts values to floats)
--FILE--
<?php
$data = array(1, 2, 3);
stats_variance($data);
var_dump($data);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
stats_stat_innerproduct.phpt 0000644 00000000460 15041410412 0012416 0 ustar 00 --TEST--
stats_stat_innerproduct()
--FILE--
<?php
var_dump(stats_stat_innerproduct(array(1, 2), array(3, 4)));
var_dump(stats_stat_innerproduct(array(1, 2), array(3, 4, 5)));
?>
--EXPECTF--
float(11)
Warning: stats_stat_innerproduct(): Unequal number of X and Y coordinates in %s on line %d
bool(false)
stats_dens_pmf_hypergeometric.phpt 0000644 00000003240 15041410412 0013547 0 ustar 00 --TEST--
stats_dens_pmf_hypergeometric()
--FILE--
<?php
/*
* Definition from Wikipedia
* (see https://en.wikipedia.org/wiki/Hypergeometric_distribution)
*
* P(X=k) = binom(k, K) * binom(n-k, N-K) / binom(n, N)
* where
* N is the population size,
* K is the number of success states in the population,
* n is the number of draws,
* k is the number of observed successes.
*
* Implementation in php_stats.c
*
* stats_dens_pmf_hypergeometric(n1, n2, N1, N2)
* = binom(n1, N1) * binom(n2, N2) / binom(n1+n2, N1+N2)
*
* so the relation between both definitions is
* n1 = k is the number of observed successes,
* n2 = n - k is the number of observed failures,
* N1 = K is the number of success states in the population,
* N2 = N - K is the number of failure states in the population.
*/
// check for each n1
foreach (range(0, 3) as $n1) {
var_dump(stats_dens_pmf_hypergeometric($n1, 1, 2, 3));
}
// check for each n2
foreach (range(0, 3) as $n2) {
var_dump(stats_dens_pmf_hypergeometric(1, $n2, 2, 3));
}
// check for each N1
foreach (range(0, 3) as $N1) {
var_dump(stats_dens_pmf_hypergeometric(1, 1, $N1, 3));
}
// check for each N2
foreach (range(1, 3) as $N2) {
var_dump(round(stats_dens_pmf_hypergeometric(1, 1, 2, $N2), 6));
}
// error cases
var_dump(stats_dens_pmf_hypergeometric(1, 3, 1, 2)); // n1 + n2 > N1 + N2
?>
--EXPECTF--
float(0.6)
float(0.6)
float(0.3)
float(0)
float(0.4)
float(0.6)
float(0.6)
float(0.4)
float(0)
float(0.5)
float(0.6)
float(0.6)
float(0.666667)
float(0.666667)
float(0.6)
Warning: stats_dens_pmf_hypergeometric(): possible division by zero - n1+n2 >= N1+N2 in %s on line %d
float(NAN)
stats_dens_f.phpt 0000644 00000001253 15041410412 0010106 0 ustar 00 --TEST--
stats_dens_f()
--FILE--
<?php
// check for each x
foreach (range(0, 3, 0.5) as $x) {
var_dump(round(stats_dens_f($x, 3, 2), 6));
}
// check for each dfr1
foreach (range(0.5, 3, 0.5) as $dfr1) {
var_dump(round(stats_dens_f(1, $dfr1, 2), 6));
}
// check for each dfr2
foreach (range(0.5, 3, 0.5) as $dfr2) {
var_dump(round(stats_dens_f(1, 3, $dfr2), 6));
}
?>
--EXPECTF--
float(0)
float(0.48097)
float(0.278855)
float(0.177241)
float(0.121785)
float(0.088606)
float(0.067279)
float(0.133748)
float(0.19245)
float(0.227008)
float(0.25)
float(0.266463)
float(0.278855)
float(0.139548)
float(0.206748)
float(0.249129)
float(0.278855)
float(0.301042)
float(0.31831)
bug61318-12.phpt 0000644 00000000337 15041410412 0007034 0 ustar 00 --TEST--
Bug #61318 (stats_kurtosis also casts values to floats)
--FILE--
<?php
$data = array(1, 2, 3);
stats_kurtosis($data);
var_dump($data);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
stats_cdf_cauchy.phpt 0000644 00000002136 15041410412 0010741 0 ustar 00 --TEST--
stats_cdf_cauchy()
--FILE--
<?php
// which = 1 : calculate P from (X, MEAN, SD)
var_dump(round(stats_cdf_cauchy(1, 2, 3, 1), 6));
var_dump(round(stats_cdf_cauchy(6, 5, 4, 1), 6));
// which = 2 : calculate X from (P, MEAN, SD)
var_dump(round(stats_cdf_cauchy(0.397583618, 2, 3, 2), 6));
var_dump(round(stats_cdf_cauchy(0.57797913, 5, 4, 2), 6));
// which = 3 : calculate MEAN from (P, X, SD)
var_dump(round(stats_cdf_cauchy(0.397583618, 1, 3, 3), 6));
var_dump(round(stats_cdf_cauchy(0.57797913, 6, 4, 3), 6));
// which = 4 : calculate SD from (P, X, MEAN)
var_dump(round(stats_cdf_cauchy(0.397583618, 1, 2, 4), 6));
var_dump(round(stats_cdf_cauchy(0.57797913, 6, 5, 4), 6));
// error cases
var_dump(stats_cdf_cauchy(1, 2, 3, 0)); // which < 1
var_dump(stats_cdf_cauchy(1, 2, 3, 5)); // which > 4
?>
--EXPECTF--
float(0.397584)
float(0.577979)
float(1)
float(6)
float(2)
float(5)
float(3)
float(4)
Warning: stats_cdf_cauchy(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_cauchy(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
stats_cdf_noncentral_f.phpt 0000644 00000004565 15041410412 0012145 0 ustar 00 --TEST--
stats_cdf_noncentral_f()
--FILE--
<?php
// which = 1 : calculate P from (F, DFN, DFD, PNONC)
var_dump(round(stats_cdf_noncentral_f(5, 2, 3, 4, 1), 6));
// which = 2 : calculate F from (P, DFN, DFD, PNONC)
var_dump(round(stats_cdf_noncentral_f(0.650459043, 2, 3, 4, 2), 6));
// which = 3 : calculate DFN from (P, F, DFD, PNONC)
var_dump(round(stats_cdf_noncentral_f(0.650459043, 5, 3, 4, 3), 6));
// which = 4 : calculate DFD from (P, F, DFN, PNONC)
var_dump(round(stats_cdf_noncentral_f(0.650459043, 5, 2, 4, 4), 6));
// which = 5 : calculate PNONC from (P, F, DFN, DFD)
var_dump(round(stats_cdf_noncentral_f(0.650459043, 5, 2, 3, 5), 6));
// error cases
var_dump(round(stats_cdf_noncentral_f(1, 2, 3, 4, 0), 6)); // which < 1
var_dump(round(stats_cdf_noncentral_f(1, 2, 3, 4, 6), 6)); // which > 5
var_dump(round(stats_cdf_noncentral_f(-0.1, 2, 3, 4, 2), 6)); // P < 0
var_dump(round(stats_cdf_noncentral_f(1.1, 2, 3, 4, 2), 6)); // P > 1
var_dump(round(stats_cdf_noncentral_f(-0.1, 2, 3, 4, 1), 6)); // F < 0
var_dump(round(stats_cdf_noncentral_f(1, -0.1, 3, 4, 1), 6)); // DFN < 0
var_dump(round(stats_cdf_noncentral_f(1, 0, 3, 4, 1), 6)); // DFN == 0
var_dump(round(stats_cdf_noncentral_f(1, 2, -0.1, 4, 1), 6)); // DFR < 0
var_dump(round(stats_cdf_noncentral_f(1, 2, 0, 4, 1), 6)); // DFR == 0
var_dump(round(stats_cdf_noncentral_f(1, 2, 3, -0.1, 1), 6)); // PNONC < 0
?>
--EXPECTF--
float(0.650459)
float(5)
float(2)
float(3)
float(4)
Warning: stats_cdf_noncentral_f(): Fifth parameter should be in the 1..5 range in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Fifth parameter should be in the 1..5 range in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
Warning: stats_cdf_noncentral_f(): Computation Error in cdffnc in %s on line %d
float(0)
stats_dens_weibull.phpt 0000644 00000001144 15041410412 0011323 0 ustar 00 --TEST--
stats_dens_weibull()
--FILE--
<?php
// check for each x
foreach (range(0, 2, 0.5) as $x) {
var_dump(round(stats_dens_weibull($x, 2, 3), 6));
}
// check for each a
foreach (range(0.5, 2, 0.5) as $a) {
var_dump(round(stats_dens_weibull(1, $a, 3), 6));
}
// check for each b
foreach (range(0.5, 2, 0.5) as $b) {
var_dump(round(stats_dens_weibull(1, 2, $b), 6));
}
// error cases
?>
--EXPECTF--
float(0)
float(0.108067)
float(0.198853)
float(0.2596)
float(0.284969)
float(0.162058)
float(0.238844)
float(0.238138)
float(0.198853)
float(0.146525)
float(0.735759)
float(0.569938)
float(0.3894)
stats_cdf_noncentral_chisquare.phpt 0000644 00000003741 15041410412 0013677 0 ustar 00 --TEST--
stats_cdf_noncentral_chisquare()
--FILE--
<?php
// which = 1 : calculate P from (X, DF, PNONC)
var_dump(round(stats_cdf_noncentral_chisquare(4, 2, 3, 1), 6));
// which = 2 : calculate X from (P, DF, PNONC)
var_dump(round(stats_cdf_noncentral_chisquare(0.493562417, 2, 3, 2), 6));
// which = 3 : calculate DF from (P, X, PNONC)
var_dump(round(stats_cdf_noncentral_chisquare(0.493562417, 4, 3, 3), 6));
// which = 4 : calculate PNONC from (P, X, DF)
var_dump(round(stats_cdf_noncentral_chisquare(0.493562417, 4, 2, 4), 6));
// error cases
var_dump(stats_cdf_noncentral_chisquare(4, 2, 3, 0)); // which < 1
var_dump(stats_cdf_noncentral_chisquare(4, 2, 3, 5)); // which > 4
var_dump(stats_cdf_noncentral_chisquare(-0.1, 2, 3, 2)); // P < 0
var_dump(stats_cdf_noncentral_chisquare(1.1, 2, 3, 2)); // P > 1
var_dump(stats_cdf_noncentral_chisquare(-0.1, 2, 3, 1)); // X < 0
var_dump(stats_cdf_noncentral_chisquare(4, -0.1, 3, 1)); // DF < 0
var_dump(stats_cdf_noncentral_chisquare(4, 0, 3, 1)); // DF == 0
var_dump(stats_cdf_noncentral_chisquare(4, 2, -0.1, 1)); // PNONC < 0
?>
--EXPECTF--
float(0.493562)
float(4)
float(2)
float(3)
Warning: stats_cdf_noncentral_chisquare(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_chisquare(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_chisquare(): Computation Error in cdfchn in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_chisquare(): Computation Error in cdfchn in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_chisquare(): Computation Error in cdfchn in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_chisquare(): Computation Error in cdfchn in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_chisquare(): Computation Error in cdfchn in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_chisquare(): Computation Error in cdfchn in %s on line %d
bool(false)
stats_cdf_weibull.phpt 0000644 00000002144 15041410412 0011127 0 ustar 00 --TEST--
stats_cdf_weibull()
--FILE--
<?php
// which = 1 : calculate P from (X, A, B)
var_dump(round(stats_cdf_weibull(1, 2, 3, 1), 6));
var_dump(round(stats_cdf_weibull(6, 5, 4, 1), 6));
// which = 2 : calculate X from (P, A, B)
var_dump(round(stats_cdf_weibull(0.105160683, 2, 3, 2), 6));
var_dump(round(stats_cdf_weibull(0.999496411, 5, 4, 2), 6));
// which = 3 : calcualte A from (P, X, B)
var_dump(round(stats_cdf_weibull(0.105160683, 1, 3, 3), 6));
var_dump(round(stats_cdf_weibull(0.999496411, 6, 4, 3), 6));
// which = 4 : calculate B from (P, X, A)
var_dump(round(stats_cdf_weibull(0.105160683, 1, 2, 4), 6));
var_dump(round(stats_cdf_weibull(0.999496411, 6, 5, 4), 6));
// error cases
var_dump(stats_cdf_weibull(1, 2, 3, 0)); // which < 1
var_dump(stats_cdf_weibull(1, 2, 3, 5)); // which > 4
?>
--EXPECTF--
float(0.105161)
float(0.999496)
float(1)
float(6)
float(2)
float(5)
float(3)
float(4)
Warning: stats_cdf_weibull(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_weibull(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
stats_variance.phpt 0000644 00000000247 15041410412 0010442 0 ustar 00 --TEST--
stats_variance()
--FILE--
<?php
$a=array(5,7,8,10,10);
var_dump(stats_variance($a));
var_dump(stats_variance($a, true));
?>
--EXPECTF--
float(3.6)
float(4.5)
stats_cdf_noncentral_t.phpt 0000644 00000002731 15041410412 0012154 0 ustar 00 --TEST--
stats_cdf_noncentral_t()
--FILE--
<?php
// which = 1 : calculate P from (T, DF, PNONC)
var_dump(round(stats_cdf_noncentral_t(3, 2, 1, 1), 6));
// which = 2 : calculate T from (P, DF, PNONC)
var_dump(round(stats_cdf_noncentral_t(0.833559426, 2, 1, 2), 6));
// which = 3 : calculate DF from (P, T, PNONC)
var_dump(round(stats_cdf_noncentral_t(0.833559426, 3, 1, 3), 6));
// which = 4 : calculate PNONC from (P, DF, T)
var_dump(round(stats_cdf_noncentral_t(0.833559426, 3, 2, 4), 6));
// error cases
var_dump(stats_cdf_noncentral_t(3, 2, 1, 0)); // which < 0
var_dump(stats_cdf_noncentral_t(3, 2, 1, 5)); // which > 4
var_dump(stats_cdf_noncentral_t(-0.1, 2, 1, 2)); // P < 0
var_dump(stats_cdf_noncentral_t(1.1, 2, 1, 2)); // P > 1
var_dump(stats_cdf_noncentral_t(3, -0.1, 1, 1)); // DF < 0
var_dump(stats_cdf_noncentral_t(3, 0, 1, 1)); // DF == 1
?>
--EXPECTF--
float(0.833559)
float(3)
float(2)
float(1)
Warning: stats_cdf_noncentral_t(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_t(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_t(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_t(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_t(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_noncentral_t(): Computation Error in %s on line %d
bool(false)
stats_stat_binomial_coef.phpt 0000644 00000000501 15041410412 0012464 0 ustar 00 --TEST--
stats_stat_binomial_coef()
--FILE--
<?php
var_dump(stats_stat_binomial_coef(0, 4));
var_dump(stats_stat_binomial_coef(1, 4));
var_dump(stats_stat_binomial_coef(2, 4));
var_dump(stats_stat_binomial_coef(3, 4));
var_dump(stats_stat_binomial_coef(4, 4));
?>
--EXPECTF--
float(1)
float(4)
float(6)
float(4)
float(1)
stats_stat_paired_t.phpt 0000644 00000001071 15041410412 0011470 0 ustar 00 --TEST--
stats_stat_paired_t()
--FILE--
<?php
var_dump(stats_stat_paired_t(array(1, 2), array(1, 1)));
var_dump(stats_stat_paired_t(array(1, 2), array(2, 1)));
var_dump(stats_stat_paired_t(array(1, 2), array(2, 2)));
var_dump(stats_stat_paired_t(array(1, 2), array(1, 2, 3)));
var_dump(stats_stat_paired_t(array(1), array(2)));
?>
--EXPECTF--
float(1)
float(0)
float(-1)
Warning: stats_stat_paired_t(): Unequal number of X and Y coordinates in %s on line %d
bool(false)
Warning: stats_stat_paired_t(): arr1 should have atleast 2 elements in %s on line %d
bool(false)
bug57830.phpt 0000644 00000000307 15041410412 0006615 0 ustar 00 --TEST--
Bug #57830 wrong storage class for variable in C function gsrgs()
--FILE--
<?php
stats_rand_setall(4711, 88888);
$val = stats_rand_gen_gamma(0.6, 0.1);
echo is_float($val);
?>
--EXPECTF--
1
stats_rand_gen_noncentral_t.phpt 0000644 00000000467 15041410412 0013201 0 ustar 00 --TEST--
stats_rand_gen_noncentral_t()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_noncentral_t(2, 1)));
// error cases
var_dump(stats_rand_gen_noncentral_t(-0.1, 1)); // df < 0
?>
--EXPECTF--
bool(true)
Warning: stats_rand_gen_noncentral_t(): df <= 0 . df : -1.000000E-1 in %s on line %d
bool(false)
stats_stat_powersum.phpt 0000644 00000000757 15041410412 0011574 0 ustar 00 --TEST--
stats_stat_powersum()
--FILE--
<?php
var_dump(stats_stat_powersum(array(1, 2, 4), 2));
var_dump(stats_stat_powersum(array(1, 2, 4), 0));
var_dump(stats_stat_powersum(array(1, 2, 4), -2));
var_dump(stats_stat_powersum(array(1, 0, 4), 1));
var_dump(stats_stat_powersum(array(1, 0, 4), 0));
var_dump(stats_stat_powersum(array(), 1));
?>
--EXPECTF--
float(21)
float(3)
float(1.3125)
float(5)
Warning: stats_stat_powersum(): Both value and power are zero in %s on line %d
float(2)
float(0)
stats_cdf_laplace.phpt 0000644 00000002161 15041410412 0011064 0 ustar 00 --TEST--
stats_cdf_laplace()
--FILE--
<?php
// which = 1 : calculate P from (X, MEAN, SD)
var_dump(round(stats_cdf_laplace(0, 1, 2, 1), 6));
var_dump(round(stats_cdf_laplace(5, 4, 3, 1), 6));
// which = 2 : calculate X from (P, MEAN, SD)
var_dump(round(stats_cdf_laplace(0.30326533, 1, 2, 2), 6));
var_dump(round(stats_cdf_laplace(0.641734344, 4, 3, 2), 6));
// which = 3 : calculate MEAN from (P, X, SD)
var_dump(round(stats_cdf_laplace(0.30326533, 0, 2, 3), 6));
var_dump(round(stats_cdf_laplace(0.641734344, 5, 3, 3), 6));
// which = 4 : calculate SD from (P, X, MEAN)
var_dump(round(stats_cdf_laplace(0.30326533, 0, 1, 4), 6));
var_dump(round(stats_cdf_laplace(0.641734344, 5, 4, 4), 6));
// error cases
var_dump(stats_cdf_laplace(0, 1, 2, 0)); // which < 1
var_dump(stats_cdf_laplace(0, 1, 2, 5)); // which < 4
?>
--EXPECTF--
float(0.303265)
float(0.641734)
float(0)
float(5)
float(1)
float(4)
float(2)
float(3)
Warning: stats_cdf_laplace(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_laplace(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
bug61318-10.phpt 0000644 00000000351 15041410412 0007026 0 ustar 00 --TEST--
Bug #61318 (stats_harmonic_mean also casts values to floats)
--FILE--
<?php
$data = array(1, 2, 3);
stats_harmonic_mean($data);
var_dump($data);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
stats_stat_independent_t.phpt 0000644 00000001106 15041410412 0012520 0 ustar 00 --TEST--
stats_stat_independent_t()
--FILE--
<?php
var_dump(round(stats_stat_independent_t(array(1, 2), array(1, 2)), 8));
var_dump(round(stats_stat_independent_t(array(1, 2), array(2, 3)), 8));
var_dump(stats_stat_independent_t(array(1), array(1, 2)));
var_dump(stats_stat_independent_t(array(1, 2), array(1)));
?>
--EXPECTF--
float(0)
float(-1.41421356)
Warning: stats_stat_independent_t(): Each argument should have more than 1 element in %s on line %d
bool(false)
Warning: stats_stat_independent_t(): Each argument should have more than 1 element in %s on line %d
bool(false)
stats_dens_exponential.phpt 0000644 00000001127 15041410412 0012207 0 ustar 00 --TEST--
stats_dens_exponential()
--FILE--
<?php
// check for each x
foreach (range(-0.5, 2, 0.5) as $x) {
var_dump(round(stats_dens_exponential($x, 2), 6));
}
// check for each scale
foreach (range(0.5, 2, 0.5) as $scale) {
var_dump(round(stats_dens_exponential(1, $scale), 6));
}
// error cases
var_dump(stats_dens_exponential(1, 0)); // scale == 0
?>
--EXPECTF--
float(0)
float(0.5)
float(0.3894)
float(0.303265)
float(0.236183)
float(0.18394)
float(0.270671)
float(0.367879)
float(0.342278)
float(0.303265)
Warning: stats_dens_exponential(): scale == 0.0 in %s on line %d
bool(false)
stats_dens_uniform.phpt 0000644 00000000634 15041410412 0011342 0 ustar 00 --TEST--
stats_dens_uniform()
--FILE--
<?php
var_dump(stats_dens_uniform(2.5, 1, 3)); // A <= X <= B
var_dump(stats_dens_uniform(0, 1, 3)); // X < A
var_dump(stats_dens_uniform(4, 1, 3)); // X > B
// error cases
var_dump(stats_dens_uniform(1, 1, 1)); // A == B
?>
--EXPECTF--
float(0.5)
float(0)
float(0)
Warning: stats_dens_uniform(): b == a == 1.000000E+0 in %s on line %d
bool(false)
stats_rand_ibinomial.phpt 0000644 00000001467 15041410412 0011626 0 ustar 00 --TEST--
stats_rand_ibinomial()
--FILE--
<?php
var_dump(in_array(stats_rand_ibinomial(3, 0.7), array(0, 1, 2, 3)));
var_dump(stats_rand_ibinomial(0, 0.7));
var_dump(stats_rand_ibinomial(3, 0));
var_dump(stats_rand_ibinomial(3, 1));
// error cases
var_dump(stats_rand_ibinomial(-1, 0.7)); // n < 0
var_dump(stats_rand_ibinomial(3, -0.1)); // pp < 0
var_dump(stats_rand_ibinomial(3, 1.1)); // pp > 1
?>
--EXPECTF--
bool(true)
int(0)
int(0)
int(3)
Warning: stats_rand_ibinomial(): Bad values for the arguments. n : -1 pp : 7.000000E-1 in %s on line %d
bool(false)
Warning: stats_rand_ibinomial(): Bad values for the arguments. n : 3 pp : -1.000000E-1 in %s on line %d
bool(false)
Warning: stats_rand_ibinomial(): Bad values for the arguments. n : 3 pp : 1.100000E+0 in %s on line %d
bool(false)
stats_cdf_beta.phpt 0000644 00000003463 15041410412 0010404 0 ustar 00 --TEST--
stats_cdf_beta()
--FILE--
<?php
// which = 1 : calculate P from (X, A, B)
var_dump(round(stats_cdf_beta(0.5, 2, 4, 1), 6));
// which = 2 : calculate X from (P, A, B)
var_dump(round(stats_cdf_beta(0.8125, 2, 4, 2), 6));
// which = 3 : calculate A from (P, X, B)
var_dump(round(stats_cdf_beta(0.8125, 0.5, 4, 3), 6));
// which = 4 : calculate B from (P, X, A)
var_dump(round(stats_cdf_beta(0.8125, 0.5, 2, 4), 6));
// error cases
var_dump(stats_cdf_beta(0.5, 2, 4, 0)); // which < 1
var_dump(stats_cdf_beta(0.5, 2, 4, 5)); // which > 4
var_dump(stats_cdf_beta(-0.1, 2, 4, 2)); // P < 0
var_dump(stats_cdf_beta(1.1, 2, 4, 2)); // P > 1
var_dump(stats_cdf_beta(-0.1, 2, 4, 1)); // X < 0
var_dump(stats_cdf_beta(1.1, 2, 4, 1)); // X > 1
var_dump(stats_cdf_beta(0.5, -0.1, 4, 1)); // A < 0
var_dump(stats_cdf_beta(0.5, 0, 4, 1)); // A == 0
var_dump(stats_cdf_beta(0.5, 2, -0.1, 1)); // B < 0
var_dump(stats_cdf_beta(0.5, 2, 0, 1)); // B == 0
?>
--EXPECTF--
float(0.8125)
float(0.5)
float(2)
float(4)
Warning: stats_cdf_beta(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_beta(): Computation Error in %s on line %d
bool(false)
bug61318-9.phpt 0000644 00000000363 15041410412 0006761 0 ustar 00 --TEST--
Bug #61318 (stats_absolute_deviation also casts values to floats)
--FILE--
<?php
$data = array(1, 2, 3);
stats_absolute_deviation($data);
var_dump($data);
?>
--EXPECTF--
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
stats_rand_gen_normal.phpt 0000644 00000000506 15041410412 0011775 0 ustar 00 --TEST--
stats_rand_gen_normal()
--FILE--
<?php
var_dump(is_float(stats_rand_gen_normal(0, 1)));
var_dump(stats_rand_gen_normal(0, 0));
// error cases
var_dump(stats_rand_gen_normal(0, -0.1)); // sd < 0
?>
--EXPECTF--
bool(true)
float(0)
Warning: stats_rand_gen_normal(): sd < 0.0 . sd : %f in %s on line %d
bool(false)
stats_cdf_normal.phpt 0000644 00000002746 15041410412 0010764 0 ustar 00 --TEST--
stats_cdf_normal()
--FILE--
<?php
// which = 1 : calculate P from (X, MEAN, SD)
var_dump(round(stats_cdf_normal(1, 0, 1, 1), 6));
// which = 2 : calculate X from (P, MEAN, SD)
var_dump(round(stats_cdf_normal(0.841344746, 0, 1, 2), 6));
// which = 3 : calculate MEAN from (P, X, SD)
var_dump(round(stats_cdf_normal(0.841344746, 1, 1, 3), 6));
// which = 4 : calculate SD from (P, X, MEAN)
var_dump(round(stats_cdf_normal(0.841344746, 1, 0, 4), 6));
// error cases
var_dump(stats_cdf_normal(1, 0, 1, 0)); // which < 1
var_dump(stats_cdf_normal(1, 0, 1, 5)); // which > 4
var_dump(stats_cdf_normal(-0.1, 0, 1, 2)); // P < 0
var_dump(stats_cdf_normal(0, 0, 1, 2)); // P == 0
var_dump(stats_cdf_normal(1.1, 0, 1, 2)); // P > 1
var_dump(stats_cdf_normal(1, 0, -0.1, 1)); // SD < 0
var_dump(stats_cdf_normal(1, 0, 0, 1)); // SD == 0
?>
--EXPECTF--
float(0.841345)
float(1)
float(0)
float(1)
Warning: stats_cdf_normal(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_normal(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_normal(): Computation error in %s on line %d
bool(false)
Warning: stats_cdf_normal(): Computation error in %s on line %d
bool(false)
Warning: stats_cdf_normal(): Computation error in %s on line %d
bool(false)
Warning: stats_cdf_normal(): Computation error in %s on line %d
bool(false)
Warning: stats_cdf_normal(): Computation error in %s on line %d
bool(false)
stats_stat_correlation.phpt 0000644 00000000716 15041410412 0012227 0 ustar 00 --TEST--
stats_stat_correlation()
--FILE--
<?php
var_dump(stats_stat_correlation(array(1, 2, 3), array(1, 2, 3)));
var_dump(stats_stat_correlation(array(1, 2, 3), array(1, 2, 1)));
var_dump(stats_stat_correlation(array(1, 2, 3), array(3, 2, 1)));
var_dump(stats_stat_correlation(array(1, 2, 3), array(1, 2, 3, 4)));
?>
--EXPECTF--
float(1)
float(0)
float(-1)
Warning: stats_stat_correlation(): Unequal number of X and Y coordinates in %s on line %d
bool(false)
bug61318.phpt 0000644 00000000424 15041410412 0006611 0 ustar 00 --TEST--
Bug #61318 stats_standard_deviation casts values to floats
--FILE--
<?php
$data = array(2, 3, 2, 2, 2);
stats_standard_deviation($data);
var_dump($data);
?>
--EXPECTF--
array(5) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
int(2)
[3]=>
int(2)
[4]=>
int(2)
}
stats_dens_gamma.phpt 0000644 00000001353 15041410412 0010744 0 ustar 00 --TEST--
stats_dens_gamma()
--FILE--
<?php
// check for each x
foreach (range(0.5, 2, 0.5) as $x) {
var_dump(round(stats_dens_gamma($x, 1, 1), 6));
}
// check for each shape
foreach (range(0.5, 2, 0.5) as $shape) {
var_dump(round(stats_dens_gamma(1, $shape, 1), 6));
}
// check for each scale
foreach (range(0.5, 2, 0.5) as $scale) {
var_dump(round(stats_dens_gamma(1, 1, $scale), 6));
}
// error cases
var_dump(stats_dens_gamma(1, 1, 0)); // scale == 0
?>
--EXPECTF--
float(0.606531)
float(0.367879)
float(0.22313)
float(0.135335)
float(0.207554)
float(0.367879)
float(0.415107)
float(0.367879)
float(0.270671)
float(0.367879)
float(0.342278)
float(0.303265)
Warning: stats_dens_gamma(): scale == 0.0 in %s on line %d
bool(false)
stats_dens_t.phpt 0000644 00000001027 15041410412 0010123 0 ustar 00 --TEST--
stats_dens_t()
--FILE--
<?php
// check foreach x
foreach (range(-1, 1, 0.5) as $x) {
var_dump(round(stats_dens_t($x, 1), 6));
}
// check foreach dfr
foreach (range(0.5, 2, 0.5) as $dfr) {
var_dump(round(stats_dens_t(0, $dfr), 6));
}
// error cases
var_dump(stats_dens_t(1, 0)); // dfr == 0
?>
--EXPECTF--
float(0.159155)
float(0.254648)
float(0.31831)
float(0.254648)
float(0.159155)
float(0.269676)
float(0.31831)
float(0.340735)
float(0.353553)
Warning: stats_dens_t(): dfr == 0.0 in %s on line %d
bool(false)
stats_dens_pmf_poisson.phpt 0000644 00000000740 15041410412 0012215 0 ustar 00 --TEST--
stats_dens_pmf_poisson()
--FILE--
<?php
// check for each x
foreach (range(0, 5) as $x) {
var_dump(round(stats_dens_pmf_poisson($x, 1), 6));
}
// check for each lb
foreach (range(0.5, 3, 0.5) as $lb) {
var_dump(round(stats_dens_pmf_poisson(1, $lb), 6));
}
?>
--EXPECTF--
float(0.367879)
float(0.367879)
float(0.18394)
float(0.061313)
float(0.015328)
float(0.003066)
float(0.303265)
float(0.367879)
float(0.334695)
float(0.270671)
float(0.205212)
float(0.149361)
stats_harmonic_mean.phpt 0000644 00000000451 15041410412 0011447 0 ustar 00 --TEST--
stats_harmonic_mean() tests
--FILE--
<?php
var_dump(sprintf("%2.9f", stats_harmonic_mean(array(1,3,5,7))));
var_dump(stats_standard_deviation(array()));
?>
--EXPECTF--
string(11) "2.386363636"
Warning: stats_standard_deviation(): The array has zero elements in %s on line %d
bool(false)
bug59292.phpt 0000644 00000000525 15041410412 0006623 0 ustar 00 --TEST--
Bug #59292 Error in stats package (stats_cdf_t function)
--FILE--
<?php
var_dump(round(stats_cdf_t(3.0, 5.0, 1), 6)); // this one works
var_dump(round(stats_cdf_t(0.984950, 5.0, 2), 6)); // fails on this
var_dump(round(stats_cdf_t(0.984950, 3.0, 3), 6)); // and this
?>
--EXPECTF--
float(0.98495)
float(2.999978)
float(4.9999)
stats_rand_gen_iuniform.phpt 0000644 00000000620 15041410412 0012332 0 ustar 00 --TEST--
stats_rand_gen_iuniform()
--FILE--
<?php
var_dump(in_array(stats_rand_gen_iuniform(1, 3), array(1, 2, 3)));
var_dump(stats_rand_gen_iuniform(1, 1));
// error cases
var_dump(stats_rand_gen_iuniform(2, 1)); // low > high
?>
--EXPECTF--
bool(true)
int(1)
Warning: stats_rand_gen_iuniform(): low greater than high. low : 2 high 1 in %s on line %d
bool(false)
stats_cdf_negative_binomial.phpt 0000644 00000003576 15041410412 0013152 0 ustar 00 --TEST--
stats_cdf_negative_binomial()
--FILE--
<?php
// which = 1 : calculate P from (S, XN, PR)
var_dump(round(stats_cdf_negative_binomial(2, 1, 0.4, 1), 6));
// which = 2 : calculate S from (P, XN, PR)
var_dump(round(stats_cdf_negative_binomial(0.784, 1, 0.4, 2), 6));
// which = 3 : calculate XN from (P, S, PR)
var_dump(round(stats_cdf_negative_binomial(0.784, 2, 0.4, 3), 6));
// which = 4 : calculate PR from (P, S, XN)
var_dump(round(stats_cdf_negative_binomial(0.784, 2, 1, 4), 6));
// error cases
var_dump(stats_cdf_negative_binomial(2, 1, 0.4, 0)); // which < 1
var_dump(stats_cdf_negative_binomial(2, 1, 0.4, 5)); // which > 4
var_dump(stats_cdf_negative_binomial(-0.1, 1, 0.4, 2)); // P < 0
var_dump(stats_cdf_negative_binomial(1.1, 1, 0.4, 2)); // P > 0
var_dump(stats_cdf_negative_binomial(-1, 1, 0.4, 1)); // S < 0
var_dump(stats_cdf_negative_binomial(2, -1, 0.4, 1)); // XN < 0
var_dump(stats_cdf_negative_binomial(2, 1, -0.1, 1)); // PR < 0
var_dump(stats_cdf_negative_binomial(2, 1, 1.1, 1)); // PR > 1
?>
--EXPECTF--
float(0.784)
float(2)
float(1)
float(0.4)
Warning: stats_cdf_negative_binomial(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_negative_binomial(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_negative_binomial(): Computation Error in cdfnbn in %s on line %d
bool(false)
Warning: stats_cdf_negative_binomial(): Computation Error in cdfnbn in %s on line %d
bool(false)
Warning: stats_cdf_negative_binomial(): Computation Error in cdfnbn in %s on line %d
bool(false)
Warning: stats_cdf_negative_binomial(): Computation Error in cdfnbn in %s on line %d
bool(false)
Warning: stats_cdf_negative_binomial(): Computation Error in cdfnbn in %s on line %d
bool(false)
Warning: stats_cdf_negative_binomial(): Computation Error in cdfnbn in %s on line %d
bool(false)
stats_dens_normal.phpt 0000644 00000001612 15041410412 0011150 0 ustar 00 --TEST--
stats_dens_normal()
--FILE--
<?php
// check for each x
foreach (range(-2, 2, 0.5) as $x) {
var_dump(round(stats_dens_normal($x, 0, 1), 6));
}
// check for each ave
foreach (range(-2, 2, 0.5) as $ave) {
var_dump(round(stats_dens_normal(1, $ave, 1), 6));
}
// check for each stdev
foreach (range(0.5, 2, 0.5) as $stdev) {
var_dump(round(stats_dens_normal(1, 0, $stdev), 6));
}
// error cases
var_dump(stats_dens_normal(1, 0, 0)); // stdev == 0
?>
--EXPECTF--
float(0.053991)
float(0.129518)
float(0.241971)
float(0.352065)
float(0.398942)
float(0.352065)
float(0.241971)
float(0.129518)
float(0.053991)
float(0.004432)
float(0.017528)
float(0.053991)
float(0.129518)
float(0.241971)
float(0.352065)
float(0.398942)
float(0.352065)
float(0.241971)
float(0.107982)
float(0.241971)
float(0.212965)
float(0.176033)
Warning: stats_dens_normal(): stdev is 0.0 in %s on line %d
bool(false)
stats_cdf_uniform.phpt 0000644 00000002324 15041410412 0011143 0 ustar 00 --TEST--
stats_cdf_uniform()
--FILE--
<?php
// which = 1 : calculate P from (X, A, B)
var_dump(stats_cdf_uniform(2.5, 1, 3, 1)); // A <= X <= B
var_dump(stats_cdf_uniform(0, 1, 3, 1)); // X < A
var_dump(stats_cdf_uniform(4, 1, 3, 1)); // X > B
// which = 2 : calculate X from (P, A, B)
var_dump(stats_cdf_uniform(0.75, 1, 3, 2));
// which = 3 : calculate A from (P, X, B)
var_dump(stats_cdf_uniform(0.75, 2.5, 3, 3));
// which = 4 : calculate B from (P, X, A)
var_dump(stats_cdf_uniform(0.75, 2.5, 1, 4));
// error cases
var_dump(stats_cdf_uniform(2.5, 1, 3, 0)); // which < 1
var_dump(stats_cdf_uniform(2.5, 1, 3, 5)); // which > 4
var_dump(stats_cdf_uniform(-0.1, 1, 3, 2)); // P < 0
var_dump(stats_cdf_uniform(1.1, 1, 3, 2)); // P > 1
?>
--EXPECTF--
float(0.75)
float(0)
float(1)
float(2.5)
float(1)
float(3)
Warning: stats_cdf_uniform(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_uniform(): Fourth parameter should be in the 1..4 range in %s on line %d
bool(false)
Warning: stats_cdf_uniform(): p is out of range. p : -1.000000E-1 in %s on line %d
bool(false)
Warning: stats_cdf_uniform(): p is out of range. p : 1.100000E+0 in %s on line %d
bool(false)
stats_cdf_poisson.phpt 0000644 00000002340 15041410412 0011154 0 ustar 00 --TEST--
stats_cdf_poisson()
--FILE--
<?php
// which = 1 : calculate P from (S, XLAM)
var_dump(round(stats_cdf_poisson(1, 2, 1), 6));
// which = 2 : calculate A from (P, XLAM)
var_dump(round(stats_cdf_poisson(0.40600585, 2, 2), 6));
// which = 3 : calculate XLAM from (P, S)
var_dump(round(stats_cdf_poisson(0.40600585, 1, 3), 6));
// error cases
var_dump(stats_cdf_poisson(1, 2, 0)); // which < 1
var_dump(stats_cdf_poisson(1, 2, 4)); // which > 3
var_dump(stats_cdf_poisson(-0.1, 2, 2)); // P < 0
var_dump(stats_cdf_poisson(1.1, 2, 2)); // P > 0
var_dump(stats_cdf_poisson(-0.1, 2, 1)); // S < 0
var_dump(stats_cdf_poisson(1, -0.1, 1)); // XLAM < 0
?>
--EXPECTF--
float(0.406006)
float(1)
float(2)
Warning: stats_cdf_poisson(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
Warning: stats_cdf_poisson(): Third parameter should be in the 1..3 range in %s on line %d
bool(false)
Warning: stats_cdf_poisson(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_poisson(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_poisson(): Computation Error in %s on line %d
bool(false)
Warning: stats_cdf_poisson(): Computation Error in %s on line %d
bool(false)
stats_rand_ignlgi.phpt 0000644 00000000224 15041410412 0011122 0 ustar 00 --TEST--
stats_rand_ignlgi()
--FILE--
<?php
$r = stats_rand_ignlgi();
var_dump(is_int($r));
var_dump($r >= 1);
?>
--EXPECTF--
bool(true)
bool(true)
bug61318-2.phpt 0000644 00000000424 15041410412 0006750 0 ustar 00 --TEST--
Bug #61318 (stats_stat_powersum also casts values to floats)
--FILE--
<?php
$data = array(2, 3, 2, 2, 2);
stats_stat_powersum($data, 1);
var_dump($data);
?>
--EXPECTF--
array(5) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
int(2)
[3]=>
int(2)
[4]=>
int(2)
}
info.phpt 0000644 00000000414 15041443225 0006373 0 ustar 00 --TEST--
Test phpinfo() displays brotli info
--SKIPIF--
--FILE--
<?php
if (!extension_loaded('brotli')) {
dl('brotli.' . PHP_SHLIB_SUFFIX);
}
phpinfo();
--EXPECTF--
%a
brotli
Brotli support => enabled
Extension Version => %d.%d.%d
Library Version => %d.%d.%d
%a
roundtrip.phpt 0000644 00000004656 15041443225 0007502 0 ustar 00 --TEST--
Test compatibility
--SKIPIF--
--FILE--
<?php
if (!extension_loaded('brotli')) {
dl('brotli.' . PHP_SHLIB_SUFFIX);
}
$dir = __DIR__ . '/../brotli/';
$files = array(
'tests/testdata/alice29.txt',
'tests/testdata/asyoulik.txt',
'tests/testdata/lcet10.txt',
'tests/testdata/plrabn12.txt',
'/c/enc/encode.c',
'/c/common/dictionary.h',
'/c/dec/decode.c',
);
$qualities = array(1, 6, 9, 11);
foreach ($files as $filename) {
foreach ($qualities as $quality) {
echo 'Roundtrip testing file ', basename($filename), ' at quality ', $quality, PHP_EOL;
$expected = $dir . $filename;
if (file_exists($expected)) {
$data = file_get_contents($expected);
$expected_data = brotli_uncompress(brotli_compress($data, $quality));
if ($data !== $expected_data) {
echo " NG\n";
exit(1);
} else {
echo " OK\n";
}
}
}
}
--EXPECTF--
Roundtrip testing file alice29.txt at quality 1
OK
Roundtrip testing file alice29.txt at quality 6
OK
Roundtrip testing file alice29.txt at quality 9
OK
Roundtrip testing file alice29.txt at quality 11
OK
Roundtrip testing file asyoulik.txt at quality 1
OK
Roundtrip testing file asyoulik.txt at quality 6
OK
Roundtrip testing file asyoulik.txt at quality 9
OK
Roundtrip testing file asyoulik.txt at quality 11
OK
Roundtrip testing file lcet10.txt at quality 1
OK
Roundtrip testing file lcet10.txt at quality 6
OK
Roundtrip testing file lcet10.txt at quality 9
OK
Roundtrip testing file lcet10.txt at quality 11
OK
Roundtrip testing file plrabn12.txt at quality 1
OK
Roundtrip testing file plrabn12.txt at quality 6
OK
Roundtrip testing file plrabn12.txt at quality 9
OK
Roundtrip testing file plrabn12.txt at quality 11
OK
Roundtrip testing file encode.c at quality 1
OK
Roundtrip testing file encode.c at quality 6
OK
Roundtrip testing file encode.c at quality 9
OK
Roundtrip testing file encode.c at quality 11
OK
Roundtrip testing file dictionary.h at quality 1
OK
Roundtrip testing file dictionary.h at quality 6
OK
Roundtrip testing file dictionary.h at quality 9
OK
Roundtrip testing file dictionary.h at quality 11
OK
Roundtrip testing file decode.c at quality 1
OK
Roundtrip testing file decode.c at quality 6
OK
Roundtrip testing file decode.c at quality 9
OK
Roundtrip testing file decode.c at quality 11
OK
compatibility.phpt 0000644 00000015134 15041443225 0010316 0 ustar 00 --TEST--
Test compatibility
--SKIPIF--
--FILE--
<?php
if (!extension_loaded('brotli')) {
dl('brotli.' . PHP_SHLIB_SUFFIX);
}
$dir = __DIR__ . '/../brotli/tests/testdata/*.compressed*';
foreach (glob($dir) as $filename) {
echo 'Testing decompression of file ', basename($filename), PHP_EOL;
$split = explode('.compressed', $filename);
$expected = $split[0];
$quality = -1;
if (isset($split[1])) {
$quality = (int)$split[1];
}
if (file_exists($expected)) {
$data = file_get_contents($expected);
$compressed_data = file_get_contents($filename);
$expected_data = brotli_uncompress($compressed_data);
if ($data !== $expected_data) {
echo " read uncompressed .. NG\n";
exit(1);
} else {
echo " read uncompressed .. OK\n";
}
$expected_data = brotli_compress($data, $quality);
if (!$expected_data) {
echo " compressed .. NG\n";
exit(1);
} else {
echo " compressed .. OK\n";
}
$expected_data = brotli_uncompress($compressed_data);
if ($data !== $expected_data) {
echo " uncompressed .. NG\n";
exit(1);
} else {
echo " uncompressed .. OK\n";
}
}
}
--EXPECTF--
Testing decompression of file 10x10y.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file 64x.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file alice29.txt.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file asyoulik.txt.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file backward65536.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file compressed_file.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file compressed_repeated.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.00
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.01
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.02
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.03
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.04
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.05
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.06
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.07
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.08
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.09
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.10
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.11
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.12
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.13
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.14
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.15
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.16
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.17
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file empty.compressed.18
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file lcet10.txt.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file mapsdatazrh.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file monkey.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file plrabn12.txt.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file quickfox.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file quickfox_repeated.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file random_org_10k.bin.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file ukkonooa.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file x.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file x.compressed.00
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file x.compressed.01
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file x.compressed.02
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file x.compressed.03
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file xyzzy.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
Testing decompression of file zeros.compressed
read uncompressed .. OK
compressed .. OK
uncompressed .. OK
yaml_parse_spec_bool.phpt 0000644 00000000523 15044777136 0011640 0 ustar 00 --TEST--
Yaml 1.1 Spec - bool
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
canonical: y
answer: NO
logical: True
option: on
'));
?>
--EXPECT--
array(4) {
["canonical"]=>
bool(true)
["answer"]=>
bool(false)
["logical"]=>
bool(true)
["option"]=>
bool(true)
}
yaml_parse_wiki_YtsBasicTests_006.phpt 0000644 00000000742 15044777136 0014052 0 ustar 00 --TEST--
Yaml YtsBasicTests - Sequence in a Mapping
--DESCRIPTION--
A value in a mapping can be a sequence.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('foo: whatever
bar:
- uno
- dos
'));
?>
--EXPECT--
array(2) {
["foo"]=>
string(8) "whatever"
["bar"]=>
array(2) {
[0]=>
string(3) "uno"
[1]=>
string(3) "dos"
}
}
bug_75029.phpt 0000644 00000000632 15044777136 0007003 0 ustar 00 --TEST--
Test PECL bug #75029
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse(''));
var_dump(yaml_parse('# Empty', -1));
$doc = <<<EOD
doc
---
---
doc
EOD;
var_dump(yaml_parse($doc, -1));
var_dump(yaml_parse($doc, 1));
?>
--EXPECT--
NULL
array(1) {
[0]=>
NULL
}
array(3) {
[0]=>
string(3) "doc"
[1]=>
NULL
[2]=>
string(3) "doc"
}
NULL
bug_69465.phpt 0000644 00000001442 15044777136 0007012 0 ustar 00 --TEST--
Test PECL bug #69465
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=UTC
--FILE--
<?php
$yaml_code = <<<YAML
date1: 2015-05-15
date2: "2015-05-15"
date3: ! 2015-05-15
bool1: true
bool2: "true"
bool3: ! true
int1: 1
int2: "1"
int3: ! 1
float1: 1.5
float2: "1.5"
float3: ! 1.5
YAML;
var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(12) {
["date1"]=>
int(1431648000)
["date2"]=>
string(10) "2015-05-15"
["date3"]=>
string(10) "2015-05-15"
["bool1"]=>
bool(true)
["bool2"]=>
string(4) "true"
["bool3"]=>
string(4) "true"
["int1"]=>
int(1)
["int2"]=>
string(1) "1"
["int3"]=>
string(1) "1"
["float1"]=>
float(1.5)
["float2"]=>
string(3) "1.5"
["float3"]=>
string(3) "1.5"
}
yaml_parse_wiki_YtsBasicTests_007.phpt 0000644 00000001067 15044777136 0014054 0 ustar 00 --TEST--
Yaml YtsBasicTests - Nested Mappings
--DESCRIPTION--
A value in a mapping can be another mapping.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('foo: whatever
bar:
fruit: apple
name: steve
sport: baseball
'));
?>
--EXPECT--
array(2) {
["foo"]=>
string(8) "whatever"
["bar"]=>
array(3) {
["fruit"]=>
string(5) "apple"
["name"]=>
string(5) "steve"
["sport"]=>
string(8) "baseball"
}
}
yaml_parse_wiki_YtsStrangeKeys_001.phpt 0000644 00000000602 15044777136 0014233 0 ustar 00 --TEST--
Yaml YtsStrangeKeys - Quoted line noise key
--DESCRIPTION--
Check that quoted line noise parses as key.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
"!@#%" : bar baz
'));
?>
--EXPECT--
array(1) {
["!@#%"]=>
string(7) "bar baz"
}
yaml_parse_spec_seq.phpt 0000644 00000002526 15044777136 0011502 0 ustar 00 --TEST--
Yaml 1.1 Spec - seq
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
# Ordered sequence of nodes
Block style: !!seq
- Mercury # Rotates - no light/dark sides.
- Venus # Deadliest. Aptly named.
- Earth # Mostly dirt.
- Mars # Seems empty.
- Jupiter # The king.
- Saturn # Pretty.
- Uranus # Where the sun hardly shines.
- Neptune # Boring. No rings.
- Pluto # You call this a planet?
Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks
Jupiter, Saturn, Uranus, Neptune, # Gas
Pluto ] # Overrated
'));
?>
--EXPECT--
array(2) {
["Block style"]=>
array(9) {
[0]=>
string(7) "Mercury"
[1]=>
string(5) "Venus"
[2]=>
string(5) "Earth"
[3]=>
string(4) "Mars"
[4]=>
string(7) "Jupiter"
[5]=>
string(6) "Saturn"
[6]=>
string(6) "Uranus"
[7]=>
string(7) "Neptune"
[8]=>
string(5) "Pluto"
}
["Flow style"]=>
array(9) {
[0]=>
string(7) "Mercury"
[1]=>
string(5) "Venus"
[2]=>
string(5) "Earth"
[3]=>
string(4) "Mars"
[4]=>
string(7) "Jupiter"
[5]=>
string(6) "Saturn"
[6]=>
string(6) "Uranus"
[7]=>
string(7) "Neptune"
[8]=>
string(5) "Pluto"
}
}
yaml_emit_004.phpt 0000644 00000000520 15044777136 0010017 0 ustar 00 --TEST--
yaml_emit - datetime
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if(!class_exists('DateTime')) die('skip DateTime n/a');
?>
--INI--
date.timezone=GMT
--FILE--
<?php
$d = new DateTime('2008-08-03T14:52:10Z');
var_dump(yaml_emit($d));
?>
--EXPECT--
string(41) "--- 2008-08-03T14:52:10.000000+00:00
...
"
yaml_parse_wiki_YtsBasicTests_004.phpt 0000644 00000001023 15044777136 0014041 0 ustar 00 --TEST--
Yaml YtsBasicTests - Deeply Nested Sequences
--DESCRIPTION--
Sequences can be nested even deeper, with each
level of indentation representing a level of
depth.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('-
-
- uno
- dos
'));
?>
--EXPECT--
array(1) {
[0]=>
array(1) {
[0]=>
array(2) {
[0]=>
string(3) "uno"
[1]=>
string(3) "dos"
}
}
}
yaml_parse_spec_float.phpt 0000644 00000001032 15044777136 0012006 0 ustar 00 --TEST--
Yaml 1.1 Spec - float
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
canonical: 6.8523015e+5
exponentioal: 685.230_15e+03
fixed: 685_230.15
sexagesimal: 190:20:30.15
negative infinity: -.inf
not a number: .NaN
'));
?>
--EXPECT--
array(6) {
["canonical"]=>
float(685230.15)
["exponentioal"]=>
float(685230.15)
["fixed"]=>
float(685230.15)
["sexagesimal"]=>
float(685230.15)
["negative infinity"]=>
float(-INF)
["not a number"]=>
float(NAN)
}
yaml_parse_wiki_YtsBasicTests_009.phpt 0000644 00000001055 15044777136 0014053 0 ustar 00 --TEST--
Yaml YtsBasicTests - Sequence-Mapping Shortcut
--DESCRIPTION--
If you are adding a mapping to a sequence, you
can place the mapping on the same line as the
dash as a shortcut.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('- work on YAML.py:
- work on Store
'));
?>
--EXPECT--
array(1) {
[0]=>
array(1) {
["work on YAML.py"]=>
array(1) {
[0]=>
string(13) "work on Store"
}
}
}
yaml_parse_wiki_YtsBlockMapping_003.phpt 0000644 00000001022 15044777136 0014341 0 ustar 00 --TEST--
Yaml YtsBlockMapping - Values aligned
--DESCRIPTION--
Often times human editors of documents will align the values even
though YAML emitters generally don't.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
red: baron
white: walls
blue: berries
'));
?>
--EXPECT--
array(3) {
["red"]=>
string(5) "baron"
["white"]=>
string(5) "walls"
["blue"]=>
string(7) "berries"
}
yaml_parse_wiki_YtsMapInSeq_002.phpt 0000644 00000000651 15044777136 0013456 0 ustar 00 --TEST--
Yaml YtsMapInSeq - Multiple keys
--DESCRIPTION--
Test a map with multiple keys.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
- foo: bar
baz: bug
'));
?>
--EXPECT--
array(1) {
[0]=>
array(2) {
["foo"]=>
string(3) "bar"
["baz"]=>
string(3) "bug"
}
}
bug_60628.phpt 0000644 00000002751 15044777137 0007007 0 ustar 00 --TEST--
Test PECL bug #260628
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$data = <<<YAML
#yaml
---
data: !mytag
- look upper
...
YAML;
function tag_callback ($value, $tag, $flags) {
echo "-- callback value --\n";
var_dump($value);
var_dump($tag);
var_dump($flags);
echo "-- end callback value --\n";
return array(
'data' => $value,
'another' => 'test',
);
}
/* baseline. do like operation in native php. */
$native = array(
"data" => array("look upper"),
);
$native["data"] = tag_callback($native["data"], "!mytag", 0);
echo "-- native value --\n";
var_dump($native);
echo "-- end native value --\n";
$cnt = null;
$array = yaml_parse($data, 0, $cnt, array(
'!mytag' => 'tag_callback',
));
echo "-- parsed value --\n";
var_dump($array);
echo "-- end parsed value --\n";
?>
--EXPECT--
-- callback value --
array(1) {
[0]=>
string(10) "look upper"
}
string(6) "!mytag"
int(0)
-- end callback value --
-- native value --
array(1) {
["data"]=>
array(2) {
["data"]=>
array(1) {
[0]=>
string(10) "look upper"
}
["another"]=>
string(4) "test"
}
}
-- end native value --
-- callback value --
array(1) {
[0]=>
string(10) "look upper"
}
string(6) "!mytag"
int(0)
-- end callback value --
-- parsed value --
array(1) {
["data"]=>
array(2) {
["data"]=>
array(1) {
[0]=>
string(10) "look upper"
}
["another"]=>
string(4) "test"
}
}
-- end parsed value --
yaml_parse_spec_omap.phpt 0000644 00000002013 15044777137 0011636 0 ustar 00 --TEST--
Yaml 1.1 Spec - omap
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
# Explicitly typed ordered map (dictionary).
Bestiary: !!omap
- aardvark: African pig-like ant eater. Ugly.
- anteater: South-American ant eater. Two species.
- anaconda: South-American constrictor snake. Scaly.
# Etc.
# Flow style
Numbers: !!omap [ one: 1, two: 2, three : 3 ]
'));
?>
--EXPECT--
array(2) {
["Bestiary"]=>
array(3) {
[0]=>
array(1) {
["aardvark"]=>
string(33) "African pig-like ant eater. Ugly."
}
[1]=>
array(1) {
["anteater"]=>
string(38) "South-American ant eater. Two species."
}
[2]=>
array(1) {
["anaconda"]=>
string(40) "South-American constrictor snake. Scaly."
}
}
["Numbers"]=>
array(3) {
[0]=>
array(1) {
["one"]=>
int(1)
}
[1]=>
array(1) {
["two"]=>
int(2)
}
[2]=>
array(1) {
["three"]=>
int(3)
}
}
}
yaml_parse_005.phpt 0000644 00000003701 15044777137 0010201 0 ustar 00 --TEST--
yaml_parse - syck bug #12656
--CREDITS--
From syck bug #12656
http://pecl.php.net/bugs/bug.php?id=12656
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
models : [ /usr/home/enovodk/data/core/easyworks/current/models/ ]
behaviors : [
/usr/home/enovodk/data/core/easyworks/current/models/behaviors/ ]
controllers : [
/usr/home/enovodk/data/core/easyworks/current/controllers/ ]
components : [
/usr/home/enovodk/data/core/easyworks/current/controllers/components/ ]
apis : [ /usr/home/enovodk/data/core/easyworks/current/controllers/api/
]
views : [ /usr/home/enovodk/data/core/easyworks/current/views/ ]
helpers : [ /usr/home/enovodk/data/core/easyworks/current/views/helpers/
]
libs : [ /usr/home/enovodk/data/core/easyworks/current/libs/ ]
plugins : [ /usr/home/enovodk/data/core/easyworks/current/plugins/ ]
'));
?>
--EXPECT--
array(9) {
["models"]=>
array(1) {
[0]=>
string(53) "/usr/home/enovodk/data/core/easyworks/current/models/"
}
["behaviors"]=>
array(1) {
[0]=>
string(63) "/usr/home/enovodk/data/core/easyworks/current/models/behaviors/"
}
["controllers"]=>
array(1) {
[0]=>
string(58) "/usr/home/enovodk/data/core/easyworks/current/controllers/"
}
["components"]=>
array(1) {
[0]=>
string(69) "/usr/home/enovodk/data/core/easyworks/current/controllers/components/"
}
["apis"]=>
array(1) {
[0]=>
string(62) "/usr/home/enovodk/data/core/easyworks/current/controllers/api/"
}
["views"]=>
array(1) {
[0]=>
string(52) "/usr/home/enovodk/data/core/easyworks/current/views/"
}
["helpers"]=>
array(1) {
[0]=>
string(60) "/usr/home/enovodk/data/core/easyworks/current/views/helpers/"
}
["libs"]=>
array(1) {
[0]=>
string(51) "/usr/home/enovodk/data/core/easyworks/current/libs/"
}
["plugins"]=>
array(1) {
[0]=>
string(54) "/usr/home/enovodk/data/core/easyworks/current/plugins/"
}
}
yaml_parse_002.phpt 0000644 00000001205 15044777137 0010173 0 ustar 00 --TEST--
yaml_parse - multiple documents
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
---
time: !!str 20:03:20
player: Sammy Sosa
action: strike (miss)
...
%YAML 1.1
---
time: "20:03:47"
player: Sammy Sosa
action: grand slam
...
', -1));
?>
--EXPECT--
array(2) {
[0]=>
array(3) {
["time"]=>
string(8) "20:03:20"
["player"]=>
string(10) "Sammy Sosa"
["action"]=>
string(13) "strike (miss)"
}
[1]=>
array(3) {
["time"]=>
string(8) "20:03:47"
["player"]=>
string(10) "Sammy Sosa"
["action"]=>
string(10) "grand slam"
}
}
yaml_parse_spec_binary.phpt 0000644 00000001775 15044777137 0012204 0 ustar 00 --TEST--
Yaml 1.1 Spec - binary
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if(!function_exists('md5')) die('skip md5 unavailable');
?>
--INI--
yaml.decode_binary=1
--FILE--
<?php
$y = yaml_parse('
canonical: !!binary "\
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
generic: !!binary |
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
description:
The binary value above is a tiny arrow encoded as a gif image.
');
var_dump($y['canonical'] === $y['generic']);
var_dump(md5($y['canonical']));
?>
--EXPECT--
bool(true)
string(32) "a8363b3d0e4e39d9e77e244e216c7840"
yaml_emit_005.phpt 0000644 00000000531 15044777137 0010023 0 ustar 00 --TEST--
yaml_emit - serializable
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--FILE--
<?php
class A {
public $one = 1;
public function show_one() {
echo $this->one;
}
}
$a = new A;
var_dump(yaml_emit(array('a' => $a)));
?>
--EXPECT--
string(56) "---
a: !php/object "O:1:\"A\":1:{s:3:\"one\";i:1;}"
...
"
bug_64019.phpt 0000644 00000001254 15044777137 0007002 0 ustar 00 --TEST--
Test PECL bug #64019
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
configAnchors:
- &wrongAnchor: # This last colon (:) makes the script die
configKey: configValue
config:
<<: *wrongAnchor
YAML;
var_dump(yaml_parse($yaml_code));
$yaml_code = <<<YAML
config:
<<:
YAML;
var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(2) {
["configAnchors"]=>
array(1) {
[0]=>
array(2) {
[""]=>
NULL
["configKey"]=>
string(11) "configValue"
}
}
["config"]=>
array(1) {
["<<"]=>
NULL
}
}
array(1) {
["config"]=>
array(1) {
["<<"]=>
NULL
}
}
yaml_parse_wiki_YtsMapInSeq_001.phpt 0000644 00000000675 15044777137 0013464 0 ustar 00 --TEST--
Yaml YtsMapInSeq - Single key
--DESCRIPTION--
Test maps with just one key.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
- foo: bar
- baz: bug
'));
?>
--EXPECT--
array(2) {
[0]=>
array(1) {
["foo"]=>
string(3) "bar"
}
[1]=>
array(1) {
["baz"]=>
string(3) "bug"
}
}
bug_72204.phpt 0000644 00000000620 15044777137 0006771 0 ustar 00 --TEST--
Test PECL bug #72204
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
foo: &ref
bar: true
baz: &ref2
<<: *ref
bar: false
YAML;
$yaml = yaml_parse($yaml_code);
var_dump($yaml);
?>
--EXPECT--
array(2) {
["foo"]=>
array(1) {
["bar"]=>
bool(true)
}
["baz"]=>
array(1) {
["bar"]=>
bool(false)
}
}
yaml_parse_spec_set.phpt 0000644 00000000572 15044777137 0011505 0 ustar 00 --TEST--
Yaml 1.1 Spec - set
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('baseball players: !!set
? Mark McGwire
? Sammy Sosa
? Ken Griffey
'));
?>
--EXPECT--
array(1) {
["baseball players"]=>
array(3) {
["Mark McGwire"]=>
NULL
["Sammy Sosa"]=>
NULL
["Ken Griffey"]=>
NULL
}
}
yaml_emit_006.phpt 0000644 00000007250 15044777137 0010031 0 ustar 00 --TEST--
yaml_emit - ini settings
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--INI--
yaml.output_canonical=0
yaml.output_indent=2
yaml.output_width=80
serialize_precision=-1
--FILE--
<?php
$addr = array(
"given" => "Chris",
"family"=> "Dumars",
"address"=> array(
"lines"=> "458 Walkman Dr.
Suite #292",
"city"=> "Royal Oak",
"state"=> "MI",
"postal"=> 48046,
),
);
$invoice = array (
"invoice"=> 34843,
"date"=> 980208000,
"bill-to"=> $addr,
"ship-to"=> $addr,
"product"=> array(
array(
"sku"=> "BL394D",
"quantity"=> 4,
"description"=> "Basketball",
"price"=> 450,
),
array(
"sku"=> "BL4438H",
"quantity"=> 1,
"description"=> "Super Hoop",
"price"=> 2392,
),
),
"tax"=> 251.42,
"total"=> 4443.52,
"comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
);
var_dump(yaml_emit($invoice));
ini_set("yaml.output_canonical", "1");
ini_set("yaml.output_indent", "4");
ini_set("yaml.output_width", "40");
echo "== CANONICAL ==\n";
var_dump(yaml_emit($invoice));
?>
--EXPECT--
string(620) "---
invoice: 34843
date: 980208000
bill-to:
given: Chris
family: Dumars
address:
lines: |-
458 Walkman Dr.
Suite #292
city: Royal Oak
state: MI
postal: 48046
ship-to:
given: Chris
family: Dumars
address:
lines: |-
458 Walkman Dr.
Suite #292
city: Royal Oak
state: MI
postal: 48046
product:
- sku: BL394D
quantity: 4
description: Basketball
price: 450
- sku: BL4438H
quantity: 1
description: Super Hoop
price: 2392
tax: 251.42
total: 4443.52
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
"
== CANONICAL ==
string(1822) "---
!!map {
? !!str "invoice"
: !!int "34843",
? !!str "date"
: !!int "980208000",
? !!str "bill-to"
: !!map {
? !!str "given"
: !!str "Chris",
? !!str "family"
: !!str "Dumars",
? !!str "address"
: !!map {
? !!str "lines"
: !!str "458 Walkman Dr.\n Suite
#292",
? !!str "city"
: !!str "Royal Oak",
? !!str "state"
: !!str "MI",
? !!str "postal"
: !!int "48046",
},
},
? !!str "ship-to"
: !!map {
? !!str "given"
: !!str "Chris",
? !!str "family"
: !!str "Dumars",
? !!str "address"
: !!map {
? !!str "lines"
: !!str "458 Walkman Dr.\n Suite
#292",
? !!str "city"
: !!str "Royal Oak",
? !!str "state"
: !!str "MI",
? !!str "postal"
: !!int "48046",
},
},
? !!str "product"
: !!seq [
!!map {
? !!str "sku"
: !!str "BL394D",
? !!str "quantity"
: !!int "4",
? !!str "description"
: !!str "Basketball",
? !!str "price"
: !!int "450",
},
!!map {
? !!str "sku"
: !!str "BL4438H",
? !!str "quantity"
: !!int "1",
? !!str "description"
: !!str "Super Hoop",
? !!str "price"
: !!int "2392",
},
],
? !!str "tax"
: !!float "251.42",
? !!str "total"
: !!float "4443.52",
? !!str "comments"
: !!str "Late afternoon is best. Backup
contact is Nancy Billsmer @ 338-4338.",
}
...
"
yaml_parse_spec_pairs.phpt 0000644 00000001636 15044777140 0012024 0 ustar 00 --TEST--
Yaml 1.1 Spec - pairs
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
# Explicitly typed pairs.
Block tasks: !!pairs
- meeting: with team.
- meeting: with boss.
- break: lunch.
- meeting: with client.
Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
'));
?>
--EXPECT--
array(2) {
["Block tasks"]=>
array(4) {
[0]=>
array(1) {
["meeting"]=>
string(10) "with team."
}
[1]=>
array(1) {
["meeting"]=>
string(10) "with boss."
}
[2]=>
array(1) {
["break"]=>
string(6) "lunch."
}
[3]=>
array(1) {
["meeting"]=>
string(12) "with client."
}
}
["Flow tasks"]=>
array(2) {
[0]=>
array(1) {
["meeting"]=>
string(9) "with team"
}
[1]=>
array(1) {
["meeting"]=>
string(9) "with boss"
}
}
}
yaml_001.phpt 0000644 00000002121 15044777140 0006770 0 ustar 00 --TEST--
yaml - emit -> parse roundtrip
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$addr = array(
"given" => "Chris",
"family"=> "Dumars",
"address"=> array(
"lines"=> "458 Walkman Dr.
Suite #292",
"city"=> "Royal Oak",
"state"=> "MI",
"postal"=> 48046,
),
);
$invoice = array (
"invoice"=> 34843,
"date"=> 980208000,
"bill-to"=> $addr,
"ship-to"=> $addr,
"product"=> array(
array(
"sku"=> "BL394D",
"quantity"=> 4,
"description"=> "Basketball",
"price"=> 450,
),
array(
"sku"=> "BL4438H",
"quantity"=> 1,
"description"=> "Super Hoop",
"price"=> 2392,
),
),
"tax"=> 251.42,
"total"=> 4443.52,
"comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
"tags" => array("a","b","c"),
);
$yaml = yaml_emit($invoice);
$parsed = yaml_parse($yaml);
var_dump($parsed == $invoice);
?>
--EXPECT--
bool(true)
yaml_parse_spec_map.phpt 0000644 00000001225 15044777140 0011455 0 ustar 00 --TEST--
Yaml 1.1 Spec - map
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
# Unordered set of key: value pairs.
Block style: !!map
Clark : Evans
Brian : Ingerson
Oren : Ben-Kiki
Flow style: !!map { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
'));
?>
--EXPECT--
array(2) {
["Block style"]=>
array(3) {
["Clark"]=>
string(5) "Evans"
["Brian"]=>
string(8) "Ingerson"
["Oren"]=>
string(8) "Ben-Kiki"
}
["Flow style"]=>
array(3) {
["Clark"]=>
string(5) "Evans"
["Brian"]=>
string(8) "Ingerson"
["Oren"]=>
string(8) "Ben-Kiki"
}
}
bug_79494.phpt 0000644 00000001141 15044777140 0007004 0 ustar 00 --TEST--
Test PECL bug #74949
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$data = array (
'audio' =>
array (
'audioEnabled' =>
array (
0 => 132317787432502136,
1 => 0,
),
'eveampGain' =>
array (
0 => 132316833510704299,
1 => 0.25,
),
),
);
print yaml_emit($data);
?>
--EXPECTF--
---
audio:
audioEnabled:
- %r(132317787432502136|1\.3231778743250214E\+17)%r
- 0
eveampGain:
- %r(132316833510704299|1\.323168335107043E\+17)%r
- 0.25
...
bug_79567.phpt 0000644 00000000513 15044777140 0007007 0 ustar 00 --TEST--
Test PECL bug #79567
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$data = [
'audioEnabled' => [
0 => 132317787432502136,
1 => 0,
],
];
$yaml = yaml_emit($data);
$result = yaml_parse($yaml);
print $result == $data ? "Yes!\n" : "No...\n";
?>
--EXPECT--
Yes!
bug_59860.phpt 0000644 00000003164 15044777140 0007006 0 ustar 00 --TEST--
Test PECL bug #59860
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
/**
* Parsing callback for yaml tag.
* @param mixed $value Data from yaml file
* @param string $tag Tag that triggered callback
* @param int $flags Scalar entity style (see YAML_*_SCALAR_STYLE)
* @return mixed Value that YAML parser should emit for the given value
*/
function tag_callback ($value, $tag, $flags) {
var_dump(func_get_args());
return $tag;
}
$yaml = <<<YAML
implicit_map:
a: b
explicit_map: !!map
c: d
implicit_seq: [e, f]
explicit_seq: !!seq [g, h]
YAML;
yaml_parse($yaml, 0, $ndocs, array(
YAML_MAP_TAG => 'tag_callback',
YAML_SEQ_TAG => 'tag_callback',
));
?>
--EXPECT--
array(3) {
[0]=>
array(1) {
["a"]=>
string(1) "b"
}
[1]=>
string(21) "tag:yaml.org,2002:map"
[2]=>
int(0)
}
array(3) {
[0]=>
array(1) {
["c"]=>
string(1) "d"
}
[1]=>
string(21) "tag:yaml.org,2002:map"
[2]=>
int(0)
}
array(3) {
[0]=>
array(2) {
[0]=>
string(1) "e"
[1]=>
string(1) "f"
}
[1]=>
string(21) "tag:yaml.org,2002:seq"
[2]=>
int(0)
}
array(3) {
[0]=>
array(2) {
[0]=>
string(1) "g"
[1]=>
string(1) "h"
}
[1]=>
string(21) "tag:yaml.org,2002:seq"
[2]=>
int(0)
}
array(3) {
[0]=>
array(4) {
["implicit_map"]=>
string(21) "tag:yaml.org,2002:map"
["explicit_map"]=>
string(21) "tag:yaml.org,2002:map"
["implicit_seq"]=>
string(21) "tag:yaml.org,2002:seq"
["explicit_seq"]=>
string(21) "tag:yaml.org,2002:seq"
}
[1]=>
string(21) "tag:yaml.org,2002:map"
[2]=>
int(0)
}
bug_61770.phpt 0000644 00000000403 15044777140 0006770 0 ustar 00 --TEST--
Test PECL bug #61770
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_emit("\xc2"));
?>
--EXPECTF--
Warning: yaml_emit(): Invalid UTF-8 sequence in argument in %sbug_61770.php on line 2
bool(false)
yaml_parse_url_001.phpt 0000644 00000003067 15044777140 0011056 0 ustar 00 --TEST--
yaml_parse_url - general
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
var_dump(yaml_parse_url('file://' . __DIR__ . '/yaml_parse_file_001.yaml'));
?>
--EXPECT--
array(8) {
["invoice"]=>
int(34843)
["date"]=>
int(980208000)
["bill-to"]=>
&array(3) {
["given"]=>
string(5) "Chris"
["family"]=>
string(6) "Dumars"
["address"]=>
array(4) {
["lines"]=>
string(27) "458 Walkman Dr.
Suite #292
"
["city"]=>
string(9) "Royal Oak"
["state"]=>
string(2) "MI"
["postal"]=>
int(48046)
}
}
["ship-to"]=>
&array(3) {
["given"]=>
string(5) "Chris"
["family"]=>
string(6) "Dumars"
["address"]=>
array(4) {
["lines"]=>
string(27) "458 Walkman Dr.
Suite #292
"
["city"]=>
string(9) "Royal Oak"
["state"]=>
string(2) "MI"
["postal"]=>
int(48046)
}
}
["product"]=>
array(2) {
[0]=>
array(4) {
["sku"]=>
string(6) "BL394D"
["quantity"]=>
int(4)
["description"]=>
string(10) "Basketball"
["price"]=>
float(450)
}
[1]=>
array(4) {
["sku"]=>
string(7) "BL4438H"
["quantity"]=>
int(1)
["description"]=>
string(10) "Super Hoop"
["price"]=>
float(2392)
}
}
["tax"]=>
float(251.42)
["total"]=>
float(4443.52)
["comments"]=>
string(68) "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
}
bug_80324.phpt 0000644 00000000673 15044777140 0006775 0 ustar 00 --TEST--
Bug #80324 (Segfault in YAML with anonymous functions)
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml = <<<YAML
- !env ENV
- !path PATH
YAML;
$result = yaml_parse($yaml, 0, $ndocs, array(
'!env' => function ($str) {return $str;},
'!path' => function ($str) {return $str;},
));
var_dump($result);
?>
--EXPECT--
array(2) {
[0]=>
string(3) "ENV"
[1]=>
string(4) "PATH"
}
bug_61923.phpt 0000644 00000002234 15044777140 0006774 0 ustar 00 --TEST--
Test PECL bug #61923
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$yaml_code = <<<YAML
---
strings:
- '1:0'
- '0:1'
- '1:0:0'
- '+1:0:0'
- '-1:0:0'
- ':01'
- ':1'
- '18:53:17.00037'
numbers:
- 1:0
- 0:1
- 1:0:0
- +1:0:0
- -1:0:0
- :01
- :1
- 18:53:17.00037
YAML;
$parsed = yaml_parse($yaml_code);
var_dump($parsed);
var_dump(yaml_emit($parsed));
?>
--EXPECT--
array(2) {
["strings"]=>
array(8) {
[0]=>
string(3) "1:0"
[1]=>
string(3) "0:1"
[2]=>
string(5) "1:0:0"
[3]=>
string(6) "+1:0:0"
[4]=>
string(6) "-1:0:0"
[5]=>
string(3) ":01"
[6]=>
string(2) ":1"
[7]=>
string(14) "18:53:17.00037"
}
["numbers"]=>
array(8) {
[0]=>
int(60)
[1]=>
int(1)
[2]=>
int(3600)
[3]=>
int(3600)
[4]=>
int(-3600)
[5]=>
int(1)
[6]=>
int(1)
[7]=>
float(67997.00037)
}
}
string(161) "---
strings:
- "1:0"
- "0:1"
- "1:0:0"
- "+1:0:0"
- "-1:0:0"
- ":01"
- ":1"
- "18:53:17.00037"
numbers:
- 60
- 1
- 3600
- 3600
- -3600
- 1
- 1
- 67997.00037
...
"
bug_64694.phpt 0000644 00000000643 15044777140 0007006 0 ustar 00 --TEST--
Test PECL bug #64694
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
"[a]": 1
YAML;
var_dump(yaml_parse($yaml_code));
$yaml_code = <<<YAML
[a]: 1
YAML;
var_dump(yaml_parse($yaml_code));
?>
--EXPECTF--
array(1) {
["[a]"]=>
int(1)
}
Warning: yaml_parse(): Illegal offset type array (line 1, column 7) in %sbug_64694.php on line 12
array(0) {
}
bug_69617.phpt 0000644 00000000472 15044777140 0007006 0 ustar 00 --TEST--
Test PECL bug #69617
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
---
a: !php/object "O:1:\"A\":1:{s:3:\"one\";i:1;}"
...
YAML;
var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(1) {
["a"]=>
string(26) "O:1:"A":1:{s:3:"one";i:1;}"
}
yaml_parse_spec_timestamp.phpt 0000644 00000001331 15044777140 0012701 0 ustar 00 --TEST--
Yaml 1.1 Spec - timestamp
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
var_dump(yaml_parse('
canonical: 2001-12-15T02:59:43.1Z
valid iso8601: 2001-12-14t21:59:43.10-05:00
alternate iso8601: 2001-12-14T21:59:43.10-0500
space separated: 2001-12-14 21:59:43.10 -5
no time zone (Z): 2001-12-15 2:59:43.10
date (00:00:00Z): 2002-12-14
'));
?>
--EXPECT--
array(6) {
["canonical"]=>
int(1008385183)
["valid iso8601"]=>
int(1008385183)
["alternate iso8601"]=>
int(1008385183)
["space separated"]=>
int(1008385183)
["no time zone (Z)"]=>
int(1008385183)
["date (00:00:00Z)"]=>
int(1039824000)
}
bug_21995.phpt 0000644 00000000611 15044777140 0006776 0 ustar 00 --TEST--
Test PECL bug #21995
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
function yaml_cbk ($a) {
var_dump($a);
return $a;
}
$yaml_code = <<<YAML
boo: doo
a: [1,2,3,4]
d: []
YAML;
$yaml = yaml_parse($yaml_code, 0, $ndocs, array(
YAML_STR_TAG => "yaml_cbk",
));
?>
--EXPECT--
string(3) "boo"
string(3) "doo"
string(1) "a"
string(1) "d"
yaml_parse_file_001.phpt 0000644 00000003052 15044777140 0011165 0 ustar 00 --TEST--
yaml_parse_file - general
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
var_dump(yaml_parse_file(__DIR__ . '/yaml_parse_file_001.yaml'));
--EXPECT--
array(8) {
["invoice"]=>
int(34843)
["date"]=>
int(980208000)
["bill-to"]=>
&array(3) {
["given"]=>
string(5) "Chris"
["family"]=>
string(6) "Dumars"
["address"]=>
array(4) {
["lines"]=>
string(27) "458 Walkman Dr.
Suite #292
"
["city"]=>
string(9) "Royal Oak"
["state"]=>
string(2) "MI"
["postal"]=>
int(48046)
}
}
["ship-to"]=>
&array(3) {
["given"]=>
string(5) "Chris"
["family"]=>
string(6) "Dumars"
["address"]=>
array(4) {
["lines"]=>
string(27) "458 Walkman Dr.
Suite #292
"
["city"]=>
string(9) "Royal Oak"
["state"]=>
string(2) "MI"
["postal"]=>
int(48046)
}
}
["product"]=>
array(2) {
[0]=>
array(4) {
["sku"]=>
string(6) "BL394D"
["quantity"]=>
int(4)
["description"]=>
string(10) "Basketball"
["price"]=>
float(450)
}
[1]=>
array(4) {
["sku"]=>
string(7) "BL4438H"
["quantity"]=>
int(1)
["description"]=>
string(10) "Super Hoop"
["price"]=>
float(2392)
}
}
["tax"]=>
float(251.42)
["total"]=>
float(4443.52)
["comments"]=>
string(68) "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
}
yaml_parse_001.phpt 0000644 00000006706 15044777140 0010177 0 ustar 00 --TEST--
yaml_parse - general
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
--FILE--
<?php
var_dump(yaml_parse('
--- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date : 2001-01-23
bill-to: &id001
given : Chris
family : Dumars
address:
lines: |
458 Walkman Dr.
Suite #292
city : Royal Oak
state : MI
postal : 48046
ship-to: *id001
product:
- sku : BL394D
quantity : 4
description : Basketball
price : 450.00
- sku : BL4438H
quantity : 1
description : Super Hoop
price : 2392.00
tax : 251.42
total: 4443.52
comments:
Late afternoon is best.
Backup contact is Nancy
Billsmer @ 338-4338.
'));
var_dump(yaml_parse('
---
Time: 2001-11-23 15:01:42 -5
User: ed
Warning:
This is an error message
for the log file
---
Time: 2001-11-23 15:02:31 -5
User: ed
Warning:
A slightly different error
message.
---
Date: 2001-11-23 15:03:17 -5
User: ed
Fatal:
Unknown variable "bar"
Stack:
- file: TopClass.py
line: 23
code: |
x = MoreObject("345\n")
- file: MoreClass.py
line: 58
code: |-
foo = bar
', -1));
?>
--EXPECT--
array(8) {
["invoice"]=>
int(34843)
["date"]=>
int(980208000)
["bill-to"]=>
&array(3) {
["given"]=>
string(5) "Chris"
["family"]=>
string(6) "Dumars"
["address"]=>
array(4) {
["lines"]=>
string(27) "458 Walkman Dr.
Suite #292
"
["city"]=>
string(9) "Royal Oak"
["state"]=>
string(2) "MI"
["postal"]=>
int(48046)
}
}
["ship-to"]=>
&array(3) {
["given"]=>
string(5) "Chris"
["family"]=>
string(6) "Dumars"
["address"]=>
array(4) {
["lines"]=>
string(27) "458 Walkman Dr.
Suite #292
"
["city"]=>
string(9) "Royal Oak"
["state"]=>
string(2) "MI"
["postal"]=>
int(48046)
}
}
["product"]=>
array(2) {
[0]=>
array(4) {
["sku"]=>
string(6) "BL394D"
["quantity"]=>
int(4)
["description"]=>
string(10) "Basketball"
["price"]=>
float(450)
}
[1]=>
array(4) {
["sku"]=>
string(7) "BL4438H"
["quantity"]=>
int(1)
["description"]=>
string(10) "Super Hoop"
["price"]=>
float(2392)
}
}
["tax"]=>
float(251.42)
["total"]=>
float(4443.52)
["comments"]=>
string(68) "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
}
array(3) {
[0]=>
array(3) {
["Time"]=>
int(1006545702)
["User"]=>
string(2) "ed"
["Warning"]=>
string(41) "This is an error message for the log file"
}
[1]=>
array(3) {
["Time"]=>
int(1006545751)
["User"]=>
string(2) "ed"
["Warning"]=>
string(35) "A slightly different error message."
}
[2]=>
array(4) {
["Date"]=>
int(1006545797)
["User"]=>
string(2) "ed"
["Fatal"]=>
string(22) "Unknown variable "bar""
["Stack"]=>
array(2) {
[0]=>
array(3) {
["file"]=>
string(11) "TopClass.py"
["line"]=>
int(23)
["code"]=>
string(24) "x = MoreObject("345\n")
"
}
[1]=>
array(3) {
["file"]=>
string(12) "MoreClass.py"
["line"]=>
int(58)
["code"]=>
string(9) "foo = bar"
}
}
}
}
bug_74799.yaml 0000644 00000000025 15044777140 0006776 0 ustar 00 ---
key:
!value
... yaml_parse_file_002.phpt 0000644 00000002456 15044777140 0011175 0 ustar 00 --TEST--
yaml_parse_file - error cases
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_timestamp=1
date.timezone=GMT
; E_ALL - E_DEPRECATED to hide Deprecated: yaml_parse_file(): Passing null to parameter #1...
error_reporting=24575
--FILE--
<?php
try {
// PHP7 emits a Warning here
yaml_parse_file(NULL);
} catch (ValueError $e) {
// PHP8 raises this exception
echo "\nWarning: yaml_parse_file(): {$e->getMessage()} in " . __FILE__ . " on line 4\n";
}
try {
// PHP7 emits a Warning here
yaml_parse_file('');
} catch (ValueError $e) {
// PHP8 raises this exception
echo "\nWarning: yaml_parse_file(): {$e->getMessage()} in " . __FILE__ . " on line 11\n";
}
yaml_parse_file('invalid');
try {
// PHP7 emits a Warning here
yaml_parse_file();
} catch (ArgumentCountError $e) {
// PHP8 raises this exception
echo "\nWarning: {$e->getMessage()} in " . __FILE__ . " on line 19\n";
}
--EXPECTF--
Warning: yaml_parse_file(): %r(Filename|Path)%r cannot be empty in %s on line %d
Warning: yaml_parse_file(): %r(Filename|Path)%r cannot be empty in %s on line %d
Warning: yaml_parse_file(invalid): %r[Ff]%railed to open stream: No such file or directory in %s on line %d
Warning: yaml_parse_file() expects at least 1 %r(argument|parameter)%r, 0 given in %s on line %d
yaml_parse_wiki_YtsBasicTests_001.phpt 0000644 00000001017 15044777140 0014034 0 ustar 00 --TEST--
Yaml YtsBasicTests - Simple Sequence
--DESCRIPTION--
You can specify a list in YAML by placing each
member of the list on a new line with an opening
dash. These lists are called sequences.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('- apple
- banana
- carrot
'));
?>
--EXPECT--
array(3) {
[0]=>
string(5) "apple"
[1]=>
string(6) "banana"
[2]=>
string(6) "carrot"
}
yaml_parse_007.phpt 0000644 00000000630 15044777140 0010173 0 ustar 00 --TEST--
yaml_parse - serializable
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--INI--
yaml.decode_php=1
--FILE--
<?php
class A {
public $one = 1;
public function show_one() {
echo $this->one;
}
}
var_dump(yaml_parse('
---
a: !php/object "O:1:\"A\":1:{s:3:\"one\";i:1;}"
...
'));
?>
--EXPECTF--
array(1) {
["a"]=>
object(A)#%d (1) {
["one"]=>
int(1)
}
}
yaml_emit_file_basic.phpt 0000644 00000003574 15044777140 0011603 0 ustar 00 --TEST--
Test Github pull request #1
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$addr = array(
"given" => "Chris",
"family"=> "Dumars",
"address"=> array(
"lines"=> "458 Walkman Dr.
Suite #292",
"city"=> "Royal Oak",
"state"=> "MI",
"postal"=> 48046,
),
);
$invoice = array (
"invoice"=> 34843,
"date"=> 980208000,
"bill-to"=> $addr,
"ship-to"=> $addr,
"product"=> array(
array(
"sku"=> "BL394D",
"quantity"=> 4,
"description"=> "Basketball",
"price"=> 450,
),
array(
"sku"=> "BL4438H",
"quantity"=> 1,
"description"=> "Super Hoop",
"price"=> 2392,
),
),
"tax"=> 251.42,
"total"=> 4443.52,
"comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
);
$temp_filename = dirname(__FILE__) . 'yaml_emit_file_basic.tmp';
var_dump(yaml_emit_file($temp_filename, $invoice));
var_dump(file_get_contents($temp_filename));
?>
--CLEAN--
<?php
$temp_filename = dirname(__FILE__) . 'yaml_emit_file_basic.tmp';
unlink($temp_filename);
?>
--EXPECT--
bool(true)
string(620) "---
invoice: 34843
date: 980208000
bill-to:
given: Chris
family: Dumars
address:
lines: |-
458 Walkman Dr.
Suite #292
city: Royal Oak
state: MI
postal: 48046
ship-to:
given: Chris
family: Dumars
address:
lines: |-
458 Walkman Dr.
Suite #292
city: Royal Oak
state: MI
postal: 48046
product:
- sku: BL394D
quantity: 4
description: Basketball
price: 450
- sku: BL4438H
quantity: 1
description: Super Hoop
price: 2392
tax: 251.42
total: 4443.52
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
"
yaml_parse_wiki_YtsBlockMapping_001.phpt 0000644 00000000552 15044777140 0014341 0 ustar 00 --TEST--
Yaml YtsBlockMapping - One Element Mapping
--DESCRIPTION--
A mapping with one key/value pair
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
foo: bar
'));
?>
--EXPECT--
array(1) {
["foo"]=>
string(3) "bar"
}
yaml_emit_009.phpt 0000644 00000002300 15044777140 0010015 0 ustar 00 --TEST--
yaml_emit - custom tags with closures
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if (version_compare(PHP_VERSION, '5.3.0', '<')) die('skip Closure unsupported');
?>
--FILE--
<?php
$emit_callbacks = array(
'Emit009Example' => function ($o) {
return array(
'tag' => '!emit009',
'data' => $o->data,
);
},
);
class Emit009Example {
public $data; // data may be in any pecl/yaml suitable type
}
$t = new Emit009Example();
$t->data = array ('a','b','c');
$yaml = yaml_emit(
array(
'callback' => $t,
),
YAML_ANY_ENCODING,
YAML_ANY_BREAK,
$emit_callbacks
);
var_dump($yaml);
/* make sure you can undo the custome serialization */
function parse_009 ($value, $tag, $flags) {
$ret = new Emit009Example();
$ret->data = $value;
return $ret;
}
$parse_callbacks = array(
'!emit009' => 'parse_009',
);
$array = yaml_parse($yaml, 0, $cnt, $parse_callbacks);
var_dump($array['callback'] == $t);
/* roundtrip with raw object */
var_dump($t == yaml_parse(
yaml_emit($t, YAML_ANY_ENCODING, YAML_ANY_BREAK, $emit_callbacks),
0, $cnt, $parse_callbacks));
?>
--EXPECT--
string(39) "---
callback: !emit009
- a
- b
- c
...
"
bool(true)
bool(true)
bug_79866.phpt 0000644 00000001653 15044777140 0007017 0 ustar 00 --TEST--
Test PECL bug #79866
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
precision=14
serialize_precision=-1
--FILE--
<?php
$floats = [
"0" => 0,
"1" => 1,
"-1" => -1,
"2." => 2.,
"2.0" => 2.0,
"2.00" => 2.00,
"2.000" => 2.000,
"0.123456789" => 0.123456789,
"-0.123456789" => -0.123456789,
"2.3e6" => 2.3e6,
"-2.3e6" => -2.3e6,
"2.3e-6" => 2.3e-6,
"-2.3e-6" => -2.3e-6,
"INF" => INF,
"NAN" => NAN,
"0.000021" => 0.000021,
];
foreach( $floats as $idx => $float ) {
$float = floatval($float);
ob_start();
echo $float;
$native = ob_get_clean();
$expect = "--- {$native}\n...\n";
$got = yaml_emit($float);
if ( $got !== $expect ) {
echo "== FAIL! {$idx} ==\n";
echo "expected:\n{$expect}\n";
echo "got:{$got}\n";
}
}
?>
--EXPECT--
yaml_parse_wiki_YtsBasicTests_002.phpt 0000644 00000001031 15044777141 0014032 0 ustar 00 --TEST--
Yaml YtsBasicTests - Nested Sequences
--DESCRIPTION--
You can include a sequence within another
sequence by giving the sequence an empty
dash, followed by an indented list.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('-
- foo
- bar
- baz
'));
?>
--EXPECT--
array(1) {
[0]=>
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
[2]=>
string(3) "baz"
}
}
yaml_parse_wiki_YtsBasicTests_008.phpt 0000644 00000001602 15044777141 0014044 0 ustar 00 --TEST--
Yaml YtsBasicTests - Mixed Mapping
--DESCRIPTION--
A mapping can contain any assortment
of mappings and sequences as values.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('foo: whatever
bar:
-
fruit: apple
name: steve
sport: baseball
- more
-
python: rocks
perl: papers
ruby: scissorses
'));
?>
--EXPECT--
array(2) {
["foo"]=>
string(8) "whatever"
["bar"]=>
array(3) {
[0]=>
array(3) {
["fruit"]=>
string(5) "apple"
["name"]=>
string(5) "steve"
["sport"]=>
string(8) "baseball"
}
[1]=>
string(4) "more"
[2]=>
array(3) {
["python"]=>
string(5) "rocks"
["perl"]=>
string(6) "papers"
["ruby"]=>
string(10) "scissorses"
}
}
}
yaml_parse_wiki_YtsMapInSeq_003.phpt 0000644 00000000666 15044777141 0013461 0 ustar 00 --TEST--
Yaml YtsMapInSeq - Strange keys
--DESCRIPTION--
Test a map with "line noise" keys.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
- "!@#$" : foo
-+!@ : bar
'));
?>
--EXPECT--
array(1) {
[0]=>
array(2) {
["!@#$"]=>
string(3) "foo"
["-+!@"]=>
string(3) "bar"
}
}
yaml_emit_007.phpt 0000644 00000000625 15044777141 0010024 0 ustar 00 --TEST--
yaml_emit - recursive structures
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--FILE--
<?php
$recursive = array(
"a" => "a",
"b" => "b",
"c" => &$recursive,
);
var_dump(yaml_emit($recursive));
// clean up a little or we may see false memory leak reports
unset($recursive['c']);
?>
--EXPECT--
string(56) "---
a: a
b: b
c: &refid1
a: a
b: b
c: *refid1
...
"
yaml_parse_006.phpt 0000644 00000003172 15044777141 0010177 0 ustar 00 --TEST--
yaml_parse - syck bug #14384
--CREDITS--
From syck bug #14384
http://pecl.php.net/bugs/bug.php?id=14384
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
"leading tab"
...
'));
var_dump(yaml_parse('---
"space and tab"
...
'));
var_dump(yaml_parse('---
"key": "tab before value"
...
'));
var_dump(yaml_parse('---
"key": "space and tab before value"
...
'));
var_dump(yaml_parse('---
- "tab before value"
...
'));
var_dump(yaml_parse('---
- "space and tab before value"
...
'));
?>
--EXPECTF--
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 1), context while scanning for the next token (line 2, column 1) in %syaml_parse_006.php on line %d
bool(false)
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 3), context while scanning for the next token (line 2, column 3) in %syaml_parse_006.php on line %d
bool(false)
array(1) {
["key"]=>
string(16) "tab before value"
}
array(1) {
["key"]=>
string(26) "space and tab before value"
}
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 2), context while scanning for the next token (line 2, column 2) in %syaml_parse_006.php on line %d
bool(false)
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 4), context while scanning for the next token (line 2, column 4) in %syaml_parse_006.php on line %d
bool(false)
bug_72540.phpt 0000644 00000000402 15044777141 0006765 0 ustar 00 --TEST--
Test PECL bug #72540
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$tmpfname = tempnam(sys_get_temp_dir(), 'bug_72540.yaml');
var_dump(yaml_parse_url($tmpfname));
unlink($tmpfname);
?>
--EXPECT--
bool(false)
yaml_parse_003.phpt 0000644 00000001323 15044777141 0010170 0 ustar 00 --TEST--
yaml_parse - parse errors
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
commercial-at: @text
'));
var_dump(yaml_parse('---
grave-accent: `text
'));
?>
--EXPECTF--
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 16), context while scanning for the next token (line 2, column 16) in %syaml_parse_003.php on line %d
bool(false)
Warning: yaml_parse(): scanning error encountered during parsing: found character that cannot start any token (line 2, column 15), context while scanning for the next token (line 2, column 15) in %syaml_parse_003.php on line %d
bool(false)
yaml_parse_spec_null.phpt 0000644 00000001423 15044777141 0011653 0 ustar 00 --TEST--
Yaml 1.1 Spec - null
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
# A document may be null.
---
---
# This mapping has four keys,
# one has a value.
empty:
canonical: ~
english: null
~: null key
---
# This sequence has five
# entries, two have values.
sparse:
- ~
- 2nd entry
-
- 4th entry
- Null
', -1));
?>
--EXPECT--
array(3) {
[0]=>
NULL
[1]=>
array(4) {
["empty"]=>
NULL
["canonical"]=>
NULL
["english"]=>
NULL
[""]=>
string(8) "null key"
}
[2]=>
array(1) {
["sparse"]=>
array(5) {
[0]=>
NULL
[1]=>
string(9) "2nd entry"
[2]=>
NULL
[3]=>
string(9) "4th entry"
[4]=>
NULL
}
}
}
bug_parsing_alias.phpt 0000644 00000001254 15044777141 0011126 0 ustar 00 --TEST--
Test PECL strange alias bug
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$yaml_code = <<<YAML
basic:
- &external {value: 22 }
keylevel0:
keylevel1:
value: 1
keylevel1.1:
keylevel2: &strange
value: 2
<<: *external
YAML;
var_dump(yaml_parse($yaml_code));
?>
--EXPECT--
array(2) {
["basic"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
int(22)
}
}
["keylevel0"]=>
array(2) {
["keylevel1"]=>
array(1) {
["value"]=>
int(1)
}
["keylevel1.1"]=>
array(1) {
["keylevel2"]=>
array(1) {
["value"]=>
int(2)
}
}
}
}
yaml_parse_spec_str.phpt 0000644 00000000333 15044777142 0011511 0 ustar 00 --TEST--
Yaml 1.1 Spec - str
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
string: abcd
'));
?>
--EXPECT--
array(1) {
["string"]=>
string(4) "abcd"
}
yaml_parse_spec_merge.phpt 0000644 00000002522 15044777142 0012002 0 ustar 00 --TEST--
Yaml 1.1 Spec - merge
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
---
- &CENTER { x: 1, "y": 2 }
- &LEFT { x: 0, "y": 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }
# All the following maps are equal:
- # Explicit keys
x: 1
"y": 2
r: 10
label: center/big
- # Merge one map
<< : *CENTER
r: 10
label: center/big
- # Merge multiple maps
<< : [ *CENTER, *BIG ]
label: center/big
- # Override
<< : [ *BIG, *LEFT, *SMALL ]
x: 1
label: center/big
'));
?>
--EXPECT--
array(8) {
[0]=>
array(2) {
["x"]=>
int(1)
["y"]=>
int(2)
}
[1]=>
array(2) {
["x"]=>
int(0)
["y"]=>
int(2)
}
[2]=>
array(1) {
["r"]=>
int(10)
}
[3]=>
array(1) {
["r"]=>
int(1)
}
[4]=>
array(4) {
["x"]=>
int(1)
["y"]=>
int(2)
["r"]=>
int(10)
["label"]=>
string(10) "center/big"
}
[5]=>
array(4) {
["x"]=>
int(1)
["y"]=>
int(2)
["r"]=>
int(10)
["label"]=>
string(10) "center/big"
}
[6]=>
array(4) {
["x"]=>
int(1)
["y"]=>
int(2)
["r"]=>
int(10)
["label"]=>
string(10) "center/big"
}
[7]=>
array(4) {
["r"]=>
int(10)
["x"]=>
int(1)
["y"]=>
int(2)
["label"]=>
string(10) "center/big"
}
}
yaml_parse_file_001.yaml 0000644 00000001204 15044777142 0011153 0 ustar 00 --- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date : 2001-01-23
bill-to: &id001
given : Chris
family : Dumars
address:
lines: |
458 Walkman Dr.
Suite #292
city : Royal Oak
state : MI
postal : 48046
ship-to: *id001
product:
- sku : BL394D
quantity : 4
description : Basketball
price : 450.00
- sku : BL4438H
quantity : 1
description : Super Hoop
price : 2392.00
tax : 251.42
total: 4443.52
comments:
Late afternoon is best.
Backup contact is Nancy
Billsmer @ 338-4338.
bug_77720.phpt 0000644 00000030513 15044777142 0007001 0 ustar 00 --TEST--
Test PECL bug #77720
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
$key_laughs = <<<YAML
- &a ["lol","lol","lol","lol","lol","lol","lol","lol","lol"]
- ? &b [{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:1},{*a:}] : "foo"
- ? &c [{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:1},{*b:}] : "foo"
- ? &d [{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:1},{*c:}] : "foo"
- ? &e [{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:1},{*d:}] : "foo"
- ? &f [{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:1},{*e:}] : "foo"
- ? &g [{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:1},{*f:}] : "foo"
- ? &h [{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:1},{*g:}] : "foo"
- ? &i [{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:1},{*h:}] : "foo"
- ? &j [{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:1},{*i:}] : "foo"
- ? &k [{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:1},{*j:}] : "foo"
YAML;
var_dump(yaml_parse($key_laughs));
?>
--EXPECTF--
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 2, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 3, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 4, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 5, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 6, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 7, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 8, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 9, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 10, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 2) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 73) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 11, column 79) in %sbug_77720.php on line 15
Warning: yaml_parse(): Illegal offset type array (line 12, column 1) in %sbug_77720.php on line 15
array(11) {
[0]=>
array(9) {
[0]=>
string(3) "lol"
[1]=>
string(3) "lol"
[2]=>
string(3) "lol"
[3]=>
string(3) "lol"
[4]=>
string(3) "lol"
[5]=>
string(3) "lol"
[6]=>
string(3) "lol"
[7]=>
string(3) "lol"
[8]=>
string(3) "lol"
}
[1]=>
array(0) {
}
[2]=>
array(0) {
}
[3]=>
array(0) {
}
[4]=>
array(0) {
}
[5]=>
array(0) {
}
[6]=>
array(0) {
}
[7]=>
array(0) {
}
[8]=>
array(0) {
}
[9]=>
array(0) {
}
[10]=>
array(0) {
}
}
bug_76309.phpt 0000644 00000000516 15044777142 0007003 0 ustar 00 --TEST--
Test PECL bug #76309
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
echo yaml_emit([
'a' => '1.0',
'b' => '2.',
'c' => '3',
'd' => '.',
'e' => 1.0,
'f' => 2.,
'g' => 3,
] );
?>
--EXPECT--
---
a: "1.0"
b: "2."
c: "3"
d: .
e: 1
f: 2
g: 3
...
bug_69616.phpt 0000644 00000000642 15044777142 0007006 0 ustar 00 --TEST--
Test PECL bug #69616
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
yaml.decode_php=1
--FILE--
<?php
$yaml_code = <<<YAML
a: !php/object O:0:1
b: !php/object
YAML;
$yaml = yaml_parse($yaml_code);
?>
--EXPECTF--
Notice: yaml_parse(): Failed to unserialize class in %sbug_69616.php on line 10
Notice: yaml_parse(): Failed to unserialize class in %sbug_69616.php on line 10
yaml_parse_008.phpt 0000644 00000004453 15044777142 0010205 0 ustar 00 --TEST--
yaml_parse - callbacks
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--FILE--
<?php
/**
* Parsing callback for yaml tag.
* @param mixed $value Data from yaml file
* @param string $tag Tag that triggered callback
* @param int $flags Scalar entity style (see YAML_*_SCALAR_STYLE)
* @return mixed Value that YAML parser should emit for the given value
*/
function tag_callback ($value, $tag, $flags) {
if (is_array($value)) {
$new_value = '';
foreach ($value as $k => $v) {
$new_value .= "'{$k}' => '{$v}', ";
}
$value = trim($new_value, ', ');
}
return "<value=[{$value}], tag=[{$tag}], flags=[{$flags}]>";
}
// yaml with some custom tags
$yaml_str = <<<YAML
%TAG ! test-
%TAG !! test2-
---
key_a : !tag_a value_a
key_b : !!tag_b 'value_b'
key_c : !<tag:example.com,2011:test/tag_c> "value_c"
key_d : !tag_d |
some
text
key_e : !tag_e >
some
text
key_f : !tag_f [ one, two ]
key_g : !tag_g { sky: blue, sea: green }
key_h : !tag_h
- one
- two
key_i : !tag_i
sky: blue
sea: green
...
YAML;
$yaml = yaml_parse($yaml_str, 0, $ndocs, array(
"test-tag_a" => "tag_callback",
"test2-tag_b" => "tag_callback",
"tag:example.com,2011:test/tag_c" => "tag_callback",
"test-tag_d" => "tag_callback",
"test-tag_e" => "tag_callback",
"test-tag_f" => "tag_callback",
"test-tag_g" => "tag_callback",
"test-tag_h" => "tag_callback",
"test-tag_i" => "tag_callback",
));
var_dump($yaml);
var_dump($ndocs);
?>
--EXPECT--
array(9) {
["key_a"]=>
string(46) "<value=[value_a], tag=[test-tag_a], flags=[1]>"
["key_b"]=>
string(47) "<value=[value_b], tag=[test2-tag_b], flags=[2]>"
["key_c"]=>
string(67) "<value=[value_c], tag=[tag:example.com,2011:test/tag_c], flags=[3]>"
["key_d"]=>
string(49) "<value=[some
text
], tag=[test-tag_d], flags=[4]>"
["key_e"]=>
string(49) "<value=[some text
], tag=[test-tag_e], flags=[5]>"
["key_f"]=>
string(65) "<value=['0' => 'one', '1' => 'two'], tag=[test-tag_f], flags=[0]>"
["key_g"]=>
string(72) "<value=['sky' => 'blue', 'sea' => 'green'], tag=[test-tag_g], flags=[0]>"
["key_h"]=>
string(65) "<value=['0' => 'one', '1' => 'two'], tag=[test-tag_h], flags=[0]>"
["key_i"]=>
string(72) "<value=['sky' => 'blue', 'sea' => 'green'], tag=[test-tag_i], flags=[0]>"
}
int(1)
yaml_002.phpt 0000644 00000002107 15044777142 0006777 0 ustar 00 --TEST--
yaml - emit -> parse roundtrip with datetime
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if(!class_exists('DateTime')) die('skip DateTime n/a');
?>
--INI--
date.timezone=GMT
yaml.decode_timestamp=2
--FILE--
<?php
$original = array(
"canonical" => new DateTime("2001-12-15T02:59:43.1Z"),
"valid iso8601" => new DateTime("2001-12-14t21:59:43.10-05:00"),
"alternate iso8601" => new DateTime("2001-12-14T21:59:43.10-0500"),
"space separated" => new DateTime("2001-12-14 21:59:43.10 -5"),
"no time zone (Z)" => new DateTime("2001-12-15 2:59:43.10"),
"date (0000:00Z)" => new DateTime("2002-12-14"),
);
$yaml = yaml_emit($original);
var_dump($yaml);
$parsed = yaml_parse($yaml);
var_dump($parsed == $original);
?>
--EXPECT--
string(303) "---
canonical: 2001-12-15T02:59:43.100000+00:00
valid iso8601: 2001-12-14T21:59:43.100000-05:00
alternate iso8601: 2001-12-14T21:59:43.100000-05:00
space separated: 2001-12-14T21:59:43.100000-05:00
no time zone (Z): 2001-12-15T02:59:43.100000+00:00
date (0000:00Z): 2002-12-14T00:00:00.000000+00:00
...
"
bool(true)
bug_74799.phpt 0000644 00000001501 15044777142 0007011 0 ustar 00 --TEST--
Memory leak check
--CREDITS--
Gleb Svitelskiy <gleb.svitelskiy@gmail.com>
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
function tag_callback($value, $tag, $flags) {
return 'callback value';
}
$base_memory = memory_get_usage();
$yamlString ="---\nkey: !value\n...\n";
$ndocs = null;
yaml_parse($yamlString, 0, $ndocs, ['!value' => 'tag_callback']);
unset($yamlString, $ndocs);
$ndocs = null;
yaml_parse_file(__DIR__.'/bug_74799.yaml', 0, $ndocs, ['!value' => 'tag_callback']);
unset($ndocs);
$array = ['key' => 'value'];
yaml_emit($array);
unset($array);
$array = ['key' => 'value'];
yaml_emit_file(__DIR__.'/bug_74799.tmp', $array);
unset($array);
var_dump($base_memory == memory_get_usage());
?>
--CLEAN--
<?php
unlink(__DIR__.'/bug_74799.tmp');
?>
--EXPECT--
bool(true)
yaml_parse_wiki_YtsBlockMapping_002.phpt 0000644 00000000713 15044777143 0014344 0 ustar 00 --TEST--
Yaml YtsBlockMapping - Multi Element Mapping
--DESCRIPTION--
More than one key/value pair
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
red: baron
white: walls
blue: berries
'));
?>
--EXPECT--
array(3) {
["red"]=>
string(5) "baron"
["white"]=>
string(5) "walls"
["blue"]=>
string(7) "berries"
}
yaml_parse_wiki_YtsStrangeKeys_002.phpt 0000644 00000000726 15044777143 0014241 0 ustar 00 --TEST--
Yaml YtsStrangeKeys - Unquoted line noise key
--DESCRIPTION--
Check that unquoted line noise parses as key.
This requires the line noise be tame enough
to pass as an implicit plain key.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
-+!@#% : bar baz
'));
?>
--EXPECT--
array(1) {
["-+!@#%"]=>
string(7) "bar baz"
}
yaml_parse_wiki_YtsBlockMapping_004.phpt 0000644 00000000742 15044777143 0014350 0 ustar 00 --TEST--
Yaml YtsBlockMapping - Colons aligned
--DESCRIPTION--
Spaces can come before the ': ' key/value separator.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
red : baron
white : walls
blue : berries
'));
?>
--EXPECT--
array(3) {
["red"]=>
string(5) "baron"
["white"]=>
string(5) "walls"
["blue"]=>
string(7) "berries"
}
yaml_parse_spec_int.phpt 0000644 00000000756 15044777143 0011505 0 ustar 00 --TEST--
Yaml 1.1 Spec - int
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('
canonical: 685230
decimal: +685_230
octal: 02472256
hexadecimal: 0x_0A_74_AE
binary: 0b1010_0111_0100_1010_1110
sexagesimal: 190:20:30
'));
?>
--EXPECT--
array(6) {
["canonical"]=>
int(685230)
["decimal"]=>
int(685230)
["octal"]=>
int(685230)
["hexadecimal"]=>
int(685230)
["binary"]=>
int(685230)
["sexagesimal"]=>
int(685230)
}
yaml_emit_008.phpt 0000644 00000002720 15044777143 0010025 0 ustar 00 --TEST--
yaml_emit - custom tags
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
?>
--FILE--
<?php
class Emit008Example {
public $data; // data may be in any pecl/yaml suitable type
/**
* Yaml emit callback function, referred on yaml_emit call by class name.
*
* Expected to return an array with 2 values:
* - 'tag': custom tag for this serialization
* - 'data': value to convert to yaml (array, string, bool, number)
*
* @return array
*/
public static function yamlEmit (Emit008Example $obj) {
return array(
'tag' => '!emit008',
'data' => $obj->data,
);
}
}
$emit_callbacks = array(
'Emit008Example' => array('Emit008Example', 'yamlEmit')
);
$t = new Emit008Example();
$t->data = array ('a','b','c');
$yaml = yaml_emit(
array(
'callback' => $t,
),
YAML_ANY_ENCODING,
YAML_ANY_BREAK,
$emit_callbacks
);
var_dump($yaml);
/* make sure you can undo the custome serialization */
function parse_008 ($value, $tag, $flags) {
$ret = new Emit008Example();
$ret->data = $value;
return $ret;
}
$parse_callbacks = array(
'!emit008' => 'parse_008',
);
$array = yaml_parse($yaml, 0, $cnt, $parse_callbacks);
var_dump($array['callback'] == $t);
/* roundtrip with raw object */
var_dump($t == yaml_parse(
yaml_emit($t, YAML_ANY_ENCODING, YAML_ANY_BREAK, $emit_callbacks),
0, $cnt, $parse_callbacks));
?>
--EXPECT--
string(39) "---
callback: !emit008
- a
- b
- c
...
"
bool(true)
bool(true)
yaml_emit_003.phpt 0000644 00000003172 15044777143 0010022 0 ustar 00 --TEST--
yaml_emit - mappings
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$addr = array(
"given" => "Chris",
"family"=> "Dumars",
"address"=> array(
"lines"=> "458 Walkman Dr.
Suite #292",
"city"=> "Royal Oak",
"state"=> "MI",
"postal"=> 48046,
),
);
$invoice = array (
"invoice"=> 34843,
"date"=> 980208000,
"bill-to"=> $addr,
"ship-to"=> $addr,
"product"=> array(
array(
"sku"=> "BL394D",
"quantity"=> 4,
"description"=> "Basketball",
"price"=> 450,
),
array(
"sku"=> "BL4438H",
"quantity"=> 1,
"description"=> "Super Hoop",
"price"=> 2392,
),
),
"tax"=> 251.42,
"total"=> 4443.52,
"comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
);
var_dump(yaml_emit($invoice));
?>
--EXPECT--
string(620) "---
invoice: 34843
date: 980208000
bill-to:
given: Chris
family: Dumars
address:
lines: |-
458 Walkman Dr.
Suite #292
city: Royal Oak
state: MI
postal: 48046
ship-to:
given: Chris
family: Dumars
address:
lines: |-
458 Walkman Dr.
Suite #292
city: Royal Oak
state: MI
postal: 48046
product:
- sku: BL394D
quantity: 4
description: Basketball
price: 450
- sku: BL4438H
quantity: 1
description: Super Hoop
price: 2392
tax: 251.42
total: 4443.52
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
"
yaml_emit_001.phpt 0000644 00000004341 15044777143 0010017 0 ustar 00 --TEST--
yaml_emit - scalars
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
var_dump(yaml_emit(null));
var_dump(yaml_emit(true));
var_dump(yaml_emit(false));
var_dump(yaml_emit(10));
var_dump(yaml_emit(-10));
var_dump(yaml_emit(123.456));
var_dump(yaml_emit(-123.456));
var_dump(yaml_emit("yes"));
var_dump(yaml_emit("no"));
var_dump(yaml_emit("~"));
var_dump(yaml_emit("-"));
var_dump(yaml_emit("'"));
var_dump(yaml_emit('"'));
var_dump(yaml_emit("I\\xF1t\\xEBrn\\xE2ti\\xF4n\\xE0liz\\xE6ti\\xF8n"));
var_dump(yaml_emit("# looks like a comment"));
var_dump(yaml_emit("@looks_like_a_ref"));
var_dump(yaml_emit("&looks_like_a_alias"));
var_dump(yaml_emit("!!str"));
var_dump(yaml_emit("%TAG ! tag:looks.like.one,999:"));
var_dump(yaml_emit("!something"));
var_dump(yaml_emit("Hello world!"));
var_dump(yaml_emit("This is a string with\nan embedded newline."));
$str = <<<EOD
This string was made with a here doc.
It contains embedded newlines.
It also has some embedded tabs.
Here are some symbols:
`~!@#$%^&*()_-+={}[]|\:";'<>,.?/
These are extended characters: Iñtërnâtiônàlizætiøn
EOD;
var_dump(yaml_emit($str));
?>
--EXPECT--
string(10) "--- ~
...
"
string(13) "--- true
...
"
string(14) "--- false
...
"
string(11) "--- 10
...
"
string(12) "--- -10
...
"
string(16) "--- 123.456
...
"
string(17) "--- -123.456
...
"
string(14) "--- "yes"
...
"
string(13) "--- "no"
...
"
string(12) "--- "~"
...
"
string(12) "--- '-'
...
"
string(13) "--- ''''
...
"
string(12) "--- '"'
...
"
string(50) "--- I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n
...
"
string(33) "--- '# looks like a comment'
...
"
string(28) "--- '@looks_like_a_ref'
...
"
string(30) "--- '&looks_like_a_alias'
...
"
string(16) "--- '!!str'
...
"
string(41) "--- '%TAG ! tag:looks.like.one,999:'
...
"
string(21) "--- '!something'
...
"
string(21) "--- Hello world!
...
"
string(58) "--- |-
This is a string with
an embedded newline.
...
"
string(267) "--- "This string was made with a here doc.\n\nIt contains embedded newlines.\n \t\tIt
also has some embedded tabs.\n\nHere are some symbols:\n`~!@#$%^&*()_-+={}[]|\\:\";'<>,.?/\n\nThese
are extended characters: I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\n\n"
...
"
yaml_parse_wiki_YtsBasicTests_005.phpt 0000644 00000001124 15044777143 0014042 0 ustar 00 --TEST--
Yaml YtsBasicTests - Simple Mapping
--DESCRIPTION--
You can add a keyed list "also known as a dictionary or
hash" to your document by placing each member of the
list on a new line, with a colon seperating the key
from its value. In YAML, this type of list is called
a mapping.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('foo: whatever
bar: stuff
'));
?>
--EXPECT--
array(2) {
["foo"]=>
string(8) "whatever"
["bar"]=>
string(5) "stuff"
}
yaml_parse_004.phpt 0000644 00000000727 15044777143 0010202 0 ustar 00 --TEST--
yaml_parse - syck bug #11585
--CREDITS--
From syck bug #11585
http://pecl.php.net/bugs/bug.php?id=11585
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('---
define: &pointer_to_define
- 1
- 2
- 3
reference: *broken_pointer_to_define
'));
?>
--EXPECTF--
Warning: yaml_parse(): alias broken_pointer_to_define is not registered (line 6, column 37) in %syaml_parse_004.php on line %d
bool(false)
yaml_parse_wiki_YtsBasicTests_003.phpt 0000644 00000001137 15044777143 0014044 0 ustar 00 --TEST--
Yaml YtsBasicTests - Mixed Sequences
--DESCRIPTION--
Sequences can contain any YAML data,
including strings and other sequences.
--CREDITS--
Bryan Davis bd808@bd808.com
# yaml.kwiki.org import/conversion
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--FILE--
<?php
var_dump(yaml_parse('- apple
-
- foo
- bar
- x123
- banana
- carrot
'));
?>
--EXPECT--
array(4) {
[0]=>
string(5) "apple"
[1]=>
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
[2]=>
string(4) "x123"
}
[2]=>
string(6) "banana"
[3]=>
string(6) "carrot"
}
yaml_emit_002.phpt 0000644 00000003644 15044777143 0010025 0 ustar 00 --TEST--
yaml_emit - sequences
--SKIPIF--
<?php if(!extension_loaded('yaml')) die('skip yaml n/a'); ?>
--INI--
serialize_precision=-1
--FILE--
<?php
$str = <<<EOD
This string was made with a here doc.
It contains embedded newlines.
It also has some embedded tabs.
Here are some symbols:
`~!@#$%^&*()_-+={}[]|\:";'<>,.?/
These are extended characters: Iñtërnâtiônàlizætiøn
EOD;
$doc = array(
null,
true,
false,
10,
-10,
123.456,
-123.456,
"yes",
"no",
"~",
"-",
"'",
'"',
"I\\xF1t\\xEBrn\\xE2ti\\xF4n\\xE0liz\\xE6ti\\xF8n",
"# looks like a comment",
"@looks_like_a_ref",
"&looks_like_a_alias",
"!!str",
"%TAG ! tag:looks.like.one,999:",
"!something",
"Hello world!",
"This is a string with\nan embedded newline.",
$str,
);
echo "=== Array of scalars ===\n";
var_dump(yaml_emit($doc));
echo "=== Nested ===\n";
var_dump(yaml_emit(array(
"top level",
array(
"in array",
),
array(
"in array",
array(
"in array",
),
),
)));
echo "=== Degenerate ===\n";
var_dump(yaml_emit(array()));
?>
--EXPECT--
=== Array of scalars ===
string(604) "---
- ~
- true
- false
- 10
- -10
- 123.456
- -123.456
- "yes"
- "no"
- "~"
- '-'
- ''''
- '"'
- I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n
- '# looks like a comment'
- '@looks_like_a_ref'
- '&looks_like_a_alias'
- '!!str'
- '%TAG ! tag:looks.like.one,999:'
- '!something'
- Hello world!
- |-
This is a string with
an embedded newline.
- "This string was made with a here doc.\n\nIt contains embedded newlines.\n \t\tIt
also has some embedded tabs.\n\nHere are some symbols:\n`~!@#$%^&*()_-+={}[]|\\:\";'<>,.?/\n\nThese
are extended characters: I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\n\n"
...
"
=== Nested ===
string(61) "---
- top level
- - in array
- - in array
- - in array
...
"
=== Degenerate ===
string(11) "--- []
...
"
ssh2_sftp_002.phpt 0000644 00000001060 15045020017 0007724 0 ustar 00 --TEST--
ssh2_sftp - SFTP tests
--SKIPIF--
<?php
require('ssh2_skip.inc');
ssh2t_needs_auth();
ssh2t_writes_remote();
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
ssh2t_auth($ssh);
$sftp = ssh2_sftp($ssh);
$filename = ssh2t_tempnam();
$fp = fopen("ssh2.sftp://$sftp/$filename", 'w');
fwrite($fp, "Hello World\n");
fwrite($fp, "Goodbye Planet\n");
fclose($fp);
readfile("ssh2.sftp://$sftp/$filename");
var_dump(ssh2_sftp_unlink($sftp, $filename));
--EXPECT--
Hello World
Goodbye Planet
bool(true)
ssh2_auth_pubkey_file.phpt 0000644 00000001077 15045020017 0011716 0 ustar 00 --TEST--
ssh2_auth_pubkey_file() - Tests authentication with a key
--SKIPIF--
<?php require('ssh2_skip.inc'); ?>
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2_auth_pubkey_file($ssh, TEST_SSH2_USER, TEST_SSH2_PUB_KEY, TEST_SSH2_PRIV_KEY));
$cmd=ssh2_exec($ssh, 'echo "testing echo with key auth"' . PHP_EOL);
var_dump($cmd);
stream_set_blocking($cmd, true);
$response = stream_get_contents($cmd);
echo $response . PHP_EOL;
--EXPECTF--
bool(true)
resource(%d) of type (stream)
testing echo with key auth
testkey_rsa.pub 0000644 00000000575 15045020017 0007612 0 ustar 00 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCcOpvkriEX0jbnvVSLN2vA/Nu3injPZixYcgLEctvubxRgZisqNmdtvpKN3I+BviIDnznocc+E7BWm+aF6BvQDYGcozpljjIhia27lXBB+xldJcuEvPKI1DUamwy8ZwvGXGaCLC7MBbXzdqJcnoIp3ci1JQlUOZJ+rCNkMLLbwGWI45xr3kOUzR2Mb0B3EEVtRZL4S8ZvypdZ6WmNhI2WnuJp6QobEPMti01J6LkWQDVyk2Mj+EI8+RuEPfRgYMa2lEI5/BYWIX6uHAdbiDcxmwSn4JOu0LqQvodawXt5fA8g7JchOMht4Rq0haMI5VERWziq9ERu5ShoY3WSFgmLH
bug63480.phpt 0000644 00000000736 15045020017 0006623 0 ustar 00 --TEST--
Bug #63480 (Warning on using the SSH2 Session resource in the uri)
--SKIPIF--
<?php
require('ssh2_skip.inc');
ssh2t_needs_auth();
ssh2t_writes_remote();
?>
--FILE--
<?php
require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
ssh2t_auth($ssh);
$filename = ssh2t_tempnam();
file_put_contents("ssh2.sftp://$ssh/$filename", "yada yada");
readfile("ssh2.sftp://$ssh/$filename");
unlink("ssh2.sftp://$ssh/$filename");
?>
--EXPECT--
yada yada
ssh2_connect.phpt 0000644 00000002444 15045020017 0010027 0 ustar 00 --TEST--
ssh2_connect() Basic connection and pre-authentication
--SKIPIF--
<?php require('ssh2_skip.inc'); ?>
--FILE--
<?php require('ssh2_test.inc');
echo "**Connect\n";
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(is_resource($ssh));
var_dump(get_resource_type($ssh));
echo "**Fingerprint MD5\n";
$md5 = ssh2_fingerprint($ssh);
var_dump(is_string($md5));
var_dump(strlen($md5));
var_dump(ctype_xdigit($md5));
echo "**Fingerprint SHA1\n";
$sha1 = ssh2_fingerprint($ssh, SSH2_FINGERPRINT_SHA1 | SSH2_FINGERPRINT_HEX);
var_dump(is_string($sha1));
var_dump(strlen($sha1));
var_dump(ctype_xdigit($sha1));
function ssh2t_strset($v) {
return is_string($v) && (strlen($v) > 0);
}
echo "**Negotiation\n";
$mn = ssh2_methods_negotiated($ssh);
var_dump(ssh2t_strset($mn['kex']));
var_dump(ssh2t_strset($mn['hostkey']));
foreach(array('client_to_server', 'server_to_client') as $direction) {
$mnd = $mn[$direction];
var_dump(ssh2t_strset($mnd['crypt']));
var_dump(ssh2t_strset($mnd['comp']));
var_dump(ssh2t_strset($mnd['mac']));
}
--EXPECT--
**Connect
bool(true)
string(12) "SSH2 Session"
**Fingerprint MD5
bool(true)
int(32)
bool(true)
**Fingerprint SHA1
bool(true)
int(40)
bool(true)
**Negotiation
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bug79631.phpt 0000644 00000000552 15045020017 0006624 0 ustar 00 --TEST--
Bug 79631 (SSH disconnect segfault with SFTP (assertion failed))
--SKIPIF--
<?php
require('ssh2_skip.inc');
ssh2t_needs_auth();
ssh2t_writes_remote();
?>
--FILE--
<?php
require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
ssh2t_auth($ssh);
$sftp = ssh2_sftp($ssh);
ssh2_disconnect($ssh);
echo "done\n";
?>
--EXPECT--
done
ssh2_send_eof.phpt 0000644 00000001105 15045020017 0010151 0 ustar 00 --TEST--
ssh2_send_eof() - Tests closing standard input
--SKIPIF--
<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); ?>
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2t_auth($ssh));
$cmd=ssh2_exec($ssh, "cat\n");
var_dump($cmd);
stream_set_blocking($cmd, true);
$content = "foo";
fwrite($cmd, $content);
fflush($cmd);
ssh2_send_eof($cmd);
$response = stream_get_contents($cmd);
var_dump($response === $content);
echo $response . PHP_EOL;
--EXPECTF--
bool(true)
resource(%d) of type (stream)
bool(true)
foo
ssh2_skip.inc 0000644 00000000627 15045020017 0007143 0 ustar 00 <?php
require('ssh2_test.inc');
if (!extension_loaded("ssh2")) print "skip extension not loaded";
if (TEST_SSH2_HOSTNAME === false) print "skip TEST_SSH2_HOSTNAME not set";
function ssh2t_needs_auth() {
if (TEST_SSH2_AUTH == 'none') {
print "skip TEST_SSH2_AUTH == 'none'";
}
}
function ssh2t_writes_remote() {
if (!TEST_SSH2_TEMPDIR) {
print "skip TEST_SSH2_TEMPDIR is empty";
}
}
ssh2_shell.phpt 0000644 00000000713 15045020017 0007502 0 ustar 00 --TEST--
ssh2_shell_test() - Tests opening a shell
--SKIPIF--
<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); ?>
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2t_auth($ssh));
$shell = ssh2_shell($ssh);
var_dump($shell);
fwrite( $shell, 'echo "foo bar"'.PHP_EOL);
sleep(1);
while($line = fgets($shell)) {
echo $line;
}
--EXPECTF--
bool(true)
resource(%d) of type (stream)
%a
foo bar
%a ssh2_auth_pubkey.phpt 0000644 00000001133 15045020017 0010710 0 ustar 00 --TEST--
ssh2_auth_pubkey() - Tests authentication with a key
--SKIPIF--
<?php require('ssh2_skip.inc'); ?>
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2_auth_pubkey($ssh, TEST_SSH2_USER, file_get_contents(TEST_SSH2_PUB_KEY), file_get_contents(TEST_SSH2_PRIV_KEY)));
$cmd=ssh2_exec($ssh, 'echo "testing echo with key auth"' . PHP_EOL);
var_dump($cmd);
stream_set_blocking($cmd, true);
$response = stream_get_contents($cmd);
echo $response . PHP_EOL;
--EXPECTF--
bool(true)
resource(%d) of type (stream)
testing echo with key auth
ssh2_test.inc 0000644 00000002222 15045020017 0007145 0 ustar 00 <?php
function ssh2t_getenv($env, $def=false) {
$v = getenv($env);
return ($v === false) ? $def : $v;
}
function ssh2t_defenv($env, $def=false, $name=null) {
define(($name === null) ? $env : $name, ssh2t_getenv($env, $def));
}
ssh2t_defenv('TEST_SSH2_HOSTNAME');
ssh2t_defenv('TEST_SSH2_PORT', 22);
ssh2t_defenv('TEST_SSH2_USER', getenv('USER'));
ssh2t_defenv('TEST_SSH2_PASS');
ssh2t_defenv('TEST_SSH2_TEMPDIR', '/tmp');
ssh2t_defenv('TEST_SSH2_AUTH', TEST_SSH2_PASS ? 'password' : 'none');
ssh2t_defenv('TEST_SSH2_PUB_KEY', dirname(__FILE__) . "/testkey_rsa.pub");
ssh2t_defenv('TEST_SSH2_PRIV_KEY', dirname(__FILE__) . "/testkey_rsa");
function ssh2t_auth($ssh) {
if (!TEST_SSH2_USER) {
return false;
}
switch (TEST_SSH2_AUTH) {
case 'none': return (ssh2_auth_none($ssh, TEST_SSH2_USER) === true) ? true : false;
case 'agent': return ssh2_auth_agent($ssh, TEST_SSH2_USER);
case 'password': return ssh2_auth_password($ssh, TEST_SSH2_USER, TEST_SSH2_PASS);
}
return false;
}
function ssh2t_tempnam($escape = false) {
$fn = TEST_SSH2_TEMPDIR . '/php-ssh2-test-' . uniqid();
return $escape ? escapeshellarg($fn) : $fn;
}
testkey_rsa 0000644 00000003213 15045020017 0007015 0 ustar 00 -----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAnDqb5K4hF9I2571UizdrwPzbt4p4z2YsWHICxHLb7m8UYGYr
KjZnbb6SjdyPgb4iA5856HHPhOwVpvmhegb0A2BnKM6ZY4yIYmtu5VwQfsZXSXLh
LzyiNQ1GpsMvGcLxlxmgiwuzAW183aiXJ6CKd3ItSUJVDmSfqwjZDCy28BliOOca
95DlM0djG9AdxBFbUWS+EvGb8qXWelpjYSNlp7iaekKGxDzLYtNSei5FkA1cpNjI
/hCPPkbhD30YGDGtpRCOfwWFiF+rhwHW4g3MZsEp+CTrtC6kL6HWsF7eXwPIOyXI
TjIbeEatIWjCOVREVs4qvREbuUoaGN1khYJixwIDAQABAoIBAH9Ysux0GBufygua
ZAjbEyWLt9njsNh2U52AycqySZ4Qw45Umcjd8e8eEb47VGsQvg8vwnc8FkkmW/vw
rfSXKF58PXqg9Z2U1zNKmWmyYuvD5zDCyNXFWf9epAGZRpJ8OovNYvUUg0Sdp9PS
8etmTJhS5KE7xbNmyFQVcT8gT7pj4IEHzEcZZQuO0w8jmKSnn8E4k5leasSR7+U3
GNRASAmuOPVsG4rp4pl4CIvUlpEPK7yuIAWD6Qwhh4nkqiZflcZ+tNDKUhMIRbez
5URX3dgZnG7fbZZI++LTRM4M09LojbdFOdT95lWJr0Pm+3h51s965F+zwkR2vYMS
6g4WcUkCgYEAyscCArrg1nocKx5ubFJVyxe/YT328Et6GhKRqTyYDMq8eznFE8of
01KiVg1+48YMb2Wc94zjsRBgHsjEz/A/f0hRtLBx3LCaYNwVF5o4DI6LqmAnOlnE
an9yYnhh8Ux4nw9PjszjdpGglIJkf0o9nP6biBgq7TAXzLfSIOxSnFsCgYEAxTvs
sE+PiF3mD4U9bWoBqRyFywDMW9mPueX9TltNqpQksaS1FzP08pCi6fTUIrsxQtXE
78N5uxiRo1OiNsPm8pluPu2Na7yfI1MQJZE8OmEadqdyPWPVYZVkUVIo13iHGovo
2eMHirb3k9y2y4WJJBPA2hOZ8azF7u1epD70DwUCgYBT4kWDqZkvQG58q+cUKm9R
R66k5IRN3XtSY9IcB3QC/q8/7qMHT7sgqXN8U7LlON2WC5wGkCL08YhB094PAxzR
Y7JhJAjGOcxzOzgCfoqnLyS5w3MW4WGuiLBh6djigDb53dSUh0+lkhKyvMokGiso
0e63OwAvBJEj3/suIXT/NwKBgGY+uGZ1+BxjQP5OvhdYWuAGDz27fjUnRaDDH1td
bZe+EH+euNn8b0DHxgyuhMI0dEcHdn4swZBCHk2i73age7rL2yD4GNX/BChVyQsQ
jT5eVE+qYkh81oMt5MFbbBy3OKKEYQOC88fvLc0TIBfFc+Cl9NWYT7e/LyS7HNLc
Z7zZAoGBAKhDfPMvGXeTjha/nBArD8rp9W7R7VrZd/VUIBOmnWhiQCRTv1KVQGKh
OGQ1taWdRt98wbnVkMxFHN4oCrnDv7cpXQNvw9m/WGZxXMgWWX0f1cpJSwewiNBt
Bb4jmKhkeAe8LwTPoxNYXxnzzf0UQox2HhcbKNP17Np/Y22NQPEf
-----END RSA PRIVATE KEY-----
ssh2_stream_select.phpt 0000644 00000001325 15045020017 0011225 0 ustar 00 --TEST--
ssh2_stream_select() - Tests opening a shell and using stream_select
--SKIPIF--
<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); ?>
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2t_auth($ssh));
$shell = ssh2_shell($ssh);
var_dump($shell);
fwrite($shell, "echo \"howdy\"\n");
sleep(1);
$read = [$shell];
$write = null;
$except = null;
$timeout = 5;
$start = time();
if (stream_select($read, $write, $except, $timeout) !== false && count($read) > 0) {
while($line = fgets($shell)) {
echo $line;
}
}
$elapsed = time() - $start;
var_dump(($elapsed < $timeout));
--EXPECTF--
bool(true)
resource(%d) of type (stream)
%a
%a
%a
howdy
%sbool(true) ssh2_auth.phpt 0000644 00000000433 15045020017 0007333 0 ustar 00 --TEST--
ssh2_auth_FOO() - Attempt to authenticate to a remote host
--SKIPIF--
<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); ?>
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2t_auth($ssh));
--EXPECT--
bool(true)
ssh2_sftp_001.phpt 0000644 00000001404 15045020017 0007725 0 ustar 00 --TEST--
ssh2_sftp - SFTP tests
--SKIPIF--
<?php
require('ssh2_skip.inc');
ssh2t_needs_auth();
ssh2t_writes_remote();
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
ssh2t_auth($ssh);
$sftp = ssh2_sftp($ssh);
$filename = ssh2t_tempnam();
$linkname = ssh2t_tempnam();
var_dump(ssh2_sftp_mkdir($sftp, $filename, 0644, true));
var_dump(ssh2_sftp_symlink($sftp, $filename, $linkname));
var_dump(ssh2_sftp_readlink($sftp, $linkname) == $filename);
$stat = ssh2_sftp_stat ($sftp, $filename);
var_dump(ssh2_sftp_rmdir($sftp, $filename));
var_dump(ssh2_sftp_unlink($sftp, $linkname));
var_dump(($stat['mode'] & 040000) == 040000); // is_dir()
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
ssh2_exec.phpt 0000644 00000000744 15045020017 0007323 0 ustar 00 --TEST--
ssh2_shell_test() - Tests opening a shell
--SKIPIF--
<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); ?>
--FILE--
<?php require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2t_auth($ssh));
$cmd=ssh2_exec($ssh, 'echo "testing echo"' . PHP_EOL);
var_dump($cmd);
stream_set_blocking($cmd, true);
$response = stream_get_contents($cmd);
echo $response . PHP_EOL;
--EXPECTF--
bool(true)
resource(%d) of type (stream)
testing echo
extauth_03.phpt 0000644 00000007017 15045021505 0007427 0 ustar 00 --TEST--
Test External Authentication errors with oci_pconnect
--EXTENSIONS--
oci8
--SKIPIF--
<?php
if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip feature not available on Windows platforms");
?>
--INI--
oci8.privileged_connect=1
--FILE--
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
// Run Test
echo "Test 1\n";
$c = oci_pconnect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 2\n";
$c = oci_pconnect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 3\n";
$c = oci_pconnect('notemtpy', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 4\n";
$c = oci_pconnect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 5\n";
$c = oci_pconnect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 6\n";
$c = oci_pconnect('', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 7\n";
$c = oci_pconnect('/', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 8\n";
$c = oci_pconnect('/', null, 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 9\n";
$c = oci_pconnect('/', '', 'd', null, OCI_SYSDBA+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 10\n";
$c = oci_pconnect('/', '', 'd', null, OCI_SYSOPER+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
?>
--EXPECTF--
Test 1
Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 2
Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 3
Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 4
Warning: oci_pconnect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
bool(false)
bool(false)
Test 5
Warning: oci_pconnect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
bool(false)
bool(false)
Test 6
Warning: oci_pconnect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 7
Warning: oci_pconnect(): ORA-12154: %s in %s on line %d
array(4) {
["code"]=>
int(12154)
["message"]=>
string(%d) "ORA-12154: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 8
Warning: oci_pconnect(): ORA-12154: %s in %s on line %d
array(4) {
["code"]=>
int(12154)
["message"]=>
string(%d) "ORA-12154: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 9
Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d
array(4) {
["code"]=>
int(%d)
["message"]=>
string(%d) "ORA-%d: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 10
Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d
array(4) {
["code"]=>
int(%d)
["message"]=>
string(%d) "ORA-%d: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
drcp_connection_class.phpt 0000644 00000001315 15045021505 0011772 0 ustar 00 --TEST--
DRCP: oci8.connection_class with ini_get() and ini_set()
--EXTENSIONS--
oci8
--SKIPIF--
<?php
preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
if (!(isset($matches[0]) && $matches[0] >= 11)) {
die("skip works only with Oracle 11g or greater version of Oracle client libraries");
}
?>
--INI--
oci8.connection_class=test
--FILE--
<?php
echo "Setting a new connection class now\n";
ini_set('oci8.connection_class',"New cc");
// Get the New connection class name. Should return New CC
$new_cc = ini_get('oci8.connection_class');
echo "The New oci8.connection_class is $new_cc\n";
echo "Done\n";
?>
--EXPECT--
Setting a new connection class now
The New oci8.connection_class is New cc
Done
error1.phpt 0000644 00000000613 15045021505 0006650 0 ustar 00 --TEST--
oci_error() when oci_connect() fails
--EXTENSIONS--
oci8
--FILE--
<?php
var_dump(oci_connect("some", "some", "some"));
var_dump(oci_error());
echo "Done\n";
?>
--EXPECTF--
Warning: oci_connect(): ORA-12154: %s in %s on line %d
bool(false)
array(4) {
["code"]=>
int(12154)
["message"]=>
string(%d) "ORA-12154: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
Done
ini_1.phpt 0000644 00000006242 15045021505 0006441 0 ustar 00 --TEST--
Test OCI8 php.ini settings
--EXTENSIONS--
oci8
--SKIPIF--
<?php
preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
if (!(isset($matches[0]) && $matches[0] >= 11)) {
die("skip works only with Oracle 11g or greater version of Oracle client libraries");
}
?>
--INI--
oci8.privileged_connect = On
oci8.max_persistent = 111
oci8.persistent_timeout = 222
oci8.ping_interval = 333
oci8.connection_class = MyCC
oci8.events = On
oci8.statement_cache_size = 444
oci8.default_prefetch = 555
oci8.old_oci_close_semantics = On
--FILE--
<?php
echo "Test 1 - check initialization\n";
echo 'oci8.privileged_connect = ' . ini_get('oci8.privileged_connect') . "\n";
echo 'oci8.max_persistent = ' . ini_get('oci8.max_persistent') . "\n";
echo 'oci8.persistent_timeout = ' . ini_get('oci8.persistent_timeout') . "\n";
echo 'oci8.ping_interval = ' . ini_get('oci8.ping_interval') . "\n";
echo 'oci8.connection_class = ' . ini_get('oci8.connection_class') . "\n";
echo 'oci8.events = ' . ini_get('oci8.events') . "\n";
echo 'oci8.statement_cache_size = ' . ini_get('oci8.statement_cache_size') . "\n";
echo 'oci8.default_prefetch = ' . ini_get('oci8.default_prefetch') . "\n";
echo 'oci8.old_oci_close_semantics = ' . ini_get('oci8.old_oci_close_semantics') . "\n";
echo "Test 2 - check what can be changed at runtime\n";
var_dump(ini_set('oci8.privileged_connect', 'Off'));
echo 'oci8.privileged_connect = ' . ini_get('oci8.privileged_connect') . "\n";
var_dump(ini_set('oci8.max_persistent', '999'));
echo 'oci8.max_persistent = ' . ini_get('oci8.max_persistent') . "\n";
var_dump(ini_set('oci8.persistent_timeout', '888'));
echo 'oci8.persistent_timeout = ' . ini_get('oci8.persistent_timeout') . "\n";
var_dump(ini_set('oci8.ping_interval', '777'));
echo 'oci8.ping_interval = ' . ini_get('oci8.ping_interval') . "\n";
var_dump(ini_set('oci8.connection_class', 'OtherCC'));
echo 'oci8.connection_class = ' . ini_get('oci8.connection_class') . "\n";
var_dump(ini_set('oci8.events', 'Off'));
echo 'oci8.events = ' . ini_get('oci8.events') . "\n";
var_dump(ini_set('oci8.statement_cache_size', '666'));
echo 'oci8.statement_cache_size = ' . ini_get('oci8.statement_cache_size') . "\n";
var_dump(ini_set('oci8.default_prefetch', '111'));
echo 'oci8.default_prefetch = ' . ini_get('oci8.default_prefetch') . "\n";
var_dump(ini_set('oci8.old_oci_close_semantics', 'Off'));
echo 'oci8.old_oci_close_semantics = ' . ini_get('oci8.old_oci_close_semantics') . "\n";
?>
--EXPECTF--
Deprecated: Directive oci8.old_oci_close_semantics is deprecated%s
Test 1 - check initialization
oci8.privileged_connect = 1
oci8.max_persistent = 111
oci8.persistent_timeout = 222
oci8.ping_interval = 333
oci8.connection_class = MyCC
oci8.events = 1
oci8.statement_cache_size = 444
oci8.default_prefetch = 555
oci8.old_oci_close_semantics = 1
Test 2 - check what can be changed at runtime
bool(false)
oci8.privileged_connect = 1
bool(false)
oci8.max_persistent = 111
bool(false)
oci8.persistent_timeout = 222
bool(false)
oci8.ping_interval = 333
string(4) "MyCC"
oci8.connection_class = OtherCC
bool(false)
oci8.events = 1
bool(false)
oci8.statement_cache_size = 444
bool(false)
oci8.default_prefetch = 555
bool(false)
oci8.old_oci_close_semantics = 1
extauth_01.phpt 0000644 00000007033 15045021505 0007423 0 ustar 00 --TEST--
Test External Authentication errors with oci_connect
--EXTENSIONS--
oci8
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip feature not available on Windows platforms");
require(__DIR__.'/details.inc');
if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
?>
--INI--
oci8.privileged_connect=1
--FILE--
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
// Run Test
echo "Test 1\n";
$c = oci_connect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 2\n";
$c = oci_connect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 3\n";
$c = oci_connect('notemtpy', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 4\n";
$c = oci_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 5\n";
$c = oci_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 6\n";
$c = oci_connect('', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 7\n";
$c = oci_connect('/', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 8\n";
$c = oci_connect('/', null, 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 9\n";
$c = oci_connect('/', '', 'd', null, OCI_SYSDBA+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 10\n";
$c = oci_connect('/', '', 'd', null, OCI_SYSOPER+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
?>
--EXPECTF--
Test 1
Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 2
Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 3
Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 4
Warning: oci_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
bool(false)
bool(false)
Test 5
Warning: oci_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
bool(false)
bool(false)
Test 6
Warning: oci_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 7
Warning: oci_connect(): ORA-12154: %s in %s on line %d
array(4) {
["code"]=>
int(12154)
["message"]=>
string(%d) "ORA-12154: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 8
Warning: oci_connect(): ORA-12154: %s in %s on line %d
array(4) {
["code"]=>
int(12154)
["message"]=>
string(%d) "ORA-12154: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 9
Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d
array(4) {
["code"]=>
int(%d)
["message"]=>
string(%d) "ORA-%d: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 10
Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d
array(4) {
["code"]=>
int(%d)
["message"]=>
string(%d) "ORA-%d: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
clientversion.phpt 0000644 00000000202 15045021505 0010314 0 ustar 00 --TEST--
oci_client_version()
--EXTENSIONS--
oci8
--FILE--
<?php
echo oci_client_version(), "\n";
?>
--EXPECTF--
%d.%d.%d.%d.%d
lob_aliases.phpt 0000644 00000002574 15045021505 0007723 0 ustar 00 --TEST--
LOB method aliases
--EXTENSIONS--
oci8
--SKIPIF--
<?php
$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
require(__DIR__.'/skipif.inc');
?>
--FILE--
<?php
// Function existence
echo "Test 1\n";
var_dump(function_exists('oci_lob_load'));
var_dump(function_exists('oci_lob_tell'));
var_dump(function_exists('oci_lob_truncate'));
var_dump(function_exists('oci_lob_erase'));
var_dump(function_exists('oci_lob_flush'));
var_dump(function_exists('ocisetbufferinglob'));
var_dump(function_exists('ocigetbufferinglob'));
var_dump(function_exists('oci_lob_rewind'));
var_dump(function_exists('oci_lob_read'));
var_dump(function_exists('oci_lob_eof'));
var_dump(function_exists('oci_lob_seek'));
var_dump(function_exists('oci_lob_write'));
var_dump(function_exists('oci_lob_append'));
var_dump(function_exists('oci_lob_size'));
var_dump(function_exists('oci_lob_export'));
var_dump(function_exists('oci_lob_export'));
var_dump(function_exists('oci_lob_import'));
var_dump(function_exists('oci_lob_save'));
var_dump(function_exists('oci_lob_import'));
var_dump(function_exists('oci_free_descriptor'));
echo "Done\n";
?>
--EXPECT--
Test 1
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
Done
extauth_02.phpt 0000644 00000007110 15045021505 0007420 0 ustar 00 --TEST--
Test External Authentication errors with oci_new_connect
--EXTENSIONS--
oci8
--SKIPIF--
<?php
if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip feature not available on Windows platforms");
?>
--INI--
oci8.privileged_connect=1
--FILE--
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
// Run Test
echo "Test 1\n";
$c = oci_new_connect('/', 'notemtpy', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 2\n";
$c = oci_new_connect('notemtpy', 'notemtpy', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 3\n";
$c = oci_new_connect('notemtpy', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 4\n";
$c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 5\n";
$c = oci_new_connect('a', 'b', 'c', null, OCI_SYSDBA+OCI_SYSOPER+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 6\n";
$c = oci_new_connect('', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 7\n";
$c = oci_new_connect('/', '', 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 8\n";
$c = oci_new_connect('/', null, 'anything', null, OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 9\n";
$c = oci_new_connect('/', '', 'd', null, OCI_SYSDBA+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
echo "Test 10\n";
$c = oci_new_connect('/', '', 'd', null, OCI_SYSOPER+OCI_CRED_EXT);
if (!$c) {
$m = oci_error();
var_dump($m);
}
var_dump($c);
?>
--EXPECTF--
Test 1
Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 2
Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 3
Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 4
Warning: oci_new_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
bool(false)
bool(false)
Test 5
Warning: oci_new_connect(): OCI_SYSDBA and OCI_SYSOPER cannot be used together in %s on line %d
bool(false)
bool(false)
Test 6
Warning: oci_new_connect(): OCI_CRED_EXT can only be used with a username of "/" and a NULL password in %s on line %d
bool(false)
bool(false)
Test 7
Warning: oci_new_connect(): ORA-12154: %s in %s on line %d
array(4) {
["code"]=>
int(12154)
["message"]=>
string(%d) "ORA-12154: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 8
Warning: oci_new_connect(): ORA-12154: %s in %s on line %d
array(4) {
["code"]=>
int(12154)
["message"]=>
string(%d) "ORA-12154: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 9
Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d
array(4) {
["code"]=>
int(%d)
["message"]=>
string(%d) "ORA-%d: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
Test 10
Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d
array(4) {
["code"]=>
int(%d)
["message"]=>
string(%d) "ORA-%d: %s"
["offset"]=>
int(0)
["sqltext"]=>
string(0) ""
}
bool(false)
minfo.phpt 0000644 00000000405 15045021505 0006545 0 ustar 00 --TEST--
Code coverage for PHP_MINFO_FUNCTION(oci)
--EXTENSIONS--
oci8
--FILE--
<?php
ob_start();
phpinfo(INFO_MODULES);
$v = ob_get_clean();
$r = preg_match('/OCI8 Support .* enabled/', $v);
if ($r !== 1)
var_dump($r);
echo "Done\n";
?>
--EXPECT--
Done
uuid_is_null.phpt 0000644 00000000754 15045601222 0010137 0 ustar 00 --TEST--
uuid_is_null() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
var_dump(uuid_is_null("00000000-0000-0000-0000-000000000000"));
var_dump(uuid_is_null("b691c99c-7fc5-11d8-9fa8-00065b896488"));
try {
if (!uuid_is_null("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")) {
echo "OK\n";
}
} catch (ValueError $e) {
echo $e->getMessage() . "\n"; // PHP 8
echo "OK\n";
}
?>
--EXPECTF--
bool(true)
bool(false)
%A Argument #1 ($uuid) UUID expected%AOK
uuid_variant.phpt 0000644 00000000641 15045601222 0010131 0 ustar 00 --TEST--
uuid_variant() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
if(!function_exists('uuid_variant')) die('skip not compiled in (HAVE_UUID_VARIANT)');
?>
--FILE--
<?php
echo uuid_variant("b691c99c-7fc5-11d8-9fa8-00065b896488")."\n";
echo uuid_variant("878b258c-a9f1-467c-8e1d-47d79ca2c01b")."\n";
echo uuid_variant("00000000-0000-0000-0000-000000000000")."\n";
?>
--EXPECT--
1
1
-1
uuid_compare.phpt 0000644 00000001663 15045601222 0010120 0 ustar 00 --TEST--
uuid_compare() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
$uuids = array();
$uuids[0] = "00000000-0000-0000-0000-000000000000";
$uuids[1] = "878b258c-a9f1-467c-8e1d-47d79ca2c01b";
$uuids[2] = "b691c99c-7fc5-11d8-9fa8-00065b896488";
foreach ($uuids as $key1 => $uuid1) {
foreach ($uuids as $key2 => $uuid2) {
echo "uuid$key1";
switch (uuid_compare($uuid1, $uuid2)) {
case -1: echo " < "; break;
case 0: echo " = "; break;
case 1: echo " > "; break;
}
echo "uuid$key2\n";
}
echo "\n";
}
?>
--EXPECT--
uuid0 = uuid0
uuid0 < uuid1
uuid0 < uuid2
uuid1 > uuid0
uuid1 = uuid1
uuid1 < uuid2
uuid2 > uuid0
uuid2 > uuid1
uuid2 = uuid2
uuid_type.phpt 0000644 00000001003 15045601222 0007437 0 ustar 00 --TEST--
uuid_type() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
if(!function_exists('uuid_type')) die('skip not compiled in (HAVE_UUID_TYPE)');
?>
--FILE--
<?php
echo uuid_type("b691c99c-7fc5-11d8-9fa8-00065b896488") == UUID_TYPE_TIME ? "OK\n" : "Failure\n";
echo uuid_type("878b258c-a9f1-467c-8e1d-47d79ca2c01b") == UUID_TYPE_RANDOM ? "OK\n" : "Failure\n";
echo uuid_type("00000000-0000-0000-0000-000000000000") == UUID_TYPE_NULL ? "OK\n" : "Failure\n";
?>
--EXPECT--
OK
OK
OK
uuid_parse.phpt 0000644 00000000335 15045601222 0007577 0 ustar 00 --TEST--
uuid_parse() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
var_dump(uuid_parse("61616161-6161-6161-6161-616161616161"));
?>
--EXPECT--
string(16) "aaaaaaaaaaaaaaaa"
uuid_generate_sha1.phpt 0000644 00000001331 15045601222 0011170 0 ustar 00 --TEST--
uuid_generate_sha1() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
if(!function_exists('uuid_generate_sha1')) die('skip not compiled in (HAVE_UUID_GENERATE_SHA1)');
?>
--FILE--
<?php
$uuid = uuid_create();
var_dump($uuid);
try {
uuid_generate_sha1("not a uuid", "foo");
} catch (ValueError $e) {
echo $e->getMessage() . "\n"; // PHP 8
}
var_dump($a = uuid_generate_sha1($uuid, "foo"));
var_dump($b = uuid_generate_sha1($uuid, "bar"));
var_dump($a === $b);
var_dump(uuid_type($a) == UUID_TYPE_SHA1);
var_dump(uuid_type($b) == UUID_TYPE_SHA1);
?>
Done
--EXPECTF--
string(36) "%s"
%A Argument #1 ($uuid_ns) UUID expecte%A
string(36) "%s"
string(36) "%s"
bool(false)
bool(true)
bool(true)
Done
uuid_generate_md5.phpt 0000644 00000001414 15045601222 0011023 0 ustar 00 --TEST--
uuid_generate_md5() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
if(!function_exists('uuid_generate_md5')) die('skip not compiled in (HAVE_UUID_GENERATE_MD5)');
?>
--FILE--
<?php
$uuid = uuid_create();
var_dump($uuid);
try {
if (!uuid_generate_md5("not a uuid", "foo")) {
echo "OK\n"; // PHP 7
}
} catch (ValueError $e) {
echo $e->getMessage() . "\n"; // PHP 8
echo "OK\n"; // PHP 8
}
var_dump($a = uuid_generate_md5($uuid, "foo"));
var_dump($b = uuid_generate_md5($uuid, "bar"));
var_dump($a === $b);
var_dump(uuid_type($a) == UUID_TYPE_MD5);
var_dump(uuid_type($b) == UUID_TYPE_MD5);
?>
Done
--EXPECTF--
string(36) "%s"
%A Argument #1 ($uuid_ns) UUID expecte%AOK
string(36) "%s"
string(36) "%s"
bool(false)
bool(true)
bool(true)
Done
uuid_create.phpt 0000644 00000000761 15045601222 0007733 0 ustar 00 --TEST--
uuid_create() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
// check basic format of generated UUIDs
$uuid = uuid_create();
if (preg_match("/[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}/", $uuid)) {
echo "basic format ok\n";
} else {
echo "basic UUID format check failed, generated UUID was $uuid\n";
}
?>
--EXPECT--
basic format ok
uuid_mac.phpt 0000644 00000000664 15045601222 0007232 0 ustar 00 --TEST--
uuid_mac() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
var_dump(uuid_mac("b691c99c-7fc5-11d8-9fa8-00065b896488"));
try {
if (!uuid_mac("878b258c-a9f1-467c-8e1d-47d79ca2c01b")) {
echo "OK\n"; // PHP 7
}
} catch (ValueError $e) {
echo $e->getMessage() . "\n"; // PHP 8
echo "OK\n";
}
?>
--EXPECTF--
string(12) "00065b896488"
%A Argument #1 ($uuid) UUID DCE TIME expecte%AOK
uuid_time.phpt 0000644 00000000631 15045601222 0007422 0 ustar 00 --TEST--
uuid_time() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
var_dump(uuid_time("b691c99c-7fc5-11d8-9fa8-00065b896488"));
try {
if (!uuid_time("878b258c-a9f1-467c-8e1d-47d79ca2c01b")) {
echo "OK\n"; // PHP 7
}
} catch (ValueError $e) {
echo $e->getMessage() . "\n"; // PHP 8
echo "OK\n";
}
?>
--EXPECTF--
int(1080374815)
%A UUID DCE TIME expecte%AOK
uuid_is_valid.phpt 0000644 00000000627 15045601222 0010263 0 ustar 00 --TEST--
uuid_is_valid() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
var_dump(uuid_is_valid("1b4e28ba-2fa1-11d2-883f-b9a761bde3fb"));
var_dump(uuid_is_valid("ffffffff-ffff-ffff-ffff-ffffffffffff"));
var_dump(uuid_is_valid("61616161-6161-6161-6161-616161616161"));
var_dump(uuid_is_valid("foobar"));
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(false)
uuid_unparse.phpt 0000644 00000000341 15045601222 0010137 0 ustar 00 --TEST--
uuid_unparse() function
--SKIPIF--
<?php
if(!extension_loaded('uuid')) die('skip ');
?>
--FILE--
<?php
var_dump(uuid_unparse("aaaaaaaaaaaaaaaa"));
?>
--EXPECT--
string(36) "61616161-6161-6161-6161-616161616161"
060.solrquery_comon_query_params.phpt 0000644 00000003033 15045630371 0014000 0 ustar 00 --TEST--
SolrQuery - testing CommonQueryParameters
--FILE--
<?php
$query = new SolrQuery();
ob_start();
var_dump(
$query->getQuery(),
$query->getTimeAllowed(),
$query->getStart(),
$query->getRows(),
$query->getFields(),
$query->getFilterQueries(),
$query->getSortFields()
);
$nullOutput = ob_get_clean();
$query->setParam('a', 1);
$query->setParam('b', 2);
$query->setParam('c', 3);
$query->setStart(4)->setQuery('solr')->setTimeAllowed(500)->setRows(17);
$query->addField('israel')->addField('joshua')->addField('june');
$query->addSortField('cat', SolrQuery::ORDER_ASC);
$query->addFilterQuery('solr')->addFilterQuery('solr1')->addFilterQuery('solr2');
$query
->setShowDebugInfo(true)
->setExplainOther('id:SOL*')
->setOmitHeader(false)
->setEchoHandler(true)
->setEchoParams('all')
;
echo $query . PHP_EOL . PHP_EOL;
var_dump(
$query->getQuery(),
$query->getTimeAllowed(),
$query->getStart(),
$query->getRows(),
$query->getFields(),
$query->getFilterQueries(),
$query->getSortFields()
);
echo $nullOutput;
?>
--EXPECT--
a=1&b=2&c=3&start=4&q=solr&timeAllowed=500&rows=17&fl=israel,joshua,june&sort=cat asc&fq=solr&fq=solr1&fq=solr2&debugQuery=true&explainOther=id:SOL*&omitHeader=false&echoHandler=true&echoParams=all
string(4) "solr"
int(500)
int(4)
int(17)
array(3) {
[0]=>
string(6) "israel"
[1]=>
string(6) "joshua"
[2]=>
string(4) "june"
}
array(3) {
[0]=>
string(4) "solr"
[1]=>
string(5) "solr1"
[2]=>
string(5) "solr2"
}
array(1) {
[0]=>
string(7) "cat asc"
}
NULL
NULL
NULL
NULL
NULL
NULL
NULL 110.solrdismaxquery.phpt 0000644 00000004003 15045630371 0011215 0 ustar 00 --TEST--
SolrDisMaxQuery - Methods
--FILE--
<?php
$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
->addPhraseField('source', 55)
->addPhraseField('cat', 3, 1)
->addPhraseField('third', 4, 1)
->removePhraseField('third')
->addPhraseField('fourth', 0.5)
->addPhraseField('fifth',5.2, 7.8)
->setQueryAlt('*:*')
->addQueryField("price")
->addQueryField("location", 4)
->setPhraseSlop(2)
->setQueryPhraseSlop(3)
->setTieBreaker(0.5)
->setMinimumMatch(2)
;
// reverse
echo $dismaxQuery.PHP_EOL;
$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
->addQueryField("location", 4)
->addQueryField("price")
->addQueryField("sku")
->addQueryField("title",3.4)
->addPhraseField('cat', 3, 1)
->addPhraseField('third', 4, 1)
->addPhraseField('source', 55)
;
echo $dismaxQuery.PHP_EOL;
$dismaxQuery->setPhraseFields('source^55 cat~1^3');
echo $dismaxQuery.PHP_EOL;
$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery->addPhraseField('first', 3, 1)
->addPhraseField('second', 4, 1)
->addPhraseField('cat', 55);
echo $dismaxQuery. PHP_EOL;
echo $dismaxQuery->removePhraseField('second').PHP_EOL;
$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery->addQueryField('first', 3)
->addQueryField('second', 0.2)
->addQueryField('cat');
echo $dismaxQuery. PHP_EOL;
echo $dismaxQuery->removeQueryField('second').PHP_EOL;
$dismaxQuery = new SolrDisMaxQuery('lucene');
$dismaxQuery->setPhraseSlop(4);
echo $dismaxQuery.PHP_EOL;
?>
--EXPECTF--
q=lucene&defType=%s&pf=source^55 cat~1^3 fourth^0.5 fifth~7.8^5.2&q.alt=*:*&qf=price location^4&ps=2&qs=3&tie=0.5&mm=2
q=lucene&defType=%s&qf=location^4 price sku title^3.4&pf=cat~1^3 third~1^4 source^55
Notice: SolrDisMaxQuery::setPhraseFields(): Parameter pf value(s) was overwritten by this call in %s on line %d
q=lucene&defType=%s&qf=location^4 price sku title^3.4&pf=source^55 cat~1^3
q=lucene&defType=%s&pf=first~1^3 second~1^4 cat^55
q=lucene&defType=%s&pf=first~1^3 cat^55
q=lucene&defType=%s&qf=first^3 second^0.2 cat
q=lucene&defType=%s&qf=first^3 cat
q=lucene&defType=%s&ps=4 019.solrclient_clone.phpt 0000644 00000001240 15045630372 0011311 0 ustar 00 --TEST--
SolrClient::__clone() - expect exception on clone
--SKIPIF--
<?php require_once 'skip.if.server_not_configured.inc'; ?>
--FILE--
<?php
require_once "bootstrap.inc";
$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_SERVER_PATH
);
$client = new SolrClient($options);
try {
$failing = clone $client;
} catch (SolrIllegalOperationException $e) {
echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL;
}
?>
--EXPECTF--
Exception 4001: Cloning of SolrClient objects is currently not supported 150.solrcollapsefunction.phpt 0000644 00000001531 15045630372 0012222 0 ustar 00 --TEST--
SolrCollapseFunction - string conversion
--FILE--
<?php
$func = new SolrCollapseFunction('field');
$func->setField('field2');
$func->setMax('max');
$func->setMin('min');
$func->setSize(1000);
$func->setHint('hint');
$func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
var_dump($func->getField());
var_dump($func->getMax());
var_dump($func->getMin());
var_dump($func->getSize());
var_dump($func->getHint());
var_dump($func->getNullPolicy());
var_dump((string)$func);
$func->setMax('with space');
var_dump((string)$func);
?>
--EXPECTF--
string(6) "field2"
string(3) "max"
string(3) "min"
string(4) "1000"
string(4) "hint"
string(6) "expand"
string(78) "{!collapse field=field2 max=max min=min size=1000 hint=hint nullPolicy=expand}"
string(87) "{!collapse field=field2 max='with space' min=min size=1000 hint=hint nullPolicy=expand}"
062.solrquery_date_facet_parameters.phpt 0000644 00000003704 15045630372 0014407 0 ustar 00 --TEST--
SolrQuery - Testing Date facet parameters
--FILE--
<?php
$query = new SolrQuery();
ob_start();
var_dump(
$query->getFacetDateFields(),
$query->getFacetDateStart(),
$query->getFacetDateStart('june'),
$query->getFacetDateEnd(),
$query->getFacetDateEnd('israel'),
$query->getFacetDateGap(),
$query->getFacetDateGap('june'),
$query->getFacetDateHardEnd(),
$query->getFacetDateHardEnd('june'),
$query->getFacetDateOther(),
$query->getFacetDateOther('june')
);
$nullOutput = ob_get_clean();
$query->addFacetDateField('israel')
->addFacetDateField('israel')
->removeFacetDateField('israel')
;
$query->setFacetDateStart('January')->setFacetDateStart('Feb', 'june');
$query->setFacetDateEnd('Jan')->setFacetDateEnd('Febr', 'israel');
$query->setFacetDateGap('AOL')->setFacetDateGap('YAHOO', 'june');
$query->setFacetDateHardEnd(1)->setFacetDateHardEnd(0,'june');
$query->addFacetDateOther('Google')
->addFacetDateOther('Yahoos','june')
->addFacetDateOther('removeme')
->removeFacetDateOther('removeme');
echo $query. PHP_EOL . PHP_EOL;
var_dump(
$query->getFacetDateFields(),
$query->getFacetDateStart(),
$query->getFacetDateStart('june'),
$query->getFacetDateEnd(),
$query->getFacetDateEnd('israel'),
$query->getFacetDateGap(),
$query->getFacetDateGap('june'),
$query->getFacetDateHardEnd(),
$query->getFacetDateHardEnd('june'),
$query->getFacetDateOther(),
$query->getFacetDateOther('june')
);
echo $nullOutput;
?>
--EXPECTF--
facet.date=israel&facet.date.start=January&f.june.facet.date.start=Feb&facet.date.end=Jan&f.israel.facet.date.end=Febr&facet.date.gap=AOL&f.june.facet.date.gap=YAHOO&facet.date.hardend=true&f.june.facet.date.hardend=false&f.june.facet.date.other=Yahoos
array(1) {
[0]=>
string(6) "israel"
}
string(7) "January"
string(3) "Feb"
string(3) "Jan"
string(4) "Febr"
string(3) "AOL"
string(5) "YAHOO"
bool(true)
bool(false)
NULL
array(1) {
[0]=>
string(6) "Yahoos"
}
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL 080.solrutils_escapequerychars.phpt 0000644 00000000523 15045630372 0013443 0 ustar 00 --TEST--
SolrUtils::escapeQueryChars() - Testing Lucene Reserved Characters
--FILE--
<?php
// + - && || ! ( ) { } [ ] ^ " ~ * ? : \
$queryString = '+a - q{ } [^test] || && () ^ " ~ * ? : \\ /';
$escaped = SolrUtils::escapeQueryChars($queryString);
echo $escaped;
?>
--EXPECTF--
\+a \- q\{ \} \[\^test\] \|| \&& \(\) \^ \" \~ \* \? \: \\ \/ test.config.inc 0000644 00000004070 15045630372 0007470 0 ustar 00 <?php
$serverConfigured = getenv('SOLR_SERVER_CONFIGURED') ? (int)getenv('SOLR_SERVER_CONFIGURED') : false;
define('SOLR_SERVER_CONFIGURED', $serverConfigured);
define('ROOT_DIRECTORY', dirname(__FILE__));
define('EXAMPLE_RESPONSE_XML_1', ROOT_DIRECTORY . '/files/response_xml.1.xml');
define('EXAMPLE_RESPONSE_XML_2', ROOT_DIRECTORY . '/files/response_xml.2.xml');
define('EXAMPLE_RESPONSE_XML_3', ROOT_DIRECTORY . '/files/response_xml.3.xml');
define('EXAMPLE_RESPONSE_XML_4', ROOT_DIRECTORY . '/files/response_xml.4.xml');
define('EXTRACT_FILE_1', ROOT_DIRECTORY . '/files/extract_file.1.pdf');
/* Whether or not to run in secure mode */
define('SOLR_SECURE', false);
/* Domain name of the Solr server */
define('SOLR_SERVER_HOSTNAME', '127.0.0.1');
/* HTTP Port to connection */
define('SOLR_SERVER_PORT', ((SOLR_SECURE) ? 8443 : 8983));
/* SOLR CORE to test on */
define('SOLR_SERVER_PATH', 'solr/collection1');
/* used to test child documents */
define('SOLR_SERVER_STORE_PATH', 'solr/metal_store');
define('SOLR_SERVER_FILES_PATH', 'solr/myfiles');
/* HTTP Basic Authentication Username */
define('SOLR_SERVER_USERNAME', 'admin');
/* HTTP Basic Authentication password */
define('SOLR_SERVER_PASSWORD', 'changeit');
/* HTTP connection timeout */
/* This is maximum time in seconds allowed for the http data transfer operation. Default value is 30 seconds */
define('SOLR_SERVER_TIMEOUT', 10);
/* File name to a PEM-formatted private key + private certificate (concatenated in that order) */
define('SOLR_SSL_CERT', 'certs/combo.pem');
/* File name to a PEM-formatted private certificate only */
define('SOLR_SSL_CERT_ONLY', 'certs/solr.crt');
/* File name to a PEM-formatted private key */
define('SOLR_SSL_KEY', 'certs/solr.key');
/* Password for PEM-formatted private key file */
define('SOLR_SSL_KEYPASSWORD', 'StrongAndSecurePassword');
/* Name of file holding one or more CA certificates to verify peer with*/
define('SOLR_SSL_CAINFO', 'certs/cacert.crt');
/* Name of directory holding multiple CA certificates to verify peer with */
define('SOLR_SSL_CAPATH', 'certs/');
?>
193.solrparams_getparams.phpt 0000644 00000000650 15045630372 0012210 0 ustar 00 --TEST--
SolrParams::getParams()
--FILE--
<?php
$params = new SolrModifiableParams();
$params
->set('q', 'lucene')
->addParam('fq', 'popularity:[10 TO *]')
->addParam('fq', 'section:0')
;
var_dump($params->getParams());
?>
--EXPECT--
array(2) {
["q"]=>
array(1) {
[0]=>
string(6) "lucene"
}
["fq"]=>
array(2) {
[0]=>
string(20) "popularity:[10 TO *]"
[1]=>
string(9) "section:0"
}
} 116.solrdismaxquery_boostfunction.phpt 0000644 00000000525 15045630372 0014205 0 ustar 00 --TEST--
SolrDisMaxQuery - setBoostFunction
--FILE--
<?php
$dismaxQuery = new SolrDisMaxQuery('lucene');
$boostRecentDocsFunction = "recip(ms(NOW,mydatefield),3.16e-11,1,1)";
$dismaxQuery->setBoostFunction($boostRecentDocsFunction);
echo $dismaxQuery.PHP_EOL;
?>
--EXPECTF--
q=lucene&defType=%s&bf=recip(ms(NOW,mydatefield),3.16e-11,1,1) 059.solrinputdocument_set_getfieldboost.phpt 0000644 00000000430 15045630372 0015342 0 ustar 00 --TEST--
SolrInputDocument::getFieldBoost
--FILE--
<?php
require_once "bootstrap.inc";
$doc = new SolrInputDocument();
$doc->addField('id', 123);
$doc->addField('cat', 'Software');
$doc->setFieldBoost('cat', 2.1);
var_dump($doc->getFieldBoost('cat'));
?>
--EXPECT--
float(2.1) 103.solrresponse_get_array_response.phpt 0000644 00000001464 15045630372 0014466 0 ustar 00 --TEST--
SolrResponse::getArrayResponse - For All response writers
--SKIPIF--
<?php
include 'skip.if.server_not_configured.inc';
?>
--FILE--
<?php
require_once "bootstrap.inc";
$options = array (
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_SERVER_PATH,
);
$client = new SolrClient ( $options );
$testArrayResponse = function ($writer) use ($client){
$client->setResponseWriter($writer);
$q = new SolrQuery("lucene");
$response = $client->query ( $q );
$arrayResponse = $response->getArrayResponse();
return is_array($arrayResponse);
};
var_dump($testArrayResponse('phps'));
var_dump($testArrayResponse('xml'));
var_dump($testArrayResponse('json'));
?>
--EXPECTF--
bool(true)
bool(true)
bool(true) 106.solrresponse_child_doc_response_solrdoc.phpt 0000644 00000005624 15045630372 0016153 0 ustar 00 --TEST--
SolrDocument - Response parsed as SolrDocument with child documents
--FILE--
<?php
require_once "bootstrap.inc";
$fixtureXml = file_get_contents(EXAMPLE_RESPONSE_XML_2);
$response = SolrUtils::digestXmlResponse($fixtureXml, SolrResponse::PARSE_SOLR_DOC);
foreach($response->response->docs as $doc)
{
echo '--- doc start ---'.PHP_EOL;
print_r($doc->toArray());
if ($doc->hasChildDocuments())
{
foreach ($doc->getChildDocuments() as $child)
{
print_r($child->toArray());
}
}
echo '--- doc end ---'.PHP_EOL;
}
?>
--EXPECT--
--- doc start ---
Array
(
[document_boost] => 0
[field_count] => 1
[fields] => Array
(
[0] => SolrDocumentField Object
(
[name] => id
[boost] => 0
[values] => Array
(
[0] => parent_1
)
)
)
)
Array
(
[document_boost] => 0
[field_count] => 1
[fields] => Array
(
[0] => SolrDocumentField Object
(
[name] => id
[boost] => 0
[values] => Array
(
[0] => CHILD_1_1
)
)
)
)
--- doc end ---
--- doc start ---
Array
(
[document_boost] => 0
[field_count] => 1
[fields] => Array
(
[0] => SolrDocumentField Object
(
[name] => id
[boost] => 0
[values] => Array
(
[0] => parent_2
)
)
)
)
Array
(
[document_boost] => 0
[field_count] => 1
[fields] => Array
(
[0] => SolrDocumentField Object
(
[name] => id
[boost] => 0
[values] => Array
(
[0] => CHILD_2_1
)
)
)
)
Array
(
[document_boost] => 0
[field_count] => 1
[fields] => Array
(
[0] => SolrDocumentField Object
(
[name] => id
[boost] => 0
[values] => Array
(
[0] => CHILD_2_2
)
)
)
)
--- doc end ---
--- doc start ---
Array
(
[document_boost] => 0
[field_count] => 1
[fields] => Array
(
[0] => SolrDocumentField Object
(
[name] => id
[boost] => 0
[values] => Array
(
[0] => not_a_parent_1
)
)
)
)
--- doc end ---
007.solrclient_deleteByIds.phpt 0000644 00000002166 15045630372 0012413 0 ustar 00 --TEST--
SolrClient::deleteByIds() - Test deleting documents by an array of IDS
--SKIPIF--
<?php
include 'skip.if.server_not_configured.inc';
?>
--FILE--
<?php
require_once "bootstrap.inc";
$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_SERVER_PATH
);
$client = new SolrClient($options);
$response = $client->deleteByIds(array('334455','334456'));
$client->commit();
print_r($response->getResponse());
try {
$client->deleteByIds(array(0));
} catch (SolrIllegalArgumentException $e) {
echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()). PHP_EOL;
}
try {
$client->deleteByIds(array('334455', ''));
} catch (SolrIllegalArgumentException $e) {
echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()). PHP_EOL;
}
?>
--EXPECTF--
SolrObject Object
(
[responseHeader] => SolrObject Object
(
[status] => %d
[QTime] => %d
)
)
Exception 4000: Id number 1 is not a valid string
Exception 4000: Id number 2 is not a valid string 016.solrclient_sendUpdateStream_file.phpt 0000644 00000001774 15045630372 0014471 0 ustar 00 --TEST--
SolrClient::sendUpdateStream - send SolrExtractRequest (file)
--SKIPIF--
<?php require_once 'skip.if.server_not_configured.inc'; ?>
--FILE--
<?php
require_once "bootstrap.inc";
$options = array (
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_SERVER_FILES_PATH,
);
$client = new SolrClient($options);
$extractParams = new SolrModifiableParams();
$extractParams
->set(SolrExtractRequest::LITERALS_PREFIX . 'id', 'doc1')
->set(SolrExtractRequest::CAPTURE_ELEMENTS, 'p')
->set(SolrExtractRequest::FIELD_MAPPING_PREFIX . 'p', 'text')
;
$extractRequest = SolrExtractRequest::createFromFile(EXTRACT_FILE_1, $extractParams);
$response = $client->sendUpdateStream($extractRequest);
$client->rollback();
echo $response->getHttpStatus() . PHP_EOL;
echo $response->getRequestUrl() . PHP_EOL;
?>
--EXPECTF--
200
http://%s/update/extract/?version=2.2&indent=on&wt=xml&literal.id=doc1&capture=p&fmap.p=text
056.solrinputdocument_toArray.phpt 0000644 00000001611 15045630372 0013255 0 ustar 00 --TEST--
SolrInputDocument::toArray - Array conversion
--FILE--
<?php
require_once "bootstrap.inc";
$doc = new SolrInputDocument();
$doc->addField('field_1', 4, 3.4);
$doc->addField('field_2', 1);
print_r($doc->toArray());
?>
--EXPECT--
Array
(
[document_boost] => 0
[field_count] => 2
[fields] => Array
(
[0] => SolrDocumentField Object
(
[name] => field_1
[boost] => 3.4
[values] => Array
(
[0] => 4
)
)
[1] => SolrDocumentField Object
(
[name] => field_2
[boost] => 0
[values] => Array
(
[0] => 1
)
)
)
)
053.solrinputdocument_getchilddocumentscount.phpt 0000644 00000001112 15045630372 0016403 0 ustar 00 --TEST--
SolrInputDocument::getChildDocumentsCount() - test
--FILE--
<?php
require_once "bootstrap.inc";
$doc = new SolrInputDocument();
$secondDoc = new SolrInputDocument();
$doc->addField('id', 1123);
$doc->addField('features', "PHP Client Side");
$doc->addField('features', "Fast development cycles");
$doc->cat = 'Information Technology';
$secondDoc->addField('cat', 'Lucene Search');
$secondDoc->cat = 'Custom Search';
$doc->addChildDocument($secondDoc);
var_dump($doc->getChildDocumentsCount());
var_dump($secondDoc->getChildDocumentsCount());
?>
--EXPECT--
int(1)
int(0) bug_70495.phpt 0000644 00000001746 15045630372 0007003 0 ustar 00 --TEST--
Solr Bug #70495 - Failed to parse 500 error response when Solr it lacks msg JSON RW
--SKIPIF--
<?php require_once 'skip.if.server_not_configured.inc'; ?>
--FILE--
<?php
require_once "bootstrap.inc";
$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_SERVER_PATH,
'wt' => 'json'
);
$client = new SolrClient($options);
$query = new SolrQuery('*:*');
$func = new SolrCollapseFunction('manu_id_s');
$func->setMax('sum(cscore(),field(manu_id_s))');
$func->setSize(100);
$func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
$query->collapse($func);
try {
$queryResponse = $client->query($query);
} catch (SolrServerException $e) {
printf("Exception code %d", $e->getCode());
assert(strlen($e->getMessage()) > 0, 'Exception message is empty');
}
?>
OK
--EXPECTF--
Exception code 500
OK 021.solrdocument_iterator.phpt 0000644 00000001766 15045630372 0012410 0 ustar 00 --TEST--
SolrDocument - checking Iterator interface implementation
--FILE--
<?php
require_once "bootstrap.inc";
$doc = new SolrDocument();
$doc->addField('id', 1123);
$doc->features = "PHP Client Side";
$doc->features = "Fast development cycles";
$doc['cat'] = 'Software';
$doc['cat'] = 'Custom Search';
$doc->cat = 'Information Technology';
foreach ($doc as $fieldname => $fieldvalues)
{
print "$fieldname\n";
print_r($fieldvalues);
}
?>
--EXPECT--
id
SolrDocumentField Object
(
[name] => id
[boost] => 0
[values] => Array
(
[0] => 1123
)
)
features
SolrDocumentField Object
(
[name] => features
[boost] => 0
[values] => Array
(
[0] => PHP Client Side
[1] => Fast development cycles
)
)
cat
SolrDocumentField Object
(
[name] => cat
[boost] => 0
[values] => Array
(
[0] => Software
[1] => Custom Search
[2] => Information Technology
)
)
008.solrclient_rollback.phpt 0000644 00000001051 15045630372 0012000 0 ustar 00 --TEST--
SolrClient::rollback() - Testing rollback
--SKIPIF--
<?php
include 'skip.if.server_not_configured.inc';
?>
--FILE--
<?php
require_once "bootstrap.inc";
$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_SERVER_PATH
);
$client = new SolrClient($options);
$updateResponse = $client->rollback();
print $updateResponse->getRawRequest();
?>
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<rollback/>