From d0d062b4a05a9eb64b8d2e6d038af96ac532e4b3 Mon Sep 17 00:00:00 2001 From: valmat Date: Thu, 27 Mar 2014 01:19:12 +0600 Subject: Added new tests. Due to support zts broke the ability to run tests without installation - fixed. --- tests/php/dbg.php | 45 ------ tests/php/phpt/valueiterator/006.phpt | 21 --- tests/php/phpt/valueiterator/006.phpt- | 21 +++ tests/php/phpt/variables/001-process_globals.phpt- | 47 ++++++ .../php/phpt/variables/002-get_complex_array.phpt- | 33 ++++ tests/php/phpt/variables/003-value-types.phpt- | 72 +++++++++ .../phpt/variables/004-store-scalar-variables.phpt | 58 +++++++ .../variables/005-value-casting-operators.phpt- | 174 +++++++++++++++++++++ tests/php/phpt/variables/006-casting-obj2str.phpt | 31 ++++ .../phpt/variables/007-overloaded-operators.phpt | 51 ++++++ tests/php/phpt/variables/008-value-arrays.phpt- | 89 +++++++++++ tests/php/phpt/variables/009-value-object.phpt- | 24 +++ tests/php/phpt/variables/010-value-object2.phpt | 24 +++ tests/php/phpt/variables/readme | 1 + 14 files changed, 625 insertions(+), 66 deletions(-) delete mode 100644 tests/php/phpt/valueiterator/006.phpt create mode 100644 tests/php/phpt/valueiterator/006.phpt- create mode 100644 tests/php/phpt/variables/001-process_globals.phpt- create mode 100644 tests/php/phpt/variables/002-get_complex_array.phpt- create mode 100644 tests/php/phpt/variables/003-value-types.phpt- create mode 100644 tests/php/phpt/variables/004-store-scalar-variables.phpt create mode 100644 tests/php/phpt/variables/005-value-casting-operators.phpt- create mode 100644 tests/php/phpt/variables/006-casting-obj2str.phpt create mode 100644 tests/php/phpt/variables/007-overloaded-operators.phpt create mode 100644 tests/php/phpt/variables/008-value-arrays.phpt- create mode 100644 tests/php/phpt/variables/009-value-object.phpt- create mode 100644 tests/php/phpt/variables/010-value-object2.phpt create mode 100644 tests/php/phpt/variables/readme (limited to 'tests/php') diff --git a/tests/php/dbg.php b/tests/php/dbg.php index 6f1dabc..9a28fc6 100644 --- a/tests/php/dbg.php +++ b/tests/php/dbg.php @@ -6,51 +6,6 @@ */ -function out($obj) { - - - $cl_name = is_object($obj) ? - get_class($obj) : - (is_array($obj) ? "Array" : "----"); - - echo "++++-" , $cl_name , "-++++\n"; - - echo "\x1b[1;31m"; - echo "\n Native iterate:\n\n"; - foreach($obj as $k => $v) { - echo "$k\t=>\t$v\n"; - } - echo "\x1b[0m"; - - - TestValueIterator\loopValue($obj); -} - - - -require './include/valueiterator/1.php'; - -#$arr = array('qwe' => 'qweqweqweqw',5,'asd' => '«£¥§©®°±¶⅐⅒⅓⅘⅞Ⅻↆ❄❅❆⚑⚐⌛⌚〰»', 'zxccvx' => 'sdfsecvyh6bug6yfty',); -#$obj = (object)$arr; -#$smpl = new SimpleClass; -#$it = new impIterator; -#$iag1 = new impIterAggr1; -$iag2 = new impIterAggr2; - - -//out($arr); -#out($obj); -#out($smpl); -TestValueIterator\loopValue($iag2); -#out($it); -#out($iag1); -#out($iag2); - - - - - - diff --git a/tests/php/phpt/valueiterator/006.phpt b/tests/php/phpt/valueiterator/006.phpt deleted file mode 100644 index ea97c2b..0000000 --- a/tests/php/phpt/valueiterator/006.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Iterate itarable oblect ---DESCRIPTION-- -class impIterAggr1 implements IteratorAggregate ---SKIPIF-- - ---FILEEOF-- - +--FILEEOF-- + +--SKIPIF-- + +--FILEEOF-- + +--FILEEOF-- + 123, + "b" => 456, + "c" => array("nested_value","example",7) + ); +} +var_export(get_complex_array()); +*/ +var_export(TestVariables\get_complex_array()); + + +echo PHP_EOL; +--EXPECT-- +array ( + 'a' => 123, + 'b' => 456, + 'c' => + array ( + 0 => 'nested_value', + 1 => 'example', + 2 => 7, + ), +) \ No newline at end of file diff --git a/tests/php/phpt/variables/003-value-types.phpt- b/tests/php/phpt/variables/003-value-types.phpt- new file mode 100644 index 0000000..477fbe2 --- /dev/null +++ b/tests/php/phpt/variables/003-value-types.phpt- @@ -0,0 +1,72 @@ +--TEST-- +get_complex_array +--SKIPIF-- + +--FILEEOF-- + NULL, + 'Numeric' => 2014, + 'Float' => 3.14, + 'Bool' => true, + 'Array' => array(5,'a' => 33, 'str'), + 'Object' => new stdClass(), + 'String' => 'String', + 'Resource' => 7, + 'Constant' => 5, + 'ConstantArray' => 11, + 'Callable1' => 'ret5', + 'Callable2' => $methodVariable, + 'Callable3' => function () {return 5;}, + 'Callable4' => new CallableClass() +); + +TestVariables\value_types($arr); + +//To check uncomment the following lines: +/* +echo "\n\nCallable1:"; +var_export(is_callable($arr['Callable1'])); +echo PHP_EOL,'Callable2:'; +var_export(is_callable($arr['Callable2'])); +echo PHP_EOL,'Callable3:'; +var_export(is_callable($arr['Callable3'])); +echo PHP_EOL,'Callable4:'; +var_export(is_callable($arr['Callable4'])); +echo PHP_EOL,'No Callable:'; +var_export(is_callable(new stdClass)); +*/ + + +echo PHP_EOL; +--EXPECT-- +Null: Yes +Numeric: Yes +Float: Yes +Bool: Yes +Array: Yes +Object: Yes +String: Yes +Resource: No +Constant: No +ConstantArray: No +Callable1: Yes +Callable2: Yes +Callable3: Yes +Callable4: Yes \ No newline at end of file diff --git a/tests/php/phpt/variables/004-store-scalar-variables.phpt b/tests/php/phpt/variables/004-store-scalar-variables.phpt new file mode 100644 index 0000000..53cc681 --- /dev/null +++ b/tests/php/phpt/variables/004-store-scalar-variables.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test variables defined in PHP-CPP +--DESCRIPTION-- +in PHP-CPP: +Php::Value scalar_store(void) { + + Php::Value value1 = 1234; + Php::Value value2 = "this is a string"; + Php::Value value3 = std::string("another string"); + Php::Value value4 = nullptr; + Php::Value value5 = 123.45; + Php::Value value6 = true; + + Php::Value r; + r[0] = value1; + r[1] = value2; + r[2] = value3; + r[3] = value4; + r[4] = value5; + r[5] = value6; + + r[6] = 1234; + r[7] = "this is a string"; + r[8] = std::string("another string"); + r[9] = nullptr; // NULL + r[10] = Php::Value(); // NULL + r[11] = 123.45; + r[12] = false; + + return r; +} + +--SKIPIF-- + +--FILEEOF-- + 1234, + 1 => 'this is a string', + 2 => 'another string', + 3 => NULL, + 4 => 123.45, + 5 => true, + 6 => 1234, + 7 => 'this is a string', + 8 => 'another string', + 9 => NULL, + 10 => NULL, + 11 => 123.45, + 12 => false, +) diff --git a/tests/php/phpt/variables/005-value-casting-operators.phpt- b/tests/php/phpt/variables/005-value-casting-operators.phpt- new file mode 100644 index 0000000..5e0fb8e --- /dev/null +++ b/tests/php/phpt/variables/005-value-casting-operators.phpt- @@ -0,0 +1,174 @@ +--TEST-- +Test Php::Value casting operators +--DESCRIPTION-- +The Php::Value class has casting operators to cast the object to almost every thinkable native type. + + +It seems need to replace double on long double + +native_value_casting - repeats the behavior of c++ functions TestVariables\value_casting +the output of each of these functions should be the same + + +--SKIPIF-- + +--FILEEOF-- + +--FILEEOF-- + +--FILEEOF-- + 100 +130 +122 +16048.5 +1.05306 +-990 +-998 +-122216 +-8.01944 +value == 'some string' +10 +2 +1234.5 +0.0810045 \ No newline at end of file diff --git a/tests/php/phpt/variables/008-value-arrays.phpt- b/tests/php/phpt/variables/008-value-arrays.phpt- new file mode 100644 index 0000000..6950780 --- /dev/null +++ b/tests/php/phpt/variables/008-value-arrays.phpt- @@ -0,0 +1,89 @@ +--TEST-- +Test Php::Value arrays +--DESCRIPTION-- +--SKIPIF-- + +--FILEEOF-- + + array ( + 0 => 'apple', + 1 => 'banana', + 2 => 'tomato', + ), + 'filled' => + array ( + 0 => 'a', + 1 => 'b', + 2 => 'c', + 3 => 'd', + ), + 'assoc' => + array ( + 'apple' => 'green', + 'banana' => 'yellow', + 'tomato' => 'green', + ), + 'assoc2' => + array ( + 'x' => 'info@example.com', + 'y' => NULL, + 'z' => 123, + ), + 'assoc3' => + array ( + 'x' => 'info@example.com', + 'y' => NULL, + 'z' => + array ( + 0 => 'a', + 1 => 'b', + 2 => 'c', + ), + ), +) \ No newline at end of file diff --git a/tests/php/phpt/variables/009-value-object.phpt- b/tests/php/phpt/variables/009-value-object.phpt- new file mode 100644 index 0000000..c45cae8 --- /dev/null +++ b/tests/php/phpt/variables/009-value-object.phpt- @@ -0,0 +1,24 @@ +--TEST-- +Test Php::Value object #1 +--DESCRIPTION-- + create empty object of type stdClass + object properties can be accessed with square brackets +--SKIPIF-- + +--FILEEOF-- + "value1", "property2" => "value2"); + +var_export($object); + + + +--EXPECT-- +stdClass::__set_state(array( + 'property1' => 'value1', + 'property2' => 'value2', +)) \ No newline at end of file diff --git a/tests/php/phpt/variables/010-value-object2.phpt b/tests/php/phpt/variables/010-value-object2.phpt new file mode 100644 index 0000000..8697a69 --- /dev/null +++ b/tests/php/phpt/variables/010-value-object2.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test Php::Value object #2 +--DESCRIPTION-- + create empty object of type stdClass + object properties can be accessed with square brackets +--SKIPIF-- + +--FILEEOF-- + '2014-03-27 00:37:15', + 'timezone_type' => 3, + 'timezone' => 'Europe/Amsterdam', +)) \ No newline at end of file diff --git a/tests/php/phpt/variables/readme b/tests/php/phpt/variables/readme new file mode 100644 index 0000000..8162526 --- /dev/null +++ b/tests/php/phpt/variables/readme @@ -0,0 +1 @@ +tests variables -- cgit v1.2.3