From aec191bc6cbb83884466800a750ecad0b37e254f Mon Sep 17 00:00:00 2001
From: Emiel Bruijntjes
Date: Thu, 5 Nov 2015 10:25:57 +0100
Subject: [PATCH] remove test framework, it never works, most of the bugs found
by the test framework turn out to be caused by errors in the tests instead of
errors in the real code, people complain about it all the time, and basically
this whole test framework causes more problems than it solves, solves issue
#215 and solves issue #221
---
Makefile | 16 -
tests/cpp/Makefile | 139 -
tests/cpp/h/Classes_and_objects.h | 14 -
tests/cpp/h/ValueIterator.h | 8 -
tests/cpp/h/ini_entries.h | 16 -
tests/cpp/h/variables.h | 37 -
tests/cpp/include/bool2str.h | 12 -
tests/cpp/include/class_obj/001-002.h | 66 -
tests/cpp/include/class_obj/003-comparable.h | 74 -
.../cpp/include/class_obj/004-static-funct.h | 90 -
tests/cpp/include/class_obj/tpl.h | 25 -
tests/cpp/include/doubl2str.h | 15 -
tests/cpp/include/ini_entries/001.h | 31 -
tests/cpp/include/valueiterator/001-006.h | 27 -
tests/cpp/include/valueiterator/007.h | 44 -
.../include/variables/001-process_globals.h | 57 -
.../include/variables/002-get_complex_array.h | 35 -
tests/cpp/include/variables/003-value-types.h | 37 -
.../variables/004-store-scalar-variables.h | 48 -
.../variables/005-cast-objects-to-scalars.h | 75 -
.../include/variables/006-casting-obj2str.h | 30 -
.../variables/007-overloaded-operators.h | 46 -
.../cpp/include/variables/008-value-arrays.h | 57 -
.../include/variables/009-010-value-object.h | 68 -
.../011-012-value-casting-operators.h | 52 -
.../variables/013-018-calling-php-functions.h | 117 -
.../cpp/include/variables/019-HashMember-1.h | 33 -
.../cpp/include/variables/020-HashMember-2.h | 41 -
.../cpp/include/variables/021-HashMember-3.h | 41 -
.../cpp/include/variables/022-HashMember-4.h | 65 -
tests/cpp/include/variables/023-cookie.h | 31 -
tests/cpp/include/variables/024-get-post.h | 38 -
tests/cpp/include/variables/025-post-raw1.h | 41 -
tests/cpp/include/variables/026-post-raw2.h | 76 -
tests/cpp/include/variables/027-env.h | 26 -
tests/cpp/include/variables/028-029-compare.h | 194 --
tests/cpp/include/variables/tpl.h | 29 -
tests/cpp/main.cpp | 179 --
tests/cpp/readme | 2 -
tests/include/.gitignore | 3 -
tests/include/zts/.gitignore | 1 -
tests/php/dbg.php | 57 -
tests/php/include/valueiterator/1.php | 76 -
tests/php/php_alias.sh | 19 -
tests/php/phpt/.gitignore | 14 -
tests/php/phpt/class_obj/001.phpt | 14 -
tests/php/phpt/class_obj/002.phpt | 14 -
tests/php/phpt/class_obj/003-comparable.phpt | 46 -
.../php/phpt/class_obj/004-static-funct.phpt | 26 -
tests/php/phpt/class_obj/005-static-prop.phpt | 32 -
tests/php/phpt/class_obj/readme | 1 -
tests/php/phpt/ini_entries/001.phpt | 19 -
tests/php/phpt/ini_entries/002.phpt | 69 -
tests/php/phpt/ini_entries/003.phpt | 27 -
tests/php/phpt/valueiterator/001.phpt | 21 -
tests/php/phpt/valueiterator/002.phpt | 22 -
tests/php/phpt/valueiterator/003.phpt | 18 -
tests/php/phpt/valueiterator/004.phpt | 20 -
tests/php/phpt/valueiterator/005.phpt | 19 -
tests/php/phpt/valueiterator/006.phpt | 21 -
.../007-Iterate-internal-array.phpt | 15 -
tests/php/phpt/valueiterator/readme | 1 -
.../phpt/variables/001-process_globals.phpt | 47 -
.../phpt/variables/002-get_complex_array.phpt | 33 -
tests/php/phpt/variables/003-value-types.phpt | 72 -
.../variables/004-store-scalar-variables.phpt | 58 -
.../005-cast-objects-to-scalars.phpt | 22 -
.../phpt/variables/006-casting-obj2str.phpt | 31 -
.../variables/007-overloaded-operators.phpt | 51 -
.../php/phpt/variables/008-value-arrays.phpt | 89 -
.../php/phpt/variables/009-value-object.phpt | 24 -
.../php/phpt/variables/010-value-object2.phpt | 24 -
.../011-value-casting-operators.phpt | 153 -
.../012-value-casting-operators-double.phpt | 80 -
.../variables/013-calling-php-functions.phpt | 113 -
.../variables/014-calling-php-functions.phpt | 113 -
.../variables/015-calling-php-functions.phpt | 109 -
.../variables/016-calling-php-functions.phpt | 113 -
.../variables/017-calling-php-functions.phpt | 115 -
.../variables/018-calling-php-functions.phpt | 32 -
.../php/phpt/variables/019-HashMember-1.phpt | 27 -
.../php/phpt/variables/020-HashMember-2.phpt | 76 -
.../php/phpt/variables/021-HashMember-3.phpt | 26 -
.../php/phpt/variables/022-HashMember-4.phpt | 37 -
tests/php/phpt/variables/023-cookie.phpt | 16 -
tests/php/phpt/variables/024-get-post.phpt | 26 -
tests/php/phpt/variables/025-post-raw1.phpt | 27 -
tests/php/phpt/variables/026-post-raw2.phpt | 38 -
tests/php/phpt/variables/027-env.phpt | 25 -
tests/php/phpt/variables/028-compare1.phpt | 53 -
tests/php/phpt/variables/029-compare2.phpt | 74 -
tests/php/phpt/variables/readme | 5 -
tests/php/readme | 9 -
tests/prepare.sh | 51 -
tests/readme | 7 -
tests/run-tests.php | 2840 -----------------
tests/test.sh | 184 --
97 files changed, 7387 deletions(-)
delete mode 100644 tests/cpp/Makefile
delete mode 100644 tests/cpp/h/Classes_and_objects.h
delete mode 100644 tests/cpp/h/ValueIterator.h
delete mode 100644 tests/cpp/h/ini_entries.h
delete mode 100644 tests/cpp/h/variables.h
delete mode 100644 tests/cpp/include/bool2str.h
delete mode 100644 tests/cpp/include/class_obj/001-002.h
delete mode 100644 tests/cpp/include/class_obj/003-comparable.h
delete mode 100644 tests/cpp/include/class_obj/004-static-funct.h
delete mode 100644 tests/cpp/include/class_obj/tpl.h
delete mode 100644 tests/cpp/include/doubl2str.h
delete mode 100644 tests/cpp/include/ini_entries/001.h
delete mode 100644 tests/cpp/include/valueiterator/001-006.h
delete mode 100644 tests/cpp/include/valueiterator/007.h
delete mode 100644 tests/cpp/include/variables/001-process_globals.h
delete mode 100644 tests/cpp/include/variables/002-get_complex_array.h
delete mode 100644 tests/cpp/include/variables/003-value-types.h
delete mode 100644 tests/cpp/include/variables/004-store-scalar-variables.h
delete mode 100644 tests/cpp/include/variables/005-cast-objects-to-scalars.h
delete mode 100644 tests/cpp/include/variables/006-casting-obj2str.h
delete mode 100644 tests/cpp/include/variables/007-overloaded-operators.h
delete mode 100644 tests/cpp/include/variables/008-value-arrays.h
delete mode 100644 tests/cpp/include/variables/009-010-value-object.h
delete mode 100644 tests/cpp/include/variables/011-012-value-casting-operators.h
delete mode 100644 tests/cpp/include/variables/013-018-calling-php-functions.h
delete mode 100644 tests/cpp/include/variables/019-HashMember-1.h
delete mode 100644 tests/cpp/include/variables/020-HashMember-2.h
delete mode 100644 tests/cpp/include/variables/021-HashMember-3.h
delete mode 100644 tests/cpp/include/variables/022-HashMember-4.h
delete mode 100644 tests/cpp/include/variables/023-cookie.h
delete mode 100644 tests/cpp/include/variables/024-get-post.h
delete mode 100644 tests/cpp/include/variables/025-post-raw1.h
delete mode 100644 tests/cpp/include/variables/026-post-raw2.h
delete mode 100644 tests/cpp/include/variables/027-env.h
delete mode 100644 tests/cpp/include/variables/028-029-compare.h
delete mode 100644 tests/cpp/include/variables/tpl.h
delete mode 100644 tests/cpp/main.cpp
delete mode 100644 tests/cpp/readme
delete mode 100644 tests/include/.gitignore
delete mode 100644 tests/include/zts/.gitignore
delete mode 100644 tests/php/dbg.php
delete mode 100644 tests/php/include/valueiterator/1.php
delete mode 100755 tests/php/php_alias.sh
delete mode 100644 tests/php/phpt/.gitignore
delete mode 100644 tests/php/phpt/class_obj/001.phpt
delete mode 100644 tests/php/phpt/class_obj/002.phpt
delete mode 100644 tests/php/phpt/class_obj/003-comparable.phpt
delete mode 100644 tests/php/phpt/class_obj/004-static-funct.phpt
delete mode 100644 tests/php/phpt/class_obj/005-static-prop.phpt
delete mode 100644 tests/php/phpt/class_obj/readme
delete mode 100644 tests/php/phpt/ini_entries/001.phpt
delete mode 100644 tests/php/phpt/ini_entries/002.phpt
delete mode 100644 tests/php/phpt/ini_entries/003.phpt
delete mode 100644 tests/php/phpt/valueiterator/001.phpt
delete mode 100644 tests/php/phpt/valueiterator/002.phpt
delete mode 100644 tests/php/phpt/valueiterator/003.phpt
delete mode 100644 tests/php/phpt/valueiterator/004.phpt
delete mode 100644 tests/php/phpt/valueiterator/005.phpt
delete mode 100644 tests/php/phpt/valueiterator/006.phpt
delete mode 100644 tests/php/phpt/valueiterator/007-Iterate-internal-array.phpt
delete mode 100644 tests/php/phpt/valueiterator/readme
delete mode 100644 tests/php/phpt/variables/001-process_globals.phpt
delete mode 100644 tests/php/phpt/variables/002-get_complex_array.phpt
delete mode 100644 tests/php/phpt/variables/003-value-types.phpt
delete mode 100644 tests/php/phpt/variables/004-store-scalar-variables.phpt
delete mode 100644 tests/php/phpt/variables/005-cast-objects-to-scalars.phpt
delete mode 100644 tests/php/phpt/variables/006-casting-obj2str.phpt
delete mode 100644 tests/php/phpt/variables/007-overloaded-operators.phpt
delete mode 100644 tests/php/phpt/variables/008-value-arrays.phpt
delete mode 100644 tests/php/phpt/variables/009-value-object.phpt
delete mode 100644 tests/php/phpt/variables/010-value-object2.phpt
delete mode 100644 tests/php/phpt/variables/011-value-casting-operators.phpt
delete mode 100644 tests/php/phpt/variables/012-value-casting-operators-double.phpt
delete mode 100644 tests/php/phpt/variables/013-calling-php-functions.phpt
delete mode 100644 tests/php/phpt/variables/014-calling-php-functions.phpt
delete mode 100644 tests/php/phpt/variables/015-calling-php-functions.phpt
delete mode 100644 tests/php/phpt/variables/016-calling-php-functions.phpt
delete mode 100644 tests/php/phpt/variables/017-calling-php-functions.phpt
delete mode 100644 tests/php/phpt/variables/018-calling-php-functions.phpt
delete mode 100644 tests/php/phpt/variables/019-HashMember-1.phpt
delete mode 100644 tests/php/phpt/variables/020-HashMember-2.phpt
delete mode 100644 tests/php/phpt/variables/021-HashMember-3.phpt
delete mode 100644 tests/php/phpt/variables/022-HashMember-4.phpt
delete mode 100644 tests/php/phpt/variables/023-cookie.phpt
delete mode 100644 tests/php/phpt/variables/024-get-post.phpt
delete mode 100644 tests/php/phpt/variables/025-post-raw1.phpt
delete mode 100644 tests/php/phpt/variables/026-post-raw2.phpt
delete mode 100644 tests/php/phpt/variables/027-env.phpt
delete mode 100644 tests/php/phpt/variables/028-compare1.phpt
delete mode 100644 tests/php/phpt/variables/029-compare2.phpt
delete mode 100644 tests/php/phpt/variables/readme
delete mode 100644 tests/php/readme
delete mode 100755 tests/prepare.sh
delete mode 100644 tests/readme
delete mode 100644 tests/run-tests.php
delete mode 100755 tests/test.sh
diff --git a/Makefile b/Makefile
index a2ce8891..d3d0596e 100644
--- a/Makefile
+++ b/Makefile
@@ -20,18 +20,6 @@
PHP_CONFIG = php-config
-#
-# PHP binary file
-#
-# The path to the executable PHP binary file.
-# Need to run tests.
-# You can see the command "whereis -b php"
-# Usually /usr/bin/php
-#
-
-PHP_BIN = $(shell ${PHP_CONFIG} --php-binary)
-
-
#
# Installation directory
#
@@ -230,7 +218,3 @@ install:
sudo ldconfig; \
fi
-test:
- mkdir -p tests/include/zts/phpcpp
- cd tests && ./test.sh -p "${PHP_BIN}"
-
diff --git a/tests/cpp/Makefile b/tests/cpp/Makefile
deleted file mode 100644
index 90b3946f..00000000
--- a/tests/cpp/Makefile
+++ /dev/null
@@ -1,139 +0,0 @@
-#
-# Makefile template
-#
-# This is an example Makefile that can be used by anyone who is building
-# his or her own PHP extensions using the PHP-CPP library.
-#
-# In the top part of this file we have included variables that can be
-# altered to fit your configuration, near the bottom the instructions and
-# dependencies for the compiler are defined. The deeper you get into this
-# file, the less likely it is that you will have to change anything in it.
-#
-
-#
-# Name of your extension
-#
-# This is the name of your extension. Based on this extension name, the
-# name of the library file (name.so) and the name of the config file (name.ini)
-# are automatically generated
-#
-
-NAME = extfortest
-
-
-#
-# Php.ini directories
-#
-# In the past, PHP used a single php.ini configuration file. Today, most
-# PHP installations use a conf.d directory that holds a set of config files,
-# one for each extension. Use this variable to specify this directory.
-#
-
-# in our case it is not required
-#INI_DIR = /etc/php5/conf.d
-
-
-#
-# The extension dirs
-#
-# This is normally a directory like /usr/lib/php5/20121221 (based on the
-# PHP version that you use. We make use of the command line 'php-config'
-# instruction to find out what the extension directory is, you can override
-# this with a different fixed directory
-#
-
-EXTENSION_DIR = $(shell php-config --extension-dir)
-
-
-#
-# The name of the extension and the name of the .ini file
-#
-# These two variables are based on the name of the extension. We simply add
-# a certain extension to them (.so or .ini)
-#
-
-EXTENSION = ${NAME}.so
-# in our case it is not required
-#INI = ${NAME}.ini
-
-
-#
-# Compiler
-#
-# By default, the GNU C++ compiler is used. If you want to use a different
-# compiler, you can change that here. You can change this for both the
-# compiler (the program that turns the c++ files into object files) and for
-# the linker (the program that links all object files into the single .so
-# library file. By default, g++ (the GNU C++ compiler) is used for both.
-#
-
-COMPILER = g++
-LINKER = g++
-
-
-#
-# Compiler and linker flags
-#
-# This variable holds the flags that are passed to the compiler. By default,
-# we include the -O2 flag. This flag tells the compiler to optimize the code,
-# but it makes debugging more difficult. So if you're debugging your application,
-# you probably want to remove this -O2 flag. At the same time, you can then
-# add the -g flag to instruct the compiler to include debug information in
-# the library (but this will make the final libphpcpp.so file much bigger, so
-# you want to leave that flag out on production servers).
-#
-# If your extension depends on other libraries (and it does at least depend on
-# one: the PHP-CPP library), you should update the LINKER_DEPENDENCIES variable
-# with a list of all flags that should be passed to the linker.
-#
-
-LIB_DIR=$(shell cd ../.. && pwd)
-COMPILER_FLAGS = -Wall -c -O2 -std=c++11 -fpic -I"${LIB_DIR}/tests/include/lib" -I"${LIB_DIR}/tests/include/zts" -o
-LINKER_FLAGS = -shared -L"${LIB_DIR}"
-LINKER_DEPENDENCIES = -lphpcpp
-
-
-#
-# Command to remove files, copy files and create directories.
-#
-# I've never encountered a *nix environment in which these commands do not work.
-# So you can probably leave this as it is
-#
-
-RM = rm -f
-CP = cp -f
-MKDIR = mkdir -p
-
-
-#
-# All source files are simply all *.cpp files found in the current directory
-#
-# A builtin Makefile macro is used to scan the current directory and find
-# all source files. The object files are all compiled versions of the source
-# file, with the .cpp extension being replaced by .o.
-#
-
-SOURCES = $(wildcard *.cpp)
-OBJECTS = $(SOURCES:%.cpp=%.o)
-
-
-#
-# From here the build instructions start
-#
-
-all: ${OBJECTS} ${EXTENSION}
-
-${EXTENSION}: ${OBJECTS}
- ${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES}
-
-${OBJECTS}:
- ${COMPILER} ${COMPILER_FLAGS} $@ ${@:%.o=%.cpp}
-
-# Do not install this extension
-#install:
-# ${CP} ${EXTENSION} ${EXTENSION_DIR}
-# ${CP} ${INI} ${INI_DIR}
-
-clean:
- ${RM} ${EXTENSION} ${OBJECTS}
-
diff --git a/tests/cpp/h/Classes_and_objects.h b/tests/cpp/h/Classes_and_objects.h
deleted file mode 100644
index 8404c69c..00000000
--- a/tests/cpp/h/Classes_and_objects.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- *
- *
- * Classes_and_objects.h
- *
- */
-
-#include "../include/class_obj/001-002.h"
-#include "../include/class_obj/003-comparable.h"
-#include "../include/class_obj/004-static-funct.h"
-//#include "../include/class_obj/.h"
-//#include "../include/class_obj/.h"
-//#include "../include/class_obj/.h"
-
diff --git a/tests/cpp/h/ValueIterator.h b/tests/cpp/h/ValueIterator.h
deleted file mode 100644
index b4300082..00000000
--- a/tests/cpp/h/ValueIterator.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- * TestValueIterator
- *
- */
-
-#include "../include/valueiterator/001-006.h"
-#include "../include/valueiterator/007.h"
diff --git a/tests/cpp/h/ini_entries.h b/tests/cpp/h/ini_entries.h
deleted file mode 100644
index a6fb10e5..00000000
--- a/tests/cpp/h/ini_entries.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- *
- * Test ini entries
- *
- */
-
-
-#include "../include/ini_entries/001.h"
-//#include "../include/ini_entries/.h"
-//#include "../include/ini_entries/.h"
-
-
-
-
-
-
diff --git a/tests/cpp/h/variables.h b/tests/cpp/h/variables.h
deleted file mode 100644
index 0b684ddc..00000000
--- a/tests/cpp/h/variables.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- * Test variables
- *
- */
-
-#include "../include/doubl2str.h"
-#include "../include/bool2str.h"
-
-#include "../include/variables/001-process_globals.h"
-#include "../include/variables/002-get_complex_array.h"
-#include "../include/variables/003-value-types.h"
-#include "../include/variables/004-store-scalar-variables.h"
-#include "../include/variables/005-cast-objects-to-scalars.h"
-#include "../include/variables/006-casting-obj2str.h"
-#include "../include/variables/007-overloaded-operators.h"
-#include "../include/variables/008-value-arrays.h"
-#include "../include/variables/009-010-value-object.h"
-#include "../include/variables/011-012-value-casting-operators.h"
-#include "../include/variables/013-018-calling-php-functions.h"
-#include "../include/variables/019-HashMember-1.h"
-#include "../include/variables/020-HashMember-2.h"
-#include "../include/variables/021-HashMember-3.h"
-#include "../include/variables/022-HashMember-4.h"
-#include "../include/variables/023-cookie.h"
-#include "../include/variables/024-get-post.h"
-#include "../include/variables/025-post-raw1.h"
-#include "../include/variables/026-post-raw2.h"
-#include "../include/variables/027-env.h"
-#include "../include/variables/028-029-compare.h"
-//#include "../include/variables/.h"
-
-
-
-
-
-
diff --git a/tests/cpp/include/bool2str.h b/tests/cpp/include/bool2str.h
deleted file mode 100644
index 26aac80c..00000000
--- a/tests/cpp/include/bool2str.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- *
- * bool -> string
- *
- */
-
-
-
-std::string bool2str(bool b)
-{
- return b ? "Yes" : "No";
-}
diff --git a/tests/cpp/include/class_obj/001-002.h b/tests/cpp/include/class_obj/001-002.h
deleted file mode 100644
index 2a3b4df6..00000000
--- a/tests/cpp/include/class_obj/001-002.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *
- * Test Classes and objects
- * 001.phpt
- * 002.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestBaseClass {
-
-
- class MyCustomClass : public Php::Base, public Php::Countable
- {
- private:
- int _x = 3;
-
- public:
- MyCustomClass()
- {
- std::cerr << "MyCustomClass::MyCustomClass()" << std::endl;
- }
-
- MyCustomClass(int value) : _x(value)
- {
- std::cerr << "MyCustomClass::MyCustomClass(" << value << ")" << std::endl;
- }
-
- MyCustomClass(const MyCustomClass &that)
- {
- //std::cerr << "MyCustomClass::MyCustomClass copy constructor" << std::endl;
- }
-
- virtual ~MyCustomClass()
- {
- std::cerr << "MyCustomClass::~MyCustomClass" << std::endl;
- }
-
- virtual long int count() override
- {
- return 33;
- }
-
- Php::Value myMethod(Php::Parameters ¶ms)
- {
- // check number of parameters
- //if (params.size() != 1) throw Php::Exception("Invalid number of parameters supplied");
-
- Php::out << "myMethod is called for object " << _x << std::endl;
-
- return 5;
-
- }
- };
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/class_obj/003-comparable.h b/tests/cpp/include/class_obj/003-comparable.h
deleted file mode 100644
index 8a384dc6..00000000
--- a/tests/cpp/include/class_obj/003-comparable.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- *
- * Test Classes and objects
- * 003-comparable.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestBaseClass {
-
-
- /**
- * Test custom comparison operator
- */
- class Comparable : public Php::Base
- {
- private:
- /**
- * Internal value of the class
- * @var int
- */
- static int count;
- int _nom;
- int _value;
-
- public:
- /**
- * C++ constructor
- */
- Comparable()
- {
- // start with random value
- //_value = rand();
- _nom = ++count;
- _value = _nom%2+1;
- }
-
- /**
- * C++ destructor
- */
- virtual ~Comparable() {}
-
- /**
- * Cast the object to a string
- * @return std::string
- */
- std::string __toString()
- {
- return "Obj#" + std::to_string(_nom) + "(" + std::to_string(_value) + ")";
- }
-
- /**
- * Compare with a different object
- * @param that
- * @return int
- */
- int __compare(const Comparable &that) const
- {
- return _value - that._value;
- }
- };
- int Comparable::count = 0;
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/class_obj/004-static-funct.h b/tests/cpp/include/class_obj/004-static-funct.h
deleted file mode 100644
index d6816ab0..00000000
--- a/tests/cpp/include/class_obj/004-static-funct.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- *
- * Test Classes and objects
- * 004-static-funct.phpt
- * test static functions
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestBaseClass {
-
-
- /**
- * Regular function
- *
- * Because a regular function does not have a 'this' pointer,
- * it has the same signature as static methods
- *
- * @param params Parameters passed to the function
- */
- void testStaticRegFunc(Php::Parameters ¶ms)
- {
- Php::out << "testStatic regular function"<< std::endl;
- }
-
- /**
- * A very simple class that will not be exported to PHP
- */
- class testStaticPrivClass
- {
- public:
- /**
- * C++ constructor and destructor
- */
- testStaticPrivClass() {}
- virtual ~testStaticPrivClass() {}
-
- /**
- * Static method
- *
- * A static method also has no 'this' pointer and has
- * therefore a signature identical to regular functions
- *
- * @param params Parameters passed to the method
- */
- static void staticMethod(Php::Parameters ¶ms)
- {
- Php::out << "testStaticPrivClass::staticMethod()"<< std::endl;
- }
- };
-
- /**
- * A very simple class that will be exported to PHP
- */
- class testStaticPubClass : public Php::Base
- {
- public:
- /**
- * C++ constructor and destructor
- */
- testStaticPubClass() {}
- virtual ~testStaticPubClass() {}
-
- /**
- * Another static method
- *
- * This static has exactly the same signature as the
- * regular function and static method that were mentioned
- * before
- *
- * @param params Parameters passed to the method
- */
- static void staticMethod(Php::Parameters ¶ms)
- {
- Php::out << "testStaticPubClass::staticMethod()"<< std::endl;
- }
- };
-
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/class_obj/tpl.h b/tests/cpp/include/class_obj/tpl.h
deleted file mode 100644
index 7dfdcfcc..00000000
--- a/tests/cpp/include/class_obj/tpl.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- *
- * Test Classes and objects
- * phptname.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestBaseClass {
-
-
-
-
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/doubl2str.h b/tests/cpp/include/doubl2str.h
deleted file mode 100644
index 5c7f208f..00000000
--- a/tests/cpp/include/doubl2str.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- *
- * double -> string
- *
- */
-#include
-#include
-std::string double2str(long double d)
-{
- std::ostringstream strs;
- strs << std::setprecision(16) << d;
- return strs.str();
-}
-
-
diff --git a/tests/cpp/include/ini_entries/001.h b/tests/cpp/include/ini_entries/001.h
deleted file mode 100644
index 8a4c5cab..00000000
--- a/tests/cpp/include/ini_entries/001.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- *
- * Test ini entries
- * test ini_entries/001.phpt
- *
- */
-
-/**
- * Set up namespace
- */
-namespace TestIniEntries {
-
- // will be retrieved at boot extension
- double ini6val = 0.0;
-
- void iniTest1(Php::Parameters ¶ms)
- {
- Php::out << "ini_get(ini1) = " << Php::ini_get("ini1") << std::endl;
- Php::out << "ini_get(ini2) = " << Php::ini_get("ini2") << std::endl;
- Php::out << "ini_get(ini3) = " << Php::ini_get("ini3") << std::endl;
- Php::out << "ini_get(ini4) = " << Php::ini_get("ini4") << std::endl;
- Php::out << "ini_get(ini5) = " << Php::ini_get("ini5") << std::endl;
- Php::out << "ini_get(ini6) = " << Php::ini_get("ini6") << std::endl;
-
- Php::out << "ini6val = " << ini6val << std::endl;
- }
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/valueiterator/001-006.h b/tests/cpp/include/valueiterator/001-006.h
deleted file mode 100644
index 0dc67783..00000000
--- a/tests/cpp/include/valueiterator/001-006.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- *
- * TestValueIterator
- * test valueiterator/001.phpt-valueiterator/006.phpt
- *
- */
-
-/**
- * Set up namespace
- */
-namespace TestValueIterator {
-
-
- void loopValue(Php::Parameters ¶ms)
- {
- std::cout << "Array/Object contains " << params[0].size() << " items" << std::endl;
- for (auto it=params[0].begin(), itend = params[0].end(); it != itend; ++it) {
- std::cout << "["<< it->first << "]="<< it->second << std::endl;
- //std::cout << "["<< it->key() << "]="<< it->value() << std::endl;
- }
- return;
- }
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/valueiterator/007.h b/tests/cpp/include/valueiterator/007.h
deleted file mode 100644
index 3cfcb59b..00000000
--- a/tests/cpp/include/valueiterator/007.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *
- * TestValueIterator
- * test valueiterator/007.phpt
- *
- */
-
-/**
- * Set up namespace
- */
-namespace TestValueIterator {
-
- void loopArray(void)
- {
-
- Php::Value value;
- /*
- If we fill the array in this form, we get the following:
- *** Error in `/usr/bin/php': double free or corruption (fasttop): 0x0000000001956d60 ***
- value[0] = "val0";
- value[1] = "val1";
- value["third"] = "val3";
- value["fourth"] = "val3";
- */
- value.set(0 , "val0");
- value.set(1 , "val1");
- value.set("third" , "val3");
- value.set("fourth", "val3");
-
- std::cout << "Array/Object contains " << value.size() << " items" << std::endl;
- // assum the value variable holds an array or object, it then
- // is possible to iterator over the values or properties
- for (auto &iter : value)
- {
- // output key and value
- Php::out << "["<< iter.first << "]="<< iter.second << std::endl;
- }
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/001-process_globals.h b/tests/cpp/include/variables/001-process_globals.h
deleted file mode 100644
index ae930d28..00000000
--- a/tests/cpp/include/variables/001-process_globals.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *
- * Test variables
- * 001-process_globals.phpt
- * Global variables in PHP-CPP
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
-
-
- /**
- * process_globals()
- *
- * This function reads and modifies global variables
- */
- Php::Value process_globals()
- {
- // all global variables can be accessed via the Php::GLOBALS variable,
- // which is more or less the same as the PHP $_GLOBALS variable
-
- // set a global variable
- Php::GLOBALS["a"] = 1;
-
- // increment a global variable
- Php::GLOBALS["b"] += 1;
-
- // set a global variable to be an array
- Php::GLOBALS["c"] = Php::Array();
-
- // add a member to an array
- Php::GLOBALS["c"]["member"] = 123;
-
- // and increment it
- Php::GLOBALS["c"]["member"] += 77;
-
- // change value e
- Php::GLOBALS["e"] = Php::GLOBALS["e"][0]("hello");
-
- // if a global variable holds a function, we can call it
- return Php::GLOBALS["d"](1,2,3);
- }
-
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/002-get_complex_array.h b/tests/cpp/include/variables/002-get_complex_array.h
deleted file mode 100644
index b12e5ee7..00000000
--- a/tests/cpp/include/variables/002-get_complex_array.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- *
- * Test variables
- * 002-get_complex_array.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /**
- * This function returns complex array
- */
- Php::Value get_complex_array()
- {
- Php::Value r;
- r["a"] = 123;
- r["b"] = 456;
- r["c"][0] = "nested value";
- r["c"][1] = "example";
- r["c"][2] = 7;
- return r;
- }
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/003-value-types.h b/tests/cpp/include/variables/003-value-types.h
deleted file mode 100644
index d24549be..00000000
--- a/tests/cpp/include/variables/003-value-types.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- * Test variables
- * 003-value-types.phpt
- *
- */
-
-namespace TestVariables {
-
- /*
- * Check type of value
- * @param array
- */
- void value_types(Php::Parameters ¶ms)
- {
- if (params.size() == 0) return;
- Php::Value arr = params[0];
-
- Php::out << "Null: " << bool2str( arr.get("Null").isNull() ) << std::endl;
- Php::out << "Numeric: " << bool2str( arr.get("Numeric").isNumeric()) << std::endl;
- Php::out << "Float: " << bool2str( arr.get("Float").isFloat() ) << std::endl;
- Php::out << "Bool: " << bool2str( arr.get("Bool").isBool() ) << std::endl;
- Php::out << "Array: " << bool2str( arr.get("Array").isArray() ) << std::endl;
- Php::out << "Object: " << bool2str( arr.get("Object").isObject() ) << std::endl;
- Php::out << "String: " << bool2str( arr.get("String").isString() ) << std::endl;
- Php::out << "Resource: " << bool2str( arr.get("Resource").type() == Php::Type::Resource ) << std::endl;
- Php::out << "Constant: " << bool2str( arr.get("Constant").type() == Php::Type::Constant ) << std::endl;
- Php::out << "ConstantArray: " << bool2str( arr.get("ConstantArray").type() == Php::Type::ConstantArray ) << std::endl;
- Php::out << "Callable1: " << bool2str( arr.get("Callable1").isCallable() ) << std::endl;
- Php::out << "Callable2: " << bool2str( arr.get("Callable2").isCallable() ) << std::endl;
- Php::out << "Callable3: " << bool2str( arr.get("Callable3").isCallable() ) << std::endl;
- Php::out << "Callable4: " << bool2str( arr.get("Callable4").isCallable() ) << std::endl;
-
- }
-
-}
-
diff --git a/tests/cpp/include/variables/004-store-scalar-variables.h b/tests/cpp/include/variables/004-store-scalar-variables.h
deleted file mode 100644
index 9ce82e5b..00000000
--- a/tests/cpp/include/variables/004-store-scalar-variables.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *
- * Test variables
- * 004-store-scalar-variables.phpt
- *
- */
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /*
- * Test variables defined 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;
- r[10] = Php::Value();
- r[11] = 123.45;
- r[12] = false;
-
- return r;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/005-cast-objects-to-scalars.h b/tests/cpp/include/variables/005-cast-objects-to-scalars.h
deleted file mode 100644
index f053c4d6..00000000
--- a/tests/cpp/include/variables/005-cast-objects-to-scalars.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *
- * Test variables
- * 005-cast-objects-to-scalars.phpt
- *
- */
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /**
- * A sample class, with methods to cast objects to scalars
- */
- class Obj2Scalar : public Php::Base
- {
- public:
- /**
- * C++ constructor and C++ destructpr
- */
- Obj2Scalar() {}
- virtual ~Obj2Scalar() {}
-
- /**
- * Cast to a string
- *
- * Note that now we use const char* as return value, and not Php::Value.
- * The __toString function is detected at compile time, and it does
- * not have a fixed signature. You can return any value that can be picked
- * up by a Php::Value object.
- *
- * @return const char *
- */
- const char *__toString()
- {
- return "Mount Meru, also called Sumeru (Sanskrit)";
- }
-
- /**
- * Cast to a integer
- * @return long
- */
- long __toInteger()
- {
- return 27032014;
- }
-
- /**
- * Cast to a floating point number
- * @return double
- */
- double __toFloat()
- {
- return 3.14159265359;
- }
-
- /**
- * Cast to a boolean
- * @return bool
- */
- bool __toBool()
- {
- return true;
- }
- };
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/006-casting-obj2str.h b/tests/cpp/include/variables/006-casting-obj2str.h
deleted file mode 100644
index 879683d3..00000000
--- a/tests/cpp/include/variables/006-casting-obj2str.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- *
- * Test variables
- * 006-casting-obj2str.phpt
- *
- */
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
-
- /*
- * Test Php::Value casting operators
- */
- void value_cast2str(Php::Parameters ¶ms)
- {
- std::string value = params[0];
- Php::out << value << std::endl;
- }
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/007-overloaded-operators.h b/tests/cpp/include/variables/007-overloaded-operators.h
deleted file mode 100644
index 88b31170..00000000
--- a/tests/cpp/include/variables/007-overloaded-operators.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *
- * Test variables
- * 007-overloaded-operators.phpt
- *
- */
-
-
-
-namespace TestVariables {
-
- /*
- * Test Php::Value overloaded operators
- */
- void overloaded_op(Php::Parameters ¶ms)
- {
- Php::Value value = params[0];
- if (value == "some string")
- {
- Php::out << "value == 'some string'" << std::endl;
- }
-
- if (value == 12)
- {
- Php::out << "value == 12" << std::endl;
- }
- else if (value > 100)
- {
- Php::out << "value > 100" << std::endl;
- }
-
- value += 10;
- Php::out << value << std::endl;
-
- int r1 = value - 8;
- Php::out << r1 << std::endl;
-
- double r2 = value*123.45;
- Php::out << r2 << std::endl;
-
- double r3 = value/123.45;
- Php::out << r3 << std::endl;
- }
-
-}
-
diff --git a/tests/cpp/include/variables/008-value-arrays.h b/tests/cpp/include/variables/008-value-arrays.h
deleted file mode 100644
index 937f79ac..00000000
--- a/tests/cpp/include/variables/008-value-arrays.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *
- * Test variables
- * 008-value-arrays.phpt
- *
- */
-
-
-namespace TestVariables {
-
-
- /*
- * Test Php::Value arrays
- */
- Php::Value value_arrays(void)
- {
- // create a regular array
- Php::Value array;
- array[0] = "apple";
- array[1] = "banana";
- array[2] = "tomato";
-
- // an initializer list can be used to create a filled array
- Php::Value filled({ "a", "b", "c", "d"});
-
- // create an associative array
- Php::Value assoc;
- assoc["apple"] = "green";
- assoc["banana"] = "yellow";
- assoc["tomato"] = "green";
-
- // the variables in an array do not all have to be of the same type
- Php::Value assoc2;
- assoc2["x"] = "info@example.com";
- assoc2["y"] = nullptr;
- assoc2["z"] = 123;
-
- // nested arrays are possible too
- Php::Value assoc3;
- assoc3["x"] = "info@example.com";
- assoc3["y"] = nullptr;
- assoc3["z"][0] = "a";
- assoc3["z"][1] = "b";
- assoc3["z"][2] = "c";
-
- Php::Value r;
- r["array"] = array;
- r["filled"] = filled;
- r["assoc"] = assoc;
- r["assoc2"] = assoc2;
- r["assoc3"] = assoc3;
- return r;
- }
-
-
-}
-
diff --git a/tests/cpp/include/variables/009-010-value-object.h b/tests/cpp/include/variables/009-010-value-object.h
deleted file mode 100644
index e3eba855..00000000
--- a/tests/cpp/include/variables/009-010-value-object.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- *
- * Test variables
- * 009-value-object.phpt
- * 010-value-object2.phpt
- *
- */
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
-
- /*
- * Test Php::Value object
- */
- Php::Value value_object1(void)
- {
-
- // create empty object of type stdClass
- Php::Object object;
-
- // object properties can be accessed with square brackets
- object["property1"] = "value1";
- object["property2"] = "value2";
-
- // Php::Value is the base class, so you can assign Php::Object objects
- //Php::Value value = object;
-
- return object;
- }
-
- /*
- * Test Php::Value object
- */
- Php::Value value_object2(void)
- {
-
- // create empty object of type stdClass
- Php::Object object;
-
- // to create an object of a different type, pass in the class name
- // to the constructor with optional constructor parameters
- //object = Php::Object("DateTime", "2014-03-27 00:37:15.638276");
-
- auto timeZone = Php::Object("DateTimeZone", "Europe/Amsterdam");
- object = Php::Object("DateTime", "2014-03-27 00:37:15", timeZone);
-
-
- // methods can be called with the call() method
- Php::out << object.call("format", "Y-m-d H:i:s") << std::endl;
-
- // all these methods can be called on a Php::Value object too
- Php::Value value = Php::Object("DateTime", "2016-03-31 15:48:00", timeZone);
- Php::out << value.call("format", "Y-m-d H:i:s") << std::endl;
- Php::out << value.call("getOffset") << std::endl;
-
- return object;
- }
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/011-012-value-casting-operators.h b/tests/cpp/include/variables/011-012-value-casting-operators.h
deleted file mode 100644
index 2d791b22..00000000
--- a/tests/cpp/include/variables/011-012-value-casting-operators.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- *
- * Test variables
- * 011-value-casting-operators.phpt
- * 012-value-casting-operators-double.phpt
- *
- */
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /*
- * Test Php::Value casting operators
- */
- void value_casting(Php::Parameters ¶ms)
- {
- Php::Value value = params[0];
-
- int64_t value1 = value;
- std::string value2 = value;
- bool value4 = value;
-
- Php::out << " long:" << value1 << "\n string:" << value2 << "\n bool:" << bool2str(value4) << std::endl;
- }
-
-
- /*
- * Test Php::Value casting operators
- */
- void value_cast2double(Php::Parameters ¶ms)
- {
- Php::Value value = params[0];
- double value3 = value;
-
- /*
- * The remark (from valmat).
- * Somehow std::to_string truncates the tail of numbers of type `double` when converting it to a string.
- * So I wrote my own function `double2str()`, which does not have this drawback.
- */
- Php::out << double2str(value3) << std::endl;
- }
-
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/013-018-calling-php-functions.h b/tests/cpp/include/variables/013-018-calling-php-functions.h
deleted file mode 100644
index 9a77408a..00000000
--- a/tests/cpp/include/variables/013-018-calling-php-functions.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- *
- * Test call function
- * 013-calling-php-functions.phpt
- * ...
- * 018-calling-php-functions.phpt
- *
- */
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
-
- /*
- * Test call function from user space
- */
- void fnFromUserSpace(void)
- {
-
-
- Php::out << "fnFromUserSpace" << std::endl;
-
- Php::Value param5;
- param5.set(0, "param5");
- param5.set(1, 3.14159265359);
- param5.set(2, 28032014);
- param5.set("key", "value");
-
- auto timeZone = Php::Object("DateTimeZone", "Asia/Yekaterinburg");
- Php::Value param6 = Php::Object("DateTime", "2014-03-28 19:42:15", timeZone);
-
- // call a function from user space
- Php::call("some_function", "param1");
- Php::call("some_function", "param1", "param2");
- Php::call("some_function", "param1", "param2", "param3");
- Php::call("some_function", "param1", "param2", "param3", "param4");
- Php::call("some_function", "param1", "param2", "param3", "param4", param5);
- Php::call("some_function", "param1", "param2", "param3", "param4", param5, param6);
- Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7");
- Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8");
- Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9");
- Php::call("some_function", "param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9", "param10");
-
- }
-
- /*
- * Test call callback
- */
- void fnCallback(Php::Parameters ¶ms)
- {
- Php::out << "call callback" << std::endl;
-
- Php::Value callback = params[0];
-
-
- Php::Value param5;
- param5.set(0, "param5");
- param5.set(1, 3.14159265359);
- param5.set(2, 28032014);
- param5.set("key", "value");
-
- auto timeZone = Php::Object("DateTimeZone", "Asia/Yekaterinburg");
- Php::Value param6 = Php::Object("DateTime", "2014-03-28 19:42:15", timeZone);
-
- // call a function from user space
- callback("param1");
- callback("param1", "param2");
- callback("param1", "param2", "param3");
- callback("param1", "param2", "param3", "param4");
- callback("param1", "param2", "param3", "param4", param5);
- callback("param1", "param2", "param3", "param4", param5, param6);
- callback("param1", "param2", "param3", "param4", "param5", "param6", "param7");
- callback("param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8");
- callback("param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9");
- callback("param1", "param2", "param3", "param4", "param5", "param6", "param7", "param8", "param9", "param10");
-
- }
-
- /*
- * Test
- */
- void fnFromUserSpace2(void)
- {
-
- // create an object (this will also call __construct())
- Php::Object time("DateTime", "2014-03-28 21:22:15", Php::Object("DateTimeZone", "Asia/Irkutsk"));
-
- // call a method on the datetime object
- Php::out << time.call("format", "Y-m-d H:i:s") << std::endl;
-
- // in PHP it is possible to create an array with two parameters, the first
- // parameter being an object, and the second parameter should be the name
- // of the method, we can do that in PHP-CPP too
- Php::Array time_format({time, "format"});
-
- // call the method that is stored in the array
- Php::out << time_format("Y-m-d H:i:s") << std::endl;
-
- // call method of class from user space
- Php::Object usrspcl("usrspClass", "Mount Meru");
- Php::Array usrspcl_meth({usrspcl, "someMethod"});
- // call the method that is stored in the array
- Php::out << usrspcl_meth("is in the Arctics") << std::endl;
-
- // call callable object of class from user space
- Php::Object clbl("CallableClass", "Arctics around mount Meru");
- Php::out << clbl("is the birthplace of the Hyperboreans") << std::endl;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/019-HashMember-1.h b/tests/cpp/include/variables/019-HashMember-1.h
deleted file mode 100644
index 28003f0f..00000000
--- a/tests/cpp/include/variables/019-HashMember-1.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- *
- * Test variables
- * 019-HashMember-1.phpt
- * Test HashMember
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /**
- * This function returns complex array
- */
- Php::Value test_HashMember_1()
- {
- Php::Value r, tmp(Php::Type::Array);
- r["key1"] = tmp;
- r["key1"]["key2"] = "val2";
- r["key1"]["key3"] = "val3";
- return r;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/020-HashMember-2.h b/tests/cpp/include/variables/020-HashMember-2.h
deleted file mode 100644
index dfa95c2c..00000000
--- a/tests/cpp/include/variables/020-HashMember-2.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- * Test variables
- * 019-HashMember-2.phpt
- * Test HashMember
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /**
- * This function returns complex array
- */
- Php::Value test_HashMember_2()
- {
- Php::Value r, empty_array(Php::Type::Array);
- r["k1"]["k3"] = "v1";
- r["k1"]["k2"]["k4"] = "v2";
- r["k5"][1] = "v3";
- r[2]["k6"][1] = "v4";
- r[3][4][1] = "v5";
- r[3][4][2][5][7][11] = "v5";
- r[3][4][2][5][7]["k"] = "v5";
- r["c"][0] = "nested value";
- r["c"][1] = nullptr;
- r["c"][2] = empty_array;
- r["c"][3] = "example";
- return r;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/021-HashMember-3.h b/tests/cpp/include/variables/021-HashMember-3.h
deleted file mode 100644
index f7c09141..00000000
--- a/tests/cpp/include/variables/021-HashMember-3.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- * Test variables
- * 019-HashMember-3.phpt
- * Test HashMember
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /**
- * This function returns complex array
- */
- Php::Value test_HashMember_3()
- {
-
- Php::Value r, tmp(Php::Type::Array);
- //Php::Value tmp;
-
- tmp.set("key2", "val1-2");
- r.set("key1", tmp);
- r.get("key1").set("key3", "val1-3");
-
- // expect to receive the same as when recording:
- //r["key1"]["key2"] = "val1-2";
- //r["key1"]["key3"] = "val1-3";
-
- return r;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/022-HashMember-4.h b/tests/cpp/include/variables/022-HashMember-4.h
deleted file mode 100644
index e51eb3a2..00000000
--- a/tests/cpp/include/variables/022-HashMember-4.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *
- * Test variables
- * 019-HashMember-4.phpt
- * Test HashMember
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /**
- * This function returns complex array
- */
- Php::Value test_HashMember_4()
- {
-
-
- Php::Value r1;
- Php::Value tmp1,tmp2;
- tmp2.set("key3", "val");
- tmp1.set("key2", tmp2);
- r1.set("key1", tmp1);
- // this should be equivalent to:
- // r1["key1"]["key2"]["key3"] = "val";
-
- Php::Value r2;
- r2.set("str1", "example");
- r2.set("str2", r2.get("str1"));
- // this should be equivalent to:
- // r2["str1"] = "example";
- // r2["str2"] = r2["str1"];
- // i.e.
- // r2["str1"] = "example";
- // r2["str2"] = "example";
-
- Php::Value r3;
- Php::Value tmp;
- tmp.set("str2", "val1-2");
- tmp.set("str3", "val1-3");
- r3.set("str1", tmp);
- // this should be equivalent to:
- // r3["str1"]["str2"] = "val1-2";
- // r3["str1"]["str3"] = "val1-3";
-
-
- Php::Value r;
- r[0] = r1;
- r[1] = r2;
- r[2] = r3;
-
-
- return r;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/023-cookie.h b/tests/cpp/include/variables/023-cookie.h
deleted file mode 100644
index 6f74883e..00000000
--- a/tests/cpp/include/variables/023-cookie.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- *
- * Test superglobal variables _COOKIE
- * 023-cookie.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
-
- /*
- * Test
- */
- void getCookie(void)
- {
- Php::out << "_COOKIE[peace] = " << Php::COOKIE["peace"] << std::endl;
- Php::out << "_COOKIE[freedom] = " << Php::COOKIE["freedom"] << std::endl;
- Php::out << "_COOKIE[empty] = " << Php::COOKIE["empty"] << std::endl;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/024-get-post.h b/tests/cpp/include/variables/024-get-post.h
deleted file mode 100644
index e615f0f7..00000000
--- a/tests/cpp/include/variables/024-get-post.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- *
- * Test superglobal variables _GET & _POST
- * 024-get-post.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
-
- /*
- * Test
- */
- void get_post(void)
- {
- Php::out << "_GET[a] = " << Php::GET["a"] << std::endl;
- Php::out << "_GET[b] = " << Php::GET["b"] << std::endl;
- Php::out << "_GET[ar][elm1] = " << Php::GET["ar"]["elm1"] << std::endl;
- Php::out << "_GET[ar][elm2] = " << Php::GET["ar"]["elm2"] << std::endl;
-
- Php::out << "_POST[c] = " << Php::POST["c"] << std::endl;
- Php::out << "_POST[d] = " << Php::POST["d"] << std::endl;
- Php::out << "_POST[e] = " << Php::POST["e"] << std::endl;
- Php::out << "_POST[e][0] = " << Php::POST["e"][0] << std::endl;
- Php::out << "_POST[e][1] = " << Php::POST["e"][1] << std::endl;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/025-post-raw1.h b/tests/cpp/include/variables/025-post-raw1.h
deleted file mode 100644
index 37c6ae17..00000000
--- a/tests/cpp/include/variables/025-post-raw1.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- *
- * Test superglobal variables _POST
- * 025-post-raw1.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
- using namespace Php;
-
-
- /*
- * Test
- */
- void post_raw1(void)
- {
- out << "username => "<< POST["username"] << std::endl;
- out << "text => "<< POST["text"] << std::endl;
-
- /*
- XXX TODO: conversion from ‘Php::Super’ to ‘Php::Value‘
- Value v = POST;
-
- out << "Array/Object contains " << v.size() << " items" << std::endl;
- for (auto it=v.begin(), itend = v.end(); it != itend; ++it) {
- out << "["<< it->first << "]="<< it->second << std::endl;
- }
- */
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/026-post-raw2.h b/tests/cpp/include/variables/026-post-raw2.h
deleted file mode 100644
index d250dc82..00000000
--- a/tests/cpp/include/variables/026-post-raw2.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *
- * Test superglobal variables _POST
- * 026-post-raw2.phpt
- *
- */
-
-
-#include
-#include
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
- using namespace Php;
-
-
- /*
- * Test
- */
- void post_raw2(void)
- {
- out << "name1 : "<< FILES["flnm"]["name"][0] << std::endl;
- out << "name2 : "<< FILES["flnm"]["name"][1] << std::endl;
-
- out << "type1 : "<< FILES["flnm"]["type"][0] << std::endl;
- out << "type2 : "<< FILES["flnm"]["type"][1] << std::endl;
-
- out << "error1 : "<< FILES["flnm"]["error"][0] << std::endl;
- out << "error2 : "<< FILES["flnm"]["error"][1] << std::endl;
-
- out << "size1 : "<< FILES["flnm"]["size"][0] << std::endl;
- out << "size2 : "<< FILES["flnm"]["size"][1] << std::endl;
-
-
- int length0 = FILES["flnm"]["size"][0];
- int length1 = FILES["flnm"]["size"][1];
- char *buffer0, *buffer1;
-
- std::ifstream file0, file1;
- std::string filename0 = FILES["flnm"]["tmp_name"][0];
- std::string filename1 = FILES["flnm"]["tmp_name"][1];
-
- file0.open(filename0, std::ios::in | std::ios::binary);
- file1.open(filename1, std::ios::in | std::ios::binary);
-
- if(!file0.is_open() || !file1.is_open()) {
- out << "Cannot open file." << std::endl;
- return;
- }
-
- //allocate memory
- buffer0 = new char[length0];
- buffer1 = new char[length1];
-
- //read data as a block to buffer
- file0.read(buffer0, length0);
- file1.read(buffer1, length1);
- file0.close();
- file1.close();
-
- out << "content1 : ";
- out.write(buffer0, length0);
- out << std::endl;
- out << "content2 : "<< buffer1 << std::endl;
-
- delete[] buffer0;
- delete[] buffer1;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/027-env.h b/tests/cpp/include/variables/027-env.h
deleted file mode 100644
index b8455b4b..00000000
--- a/tests/cpp/include/variables/027-env.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- *
- * Test superglobal variables _ENV
- * 027-env.phpt
- *
- */
-
-
-
-namespace TestVariables {
-
-
- /*
- * Test
- */
- void test_env(void)
- {
- Php::out << "HTTP_USER_AGENT => " << Php::SERVER["HTTP_USER_AGENT"] << std::endl;
- Php::out << "ENVVAR1 => " << Php::SERVER["ENVVAR1"] << std::endl;
- Php::out << "HTTP_REFERER => " << Php::SERVER["HTTP_REFERER"] << std::endl;
- Php::out << "REQUEST_METHOD => " << Php::SERVER["REQUEST_METHOD"] << std::endl;
- Php::out << "HTTP_HOST => " << Php::SERVER["HTTP_HOST"] << std::endl;
- }
-
-}
-
diff --git a/tests/cpp/include/variables/028-029-compare.h b/tests/cpp/include/variables/028-029-compare.h
deleted file mode 100644
index bd95298d..00000000
--- a/tests/cpp/include/variables/028-029-compare.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- *
- * Test variables
- * phptname.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /*
- * Test bool Value::operator==(const Value &value) const
- */
- void test_compare1()
- {
- Php::Value v1(5), v2(5.0), v3("5"), v4("5.0");
-
- Php::out << "true:" << std::endl;
- Php::out << (v1 == v2) << std::endl;
- Php::out << (v1 == v3) << std::endl;
- Php::out << (v1 == v4) << std::endl;
- Php::out << (v2 == v1) << std::endl;
- Php::out << (v2 == v3) << std::endl;
- Php::out << (v2 == v4) << std::endl;
- Php::out << (v3 == v1) << std::endl;
- Php::out << (v3 == v2) << std::endl;
- Php::out << (v3 == v4) << std::endl;
- Php::out << (v4 == v1) << std::endl;
- Php::out << (v4 == v2) << std::endl;
- Php::out << (v4 == v3) << std::endl;
-
- Php::Value v5(6), v6(6.0), v7("6"), v8("6.0");
-
- Php::out << "false:" << std::endl;
- Php::out << (v1 == v5) << std::endl;
- Php::out << (v1 == v6) << std::endl;
- Php::out << (v1 == v7) << std::endl;
- Php::out << (v1 == v8) << std::endl;
-
- Php::out << (v2 == v5) << std::endl;
- Php::out << (v2 == v6) << std::endl;
- Php::out << (v2 == v7) << std::endl;
- Php::out << (v2 == v8) << std::endl;
-
- Php::out << (v3 == v5) << std::endl;
- Php::out << (v3 == v6) << std::endl;
- Php::out << (v3 == v7) << std::endl;
- Php::out << (v3 == v8) << std::endl;
-
- Php::out << (v4 == v5) << std::endl;
- Php::out << (v4 == v6) << std::endl;
- Php::out << (v4 == v7) << std::endl;
- Php::out << (v4 == v8) << std::endl;
-
- Php::Value v9, v10, v11, v12;
- v9[0] = 5;
- v9[1] = 6;
-
- v10[0] = 5;
- v10[1] = "Hello!";
-
- v11[0] = 5;
- v11[1] = 6;
-
- v12[0] = 5;
-
- Php::out << "Compare array:" << std::endl;
- Php::out << (v1 == v9) << std::endl;
- Php::out << (v5 == v9) << std::endl;
- Php::out << (v9 == v10) << std::endl;
- Php::out << (v11 == v9) << std::endl;
- Php::out << (v12 == v9) << std::endl;
-
- Php::Value v13 = false, v14, v15 = 0;
- Php::out << "Compare NULL:" << std::endl;
- Php::out << (v1 == v13) << std::endl;
- Php::out << (v1 == v14) << std::endl;
- Php::out << (v1 == v15) << std::endl;
-
- Php::out << (v13 == v14) << std::endl;
- Php::out << (v13 == v15) << std::endl;
- Php::out << (v14 == v15) << std::endl;
- }
-
- /*
- * Test bool Value::operator< (const Value &value) const
- */
- void test_compare2()
- {
- Php::Value v1(5), v2(5.0), v3("5"), v4("5.0");
-
- Php::out << "false:" << std::endl;
- Php::out << (v1 < v2) << std::endl;
- Php::out << (v1 < v3) << std::endl;
- Php::out << (v1 < v4) << std::endl;
- Php::out << (v2 < v1) << std::endl;
- Php::out << (v2 < v3) << std::endl;
- Php::out << (v2 < v4) << std::endl;
- Php::out << (v3 < v1) << std::endl;
- Php::out << (v3 < v2) << std::endl;
- Php::out << (v3 < v4) << std::endl;
- Php::out << (v4 < v1) << std::endl;
- Php::out << (v4 < v2) << std::endl;
- Php::out << (v4 < v3) << std::endl;
-
- Php::Value v5(6), v6(6.0), v7("6"), v8("6.0");
-
- Php::out << "true:" << std::endl;
- Php::out << (v1 < v5) << std::endl;
- Php::out << (v1 < v6) << std::endl;
- Php::out << (v1 < v7) << std::endl;
- Php::out << (v1 < v8) << std::endl;
-
- Php::out << (v2 < v5) << std::endl;
- Php::out << (v2 < v6) << std::endl;
- Php::out << (v2 < v7) << std::endl;
- Php::out << (v2 < v8) << std::endl;
-
- Php::out << (v3 < v5) << std::endl;
- Php::out << (v3 < v6) << std::endl;
- Php::out << (v3 < v7) << std::endl;
- Php::out << (v3 < v8) << std::endl;
-
- Php::out << (v4 < v5) << std::endl;
- Php::out << (v4 < v6) << std::endl;
- Php::out << (v4 < v7) << std::endl;
- Php::out << (v4 < v8) << std::endl;
-
- Php::out << "false:" << std::endl;
- Php::out << (v1 > v5) << std::endl;
- Php::out << (v1 > v6) << std::endl;
- Php::out << (v1 > v7) << std::endl;
- Php::out << (v1 > v8) << std::endl;
-
- Php::out << (v2 > v5) << std::endl;
- Php::out << (v2 > v6) << std::endl;
- Php::out << (v2 > v7) << std::endl;
- Php::out << (v2 > v8) << std::endl;
-
- Php::out << (v3 > v5) << std::endl;
- Php::out << (v3 > v6) << std::endl;
- Php::out << (v3 > v7) << std::endl;
- Php::out << (v3 > v8) << std::endl;
-
- Php::out << (v4 > v5) << std::endl;
- Php::out << (v4 > v6) << std::endl;
- Php::out << (v4 > v7) << std::endl;
- Php::out << (v4 > v8) << std::endl;
-
- Php::Value v9, v10, v11, v12;
- v9[0] = 5;
- v9[1] = 6;
-
- v10[0] = 5;
- v10[1] = "Hello!";
-
- v11[0] = 5;
- v11[1] = 6;
-
- v12[0] = 5;
-
- Php::out << "Compare array:" << std::endl;
- Php::out << (v1 < v9) << std::endl;
- Php::out << (v5 < v9) << std::endl;
- Php::out << (v9 < v10) << std::endl;
- Php::out << (v9 > v10) << std::endl;
- Php::out << (v11 < v9) << std::endl;
- Php::out << (v12 < v9) << std::endl;
-
- Php::Value v13 = false, v14, v15 = 0;
- Php::out << "Compare NULL:" << std::endl;
- Php::out << (v1 < v13) << std::endl;
- Php::out << (v1 < v14) << std::endl;
- Php::out << (v1 < v15) << std::endl;
-
- Php::out << (v1 > v13) << std::endl;
- Php::out << (v1 > v14) << std::endl;
- Php::out << (v1 > v15) << std::endl;
-
- Php::out << (v13 < v14) << std::endl;
- Php::out << (v13 < v15) << std::endl;
- Php::out << (v14 < v15) << std::endl;
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/include/variables/tpl.h b/tests/cpp/include/variables/tpl.h
deleted file mode 100644
index 0df58928..00000000
--- a/tests/cpp/include/variables/tpl.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * Test variables
- * phptname.phpt
- *
- */
-
-
-
-
-/**
- * Set up namespace
- */
-namespace TestVariables {
-
- /*
- * Test
- */
- void fnname(Php::Parameters ¶ms)
- {
-
-
- }
-
-/**
- * End of namespace
- */
-}
-
diff --git a/tests/cpp/main.cpp b/tests/cpp/main.cpp
deleted file mode 100644
index 47cd90d5..00000000
--- a/tests/cpp/main.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- *
- * An example file to show the working of using a C++ class in PHP.
- */
-
-#include
-#include
-#include
-
-// Test includes
-#include "h/ValueIterator.h"
-#include "h/Classes_and_objects.h"
-#include "h/variables.h"
-#include "h/ini_entries.h"
-
-
-
-
-// Symbols are exported according to the "C" language
-extern "C"
-{
- // export the "get_module" function that will be called by the Zend engine
- PHPCPP_EXPORT void *get_module()
- {
- // create extension
- static Php::Extension extension("extension_for_tests","0.1");
-
- // build an interface
- //Php::Interface interface("MyInterface");
-
- // add methods to the interface
- //interface.method("method1");
- //interface.method("method2");
-
- // add the interface to the extension
- //extension.add(interface);
-
-
-
-
- /**
- * Classes and objects
- *
- */
- // we are going to define a class
- Php::Class customClass("TestBaseClass\\MyClass");
-
- // add methods to it
- customClass.method("myMethod", &TestBaseClass::MyCustomClass::myMethod, Php::Final, {});
- customClass.property("property1", "prop1");
- customClass.property("property2", "prop2", Php::Protected);
-
- customClass.property("CONSTANT1", "some string", Php::Const);
- customClass.property("EXP", 2.718281828459, Php::Const);
- customClass.property("CONSTANT2", -2582341, Php::Const);
- customClass.property("CONSTANT3", true, Php::Const);
-
- customClass.property("StatProp1", "some string", Php::Static);
- customClass.property("Exp", 2.718281828459, Php::Static);
- customClass.property("StatProp2", -2582341, Php::Static);
- customClass.property("StatProp3", true, Php::Static);
-
- // add the class to the extension
- extension.add(customClass);
-
- // Comparable
- extension.add( Php::Class("TestBaseClass\\Comparable") );
-
-
- // test static functions
- //
- // description of the class so that PHP knows which methods are accessible
- Php::Class ClassWithStatic("TestBaseClass\\ClassWithStatic");
- // register the testStaticPubClass::staticMethod to be a static method callable from PHP
- ClassWithStatic.method("static1", &TestBaseClass::testStaticPubClass::staticMethod);
- // regular functions have the same signatures as static methods. So nothing forbids you to register a normal function as static method too
- ClassWithStatic.method("static2", TestBaseClass::testStaticRegFunc);
- // and even static methods from completely different classes have the same function signature and can thus be registered
- ClassWithStatic.method("static3", &TestBaseClass::testStaticPrivClass::staticMethod);
- // add the class to the extension
- extension.add(std::move(ClassWithStatic));
- // In fact, because a static method has the same signature
- // as a regular function, you can also register static
- // C++ methods as regular global PHP functions
- extension.add("TestBaseClass\\staticFun1", &TestBaseClass::testStaticPrivClass::staticMethod);
-
-
-
-
- /**
- * tests for Iterators
- *
- */
- // add function to extension
- //extension.add("TestValueIterator\\loopValue", TestValueIterator::loopValue/*, {
- extension.add("TestValueIterator\\loopValue", TestValueIterator::loopValue);
- extension.add("TestValueIterator\\loopArray", TestValueIterator::loopArray);
-
-
- /**
- * tests for variables
- *
- */
- // create a nested namespace
- extension.add("TestVariables\\process_globals", TestVariables::process_globals);
- extension.add("TestVariables\\get_complex_array", TestVariables::get_complex_array);
- extension.add("TestVariables\\value_types", TestVariables::value_types);
- extension.add("TestVariables\\scalar_store", TestVariables::scalar_store);
- extension.add("TestVariables\\value_casting", TestVariables::value_casting);
- extension.add("TestVariables\\value_cast2double", TestVariables::value_cast2double);
- extension.add("TestVariables\\value_cast2str", TestVariables::value_cast2str);
- extension.add("TestVariables\\overloaded_op", TestVariables::overloaded_op);
- extension.add("TestVariables\\value_arrays", TestVariables::value_arrays);
- extension.add("TestVariables\\value_object1", TestVariables::value_object1);
- extension.add("TestVariables\\value_object2", TestVariables::value_object2);
- extension.add("TestVariables\\fnFromUserSpace", TestVariables::fnFromUserSpace);
- extension.add("TestVariables\\fnFromUserSpace2", TestVariables::fnFromUserSpace2);
- extension.add("TestVariables\\fnCallback", TestVariables::fnCallback);
- extension.add("TestVariables\\test_HashMember_1", TestVariables::test_HashMember_1);
- extension.add("TestVariables\\test_HashMember_2", TestVariables::test_HashMember_2);
- extension.add("TestVariables\\test_HashMember_3", TestVariables::test_HashMember_3);
- extension.add("TestVariables\\test_HashMember_4", TestVariables::test_HashMember_4);
- extension.add("TestVariables\\getCookie", TestVariables::getCookie);
- extension.add("TestVariables\\get_post", TestVariables::get_post);
- extension.add("TestVariables\\post_raw1", TestVariables::post_raw1);
- extension.add("TestVariables\\post_raw2", TestVariables::post_raw2);
- extension.add("TestVariables\\test_env", TestVariables::test_env);
- extension.add("TestVariables\\test_compare1", TestVariables::test_compare1);
- extension.add("TestVariables\\test_compare2", TestVariables::test_compare2);
-
-
-
-
-
- // A sample class, with methods to cast objects to scalars
- Php::Class cObj2Scalar("TestVariables\\Obj2Scalar");
- extension.add(std::move(cObj2Scalar));
-
-
- /**
- * tests ini entries
- *
- */
- extension
- .add(Php::Ini("ini1", "valIni1"))
- .add(Php::Ini("ini2", "valIni2", "OrigValIni2"))
- .add(Php::Ini("ini3", "valIni3", "OrigValIni3", Php::Ini::System))
- .add(Php::Ini("ini4", true, false, Php::Ini::Place::User))
- .add(Php::Ini("ini5", false));
-
- Php::Ini ini6("ini6", 55, 11);
- extension
- .add(ini6)
- .add(Php::Ini("ini7", 74,5));
-
- Php::Ini ini8("ini8", 3.1415926, 6.2831852);
- Php::Ini ini9("ini9", 2.7182818, 5.4365636, Php::Ini::User);
- //extension.add(Php::Ini("ini9", 0.333333, 0.777777, Php::Ini::Perdir));
-
- extension.add(ini8);
- extension.add(std::move(ini9));
-
- extension.add("TestIniEntries\\iniTest1", TestIniEntries::iniTest1);
-
- extension.onStartup([](){
- // Retrieve a value at boot extension
- TestIniEntries::ini6val = Php::ini_get("ini6");
- });
-
-
-
-
-
-
-
- // return the extension module
- return extension;
- }
-}
diff --git a/tests/cpp/readme b/tests/cpp/readme
deleted file mode 100644
index c3743ce0..00000000
--- a/tests/cpp/readme
+++ /dev/null
@@ -1,2 +0,0 @@
-This extension is written with a single purpose - all tests will be conducted through it.
-No installation required!
diff --git a/tests/include/.gitignore b/tests/include/.gitignore
deleted file mode 100644
index 3a442cee..00000000
--- a/tests/include/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.h
-/lib/*
-/zts/*
diff --git a/tests/include/zts/.gitignore b/tests/include/zts/.gitignore
deleted file mode 100644
index 8d82a929..00000000
--- a/tests/include/zts/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-phpcpp/config.h
diff --git a/tests/php/dbg.php b/tests/php/dbg.php
deleted file mode 100644
index e626ce04..00000000
--- a/tests/php/dbg.php
+++ /dev/null
@@ -1,57 +0,0 @@
-info();
-echo "\x1b[0m";
-echo "\x1b[0;34m";
-var_export( ini_get_all ( 'extension_for_tests' ) );
-echo "\x1b[0m", PHP_EOL;
-exit;
-
-TestIniEntries\iniTest1();
-
-//ini_set("extension_for_tests.some_string3", 'RFVBGT') ;
-echo PHP_EOL;
-echo "extension_for_tests.some_string ={{" , ini_get("extension_for_tests.some_string") , "}}", PHP_EOL;
-echo "extension_for_tests.some_string2 ={{" , ini_get("extension_for_tests.some_string2") , "}}", PHP_EOL;
-echo "extension_for_tests.some_string3 ={{" , ini_get("extension_for_tests.some_string3") , "}}", PHP_EOL;
-echo "extension_for_tests.some_string3 ={{" , ini_get("extension_for_tests.some_bool") , "}}", PHP_EOL;
-
-
-echo "\x1b[1;31m";
-(new ReflectionExtension('extension_for_tests') )->info();
-echo "\x1b[0m";
-
-echo "\x1b[0;34m";
-var_export( ini_get_all ( 'extension_for_tests' ) );
-echo "\x1b[0m", PHP_EOL;
-
-ini_set("extension_for_tests.some_string3", 'RFVBGT') ;
-echo "extension_for_tests.some_string3 ={{" , ini_get("extension_for_tests.some_string3") , "}}", PHP_EOL;
-ini_restore ( 'extension_for_tests.some_string3' );
-echo "extension_for_tests.some_string3 ={{" , ini_get("extension_for_tests.some_string3") , "}}", PHP_EOL;
-
-
-echo "extension_for_tests.some_bool :";
-var_dump(ini_get("extension_for_tests.some_bool"));
-echo PHP_EOL;
-
-ini_set("extension_for_tests.some_bool", 'off');
-
-echo "extension_for_tests.some_bool :";
-var_dump(ini_get("extension_for_tests.some_bool"));
-echo PHP_EOL;
-
-//var_export(php_sapi_name());
diff --git a/tests/php/include/valueiterator/1.php b/tests/php/include/valueiterator/1.php
deleted file mode 100644
index 984a77f2..00000000
--- a/tests/php/include/valueiterator/1.php
+++ /dev/null
@@ -1,76 +0,0 @@
-position = 0;
- }
-
- function rewind() {
- $this->position = 0;
- }
-
- function current() {
- return $this->array[$this->position];
- }
-
- function key() {
- return 'key_' . $this->position;
- }
-
- function next() {
- ++$this->position;
- }
-
- function valid() {
- return isset($this->array[$this->position]);
- }
-
- function __destruct() {
- echo "~impIterator\n";
- }
-}
-
-class impIterAggr1 implements IteratorAggregate {
- public function getIterator() {
- return new ArrayIterator(new SimpleClass);
- }
- function __destruct() {
- echo "~impIterAggr1\n";
- }
-}
-
-class impIterAggr2 implements IteratorAggregate {
- public function getIterator() {
- return new impIterator();
- }
- function __destruct() {
- echo "~impIterAggr2\n";
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/php/php_alias.sh b/tests/php/php_alias.sh
deleted file mode 100755
index 43931729..00000000
--- a/tests/php/php_alias.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-#!/bin/bash
-#
-# this only alias to comand "/usr/bin/php -d enable_dl=On -d extension_dir=../ext_dir -d extension=extfortest.so"
-# Designed to simplify debugging of tests
-# You can get the same thing using normal aliases: `alias php_alias="php -d enable_dl=On -d extension_dir=../ext_dir -d extension=extfortest.so"`
-# Exemlple toese: $ ./php_alias.sh dbg.php
-#
-
-if [ ! $1 ]
-then
- echo "Required the path to php file"
- exit;
-fi
-
-LD_LIBRARY_PATH="$(cd $PWD/../.. && echo $PWD):${LD_LIBRARY_PATH}"
-export LD_LIBRARY_PATH
-
-/usr/bin/php -d extension_dir=../ext_dir -d extension=extfortest.so -d ini7=47 -d ini1=ReValIni1 -d ini2=ReValIni2 $1 $2 $3 $4 $5
diff --git a/tests/php/phpt/.gitignore b/tests/php/phpt/.gitignore
deleted file mode 100644
index b583a44b..00000000
--- a/tests/php/phpt/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-*.diff
-*.exp
-*.log
-*.out
-*.php
-*.sh
-*.mem
-*.phpt-diff
-*.phpt-exp
-*.phpt-log
-*.phpt-out
-*.phpt-php
-*.phpt-sh
-*.phpt-mem
diff --git a/tests/php/phpt/class_obj/001.phpt b/tests/php/phpt/class_obj/001.phpt
deleted file mode 100644
index b22a44c0..00000000
--- a/tests/php/phpt/class_obj/001.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Test constructor & destructor
---SKIPIF--
-
---FILEEOF--
-
---FILEEOF--
-
---FILEEOF--
-
---FILEEOF--
-
---FILEEOF--
-
---INI--
-ini2=ReValIni2
---FILEEOF--
-
---INI--
-ini2=ReValIni2
-ini6=33
---FILEEOF--
-
- array (
- 'global_value' => 'valIni1',
- 'local_value' => 'valIni1',
- 'access' => 7,
- ),
- 'ini2' =>
- array (
- 'global_value' => 'OrigValIni2',
- 'local_value' => 'ReValIni2',
- 'access' => 7,
- ),
- 'ini3' =>
- array (
- 'global_value' => 'OrigValIni3',
- 'local_value' => 'valIni3',
- 'access' => 4,
- ),
- 'ini4' =>
- array (
- 'global_value' => 'Off',
- 'local_value' => 'On',
- 'access' => 1,
- ),
- 'ini5' =>
- array (
- 'global_value' => 'Off',
- 'local_value' => 'Off',
- 'access' => 7,
- ),
- 'ini6' =>
- array (
- 'global_value' => '11',
- 'local_value' => '33',
- 'access' => 7,
- ),
- 'ini7' =>
- array (
- 'global_value' => '5',
- 'local_value' => '74',
- 'access' => 7,
- ),
- 'ini8' =>
- array (
- 'global_value' => '6.283185',
- 'local_value' => '3.141593',
- 'access' => 7,
- ),
- 'ini9' =>
- array (
- 'global_value' => '5.436564',
- 'local_value' => '2.718282',
- 'access' => 1,
- ),
-)
\ No newline at end of file
diff --git a/tests/php/phpt/ini_entries/003.phpt b/tests/php/phpt/ini_entries/003.phpt
deleted file mode 100644
index 5ad6efb0..00000000
--- a/tests/php/phpt/ini_entries/003.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-Test ini entries #3
---DESCRIPTION--
-Test to check palce action of ini entries
---SKIPIF--
-
---FILEEOF--
-
---FILEEOF--
- 'qweqweqweqw',5,'asd' => '«£¥§©®°±¶⅐⅒⅓⅘⅞Ⅻↆ❄❅❆⚑⚐⌛⌚〰»', 'zxccvx' => 'sdfsecvyh6bug6yfty',);
-
-TestValueIterator\loopValue($arr);
-
-echo PHP_EOL;
---EXPECT--
-Array/Object contains 4 items
-[qwe]=qweqweqweqw
-[0]=5
-[asd]=«£¥§©®°±¶⅐⅒⅓⅘⅞Ⅻↆ❄❅❆⚑⚐⌛⌚〰»
-[zxccvx]=sdfsecvyh6bug6yfty
\ No newline at end of file
diff --git a/tests/php/phpt/valueiterator/002.phpt b/tests/php/phpt/valueiterator/002.phpt
deleted file mode 100644
index fdffdf79..00000000
--- a/tests/php/phpt/valueiterator/002.phpt
+++ /dev/null
@@ -1,22 +0,0 @@
---TEST--
-Iterate object of stdClass
---DESCRIPTION--
-Iterate object of stdClass
---SKIPIF--
-
---FILEEOF--
- 'qweqweqweqw',5,'asd' => '«£¥§©®°±¶⅐⅒⅓⅘⅞Ⅻↆ❄❅❆⚑⚐⌛⌚〰»', 'zxccvx' => 'sdfsecvyh6bug6yfty',);
-$obj = (object)$arr;
-
-TestValueIterator\loopValue($obj);
-
-echo PHP_EOL;
---EXPECT--
-Array/Object contains 0 items
-[qwe]=qweqweqweqw
-[0]=5
-[asd]=«£¥§©®°±¶⅐⅒⅓⅘⅞Ⅻↆ❄❅❆⚑⚐⌛⌚〰»
-[zxccvx]=sdfsecvyh6bug6yfty
\ No newline at end of file
diff --git a/tests/php/phpt/valueiterator/003.phpt b/tests/php/phpt/valueiterator/003.phpt
deleted file mode 100644
index d29d7e59..00000000
--- a/tests/php/phpt/valueiterator/003.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-Iterate object
---DESCRIPTION--
-Iterate regular php object
---SKIPIF--
-
---FILEEOF--
-
---FILEEOF--
-
---FILEEOF--
-
---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
deleted file mode 100644
index 477fbe27..00000000
--- a/tests/php/phpt/variables/003-value-types.phpt
+++ /dev/null
@@ -1,72 +0,0 @@
---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
deleted file mode 100644
index 53cc6814..00000000
--- a/tests/php/phpt/variables/004-store-scalar-variables.phpt
+++ /dev/null
@@ -1,58 +0,0 @@
---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-cast-objects-to-scalars.phpt b/tests/php/phpt/variables/005-cast-objects-to-scalars.phpt
deleted file mode 100644
index 9de9ba55..00000000
--- a/tests/php/phpt/variables/005-cast-objects-to-scalars.phpt
+++ /dev/null
@@ -1,22 +0,0 @@
---TEST--
-cast objects to scalars
---DESCRIPTION--
-http://www.phpcpp.com/documentation/special-features#casting-functions
---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
deleted file mode 100644
index 69507800..00000000
--- a/tests/php/phpt/variables/008-value-arrays.phpt
+++ /dev/null
@@ -1,89 +0,0 @@
---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
deleted file mode 100644
index c45cae8b..00000000
--- a/tests/php/phpt/variables/009-value-object.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---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
deleted file mode 100644
index 8697a696..00000000
--- a/tests/php/phpt/variables/010-value-object2.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---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/011-value-casting-operators.phpt b/tests/php/phpt/variables/011-value-casting-operators.phpt
deleted file mode 100644
index 27e92c7f..00000000
--- a/tests/php/phpt/variables/011-value-casting-operators.phpt
+++ /dev/null
@@ -1,153 +0,0 @@
---TEST--
-Test Php::Value casting operators (64bit OS only)
---DESCRIPTION--
-The Php::Value class has casting operators to cast the object to almost every thinkable native type.
-
-native_value_casting - repeats the behavior of c++ functions TestVariables\value_casting
-the output of each of these functions should be the same
-
-Skip if the current OS is not 64-bit architecture.
-
---SKIPIF--
-
---FILEEOF--
-
---FILEEOF--
-
---FILEEOF--
- 'param1',
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
- 5 =>
- DateTime::__set_state(array(
- 'date' => '2014-03-28 19:42:15',
- 'timezone_type' => 3,
- 'timezone' => 'Asia/Yekaterinburg',
- )),
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
-)userspace function called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
- 9 => 'param10',
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/014-calling-php-functions.phpt b/tests/php/phpt/variables/014-calling-php-functions.phpt
deleted file mode 100644
index 4a05e2a0..00000000
--- a/tests/php/phpt/variables/014-calling-php-functions.phpt
+++ /dev/null
@@ -1,113 +0,0 @@
---TEST--
-calling-php-Callback-functions
---SKIPIF--
-
---FILEEOF--
- 'param1',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
- 5 =>
- DateTime::__set_state(array(
- 'date' => '2014-03-28 19:42:15',
- 'timezone_type' => 3,
- 'timezone' => 'Asia/Yekaterinburg',
- )),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
- 9 => 'param10',
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/015-calling-php-functions.phpt b/tests/php/phpt/variables/015-calling-php-functions.phpt
deleted file mode 100644
index e9382b2c..00000000
--- a/tests/php/phpt/variables/015-calling-php-functions.phpt
+++ /dev/null
@@ -1,109 +0,0 @@
---TEST--
-calling-php-Callback-functions (lambda)
---SKIPIF--
-
---FILEEOF--
- 'param1',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
- 5 =>
- DateTime::__set_state(array(
- 'date' => '2014-03-28 19:42:15',
- 'timezone_type' => 3,
- 'timezone' => 'Asia/Yekaterinburg',
- )),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
- 9 => 'param10',
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/016-calling-php-functions.phpt b/tests/php/phpt/variables/016-calling-php-functions.phpt
deleted file mode 100644
index 46fda6ed..00000000
--- a/tests/php/phpt/variables/016-calling-php-functions.phpt
+++ /dev/null
@@ -1,113 +0,0 @@
---TEST--
-calling-php-Callback-functions (__invoke)
---SKIPIF--
-
---FILEEOF--
- 'param1',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
- 5 =>
- DateTime::__set_state(array(
- 'date' => '2014-03-28 19:42:15',
- 'timezone_type' => 3,
- 'timezone' => 'Asia/Yekaterinburg',
- )),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
- 9 => 'param10',
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/017-calling-php-functions.phpt b/tests/php/phpt/variables/017-calling-php-functions.phpt
deleted file mode 100644
index 630399a5..00000000
--- a/tests/php/phpt/variables/017-calling-php-functions.phpt
+++ /dev/null
@@ -1,115 +0,0 @@
---TEST--
-calling-php-Callback-functions (method of class)
---SKIPIF--
-
---FILEEOF--
- 'param1',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 =>
- array (
- 0 => 'param5',
- 1 => 3.14159265359,
- 2 => 28032014,
- 'key' => 'value',
- ),
- 5 =>
- DateTime::__set_state(array(
- 'date' => '2014-03-28 19:42:15',
- 'timezone_type' => 3,
- 'timezone' => 'Asia/Yekaterinburg',
- )),
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
-)Callback called with parameters:
-array (
- 0 => 'param1',
- 1 => 'param2',
- 2 => 'param3',
- 3 => 'param4',
- 4 => 'param5',
- 5 => 'param6',
- 6 => 'param7',
- 7 => 'param8',
- 8 => 'param9',
- 9 => 'param10',
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/018-calling-php-functions.phpt b/tests/php/phpt/variables/018-calling-php-functions.phpt
deleted file mode 100644
index 1b8bfebd..00000000
--- a/tests/php/phpt/variables/018-calling-php-functions.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-calling-php-callable
---DESCRIPTION--
-call callable object of class from user space
-call method of class from user space
---SKIPIF--
-
---FILEEOF--
-a = $a;}
- public function __invoke($b){ echo "CallableClass({$this->a})::__invoke($b)";}
- private $a = "";
-}
-
-class usrspClass {
- function __construct($a){ $this->a = $a;}
- function someMethod($b) {echo "usrspClass({$this->a})::someMethod($b)";}
- private $a = "";
-}
-
-
-TestVariables\fnFromUserSpace2();
-
-
---EXPECT--
-2014-03-28 21:22:15
-2014-03-28 21:22:15
-usrspClass(Mount Meru)::someMethod(is in the Arctics)
-CallableClass(Arctics around mount Meru)::__invoke(is the birthplace of the Hyperboreans)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/019-HashMember-1.phpt b/tests/php/phpt/variables/019-HashMember-1.phpt
deleted file mode 100644
index ebc126f3..00000000
--- a/tests/php/phpt/variables/019-HashMember-1.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-get_complex_array (test HashMember #1)
---SKIPIF--
-
---FILEEOF--
-
- array (
- 'key2' => 'val2',
- 'key3' => 'val3',
- ),
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/020-HashMember-2.phpt b/tests/php/phpt/variables/020-HashMember-2.phpt
deleted file mode 100644
index bb48d068..00000000
--- a/tests/php/phpt/variables/020-HashMember-2.phpt
+++ /dev/null
@@ -1,76 +0,0 @@
---TEST--
-get_complex_array (test HashMember #2)
---SKIPIF--
-
---FILEEOF--
-
- array (
- 'k3' => 'v1',
- 'k2' =>
- array (
- 'k4' => 'v2',
- ),
- ),
- 'k5' =>
- array (
- 1 => 'v3',
- ),
- 2 =>
- array (
- 'k6' =>
- array (
- 1 => 'v4',
- ),
- ),
- 3 =>
- array (
- 4 =>
- array (
- 1 => 'v5',
- 2 =>
- array (
- 5 =>
- array (
- 7 =>
- array (
- 11 => 'v5',
- 'k' => 'v5',
- ),
- ),
- ),
- ),
- ),
- 'c' =>
- array (
- 0 => 'nested value',
- 1 => NULL,
- 2 =>
- array (
- ),
- 3 => 'example',
- ),
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/021-HashMember-3.phpt b/tests/php/phpt/variables/021-HashMember-3.phpt
deleted file mode 100644
index 20f43ba7..00000000
--- a/tests/php/phpt/variables/021-HashMember-3.phpt
+++ /dev/null
@@ -1,26 +0,0 @@
---TEST--
-get_complex_array (test HashMember #3)
---SKIPIF--
-
---FILEEOF--
-
- array (
- 'key2' => 'val1-2',
- ),
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/022-HashMember-4.phpt b/tests/php/phpt/variables/022-HashMember-4.phpt
deleted file mode 100644
index cbdc8b08..00000000
--- a/tests/php/phpt/variables/022-HashMember-4.phpt
+++ /dev/null
@@ -1,37 +0,0 @@
---TEST--
-get_complex_array (test HashMember #4)
---SKIPIF--
-
---FILEEOF--
-
- array (
- 'key1' =>
- array (
- 'key2' =>
- array (
- 'key3' => 'val',
- ),
- ),
- ),
- 1 =>
- array (
- 'str1' => 'example',
- 'str2' => 'example',
- ),
- 2 =>
- array (
- 'str1' =>
- array (
- 'str2' => 'val1-2',
- 'str3' => 'val1-3',
- ),
- ),
-)
\ No newline at end of file
diff --git a/tests/php/phpt/variables/023-cookie.phpt b/tests/php/phpt/variables/023-cookie.phpt
deleted file mode 100644
index 06481885..00000000
--- a/tests/php/phpt/variables/023-cookie.phpt
+++ /dev/null
@@ -1,16 +0,0 @@
---TEST--
-test cookie
---SKIPIF--
-
---COOKIE--
-peace=toTheWorld;freedom=toThePeople
---FILEEOF--
-
---GET--
-a=test&b=http://phpcpp.com&ar[elm1]=1234&ar[elm2]=0660&a=0234
---POST--
-c=string
&d=12345.7&e[]=e1&e[]=e2
---FILEEOF--
-string
-_POST[d] = 12345.7
-
-Notice: Array to string conversion in %s/024-get-post.php on line %d
-_POST[e] = Array
-_POST[e][0] = e1
-_POST[e][1] = e2
\ No newline at end of file
diff --git a/tests/php/phpt/variables/025-post-raw1.phpt b/tests/php/phpt/variables/025-post-raw1.phpt
deleted file mode 100644
index 76fed0ff..00000000
--- a/tests/php/phpt/variables/025-post-raw1.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-test post raw #1
---SKIPIF--
-
---POST_RAW--
-Content-type: multipart/form-data, boundary=AaB03x
-
---AaB03x
-content-disposition: form-data; name="username"
-
-valmat
---AaB03x
-content-disposition: form-data; name="text"
-
-Hellow World!
---AaB03x
---FILEEOF--
- $v) {echo "\n$k => $v";}
-
---EXPECTF--
-username => valmat
-text => Hellow World!
\ No newline at end of file
diff --git a/tests/php/phpt/variables/026-post-raw2.phpt b/tests/php/phpt/variables/026-post-raw2.phpt
deleted file mode 100644
index 4bee44c5..00000000
--- a/tests/php/phpt/variables/026-post-raw2.phpt
+++ /dev/null
@@ -1,38 +0,0 @@
---TEST--
-Post files
---DESCRIPTION--
-Simulates the file upload method post
-test post raw #2
---SKIPIF--
-
---POST_RAW--
-Content-type: multipart/form-data, boundary=AaB03x
-
---AaB03x
-content-disposition: form-data; name="flnm[]"; filename="file1.txt"
-Content-Type: text/plain
-
-abcdef123456789
---AaB03x
-content-disposition: form-data; name="flnm[]"; filename="file2.txt"
-Content-Type: text/plain
-
-«£¥§©®°±¶Я⅓⅘⅞Ⅻↆ❄❅❆⚑⚐⌛⌚〰»
---AaB03x
---FILEEOF--
-
---ENV--
-return << Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0
-ENVVAR1 => ENVVAL1
-HTTP_REFERER => http://spb.1gs.ru/
-REQUEST_METHOD => GET
-HTTP_HOST => phpcpp.com
diff --git a/tests/php/phpt/variables/028-compare1.phpt b/tests/php/phpt/variables/028-compare1.phpt
deleted file mode 100644
index 2885fe8f..00000000
--- a/tests/php/phpt/variables/028-compare1.phpt
+++ /dev/null
@@ -1,53 +0,0 @@
---TEST--
-Test bool Value::operator==(const Value &value) const
---SKIPIF--
-
---FILEEOF--
-
---FILEEOF--
-
-#
-
-# Local directory in which to copy the links to all installed extensions
-EXTDLOC=ext_dir
-mkdir -p "./$EXTDLOC"
-
-SO=extfortest.so
-
-# to check whether specified the extension name as parameter
-if [ $1 ]
-then
- SO=$1
-fi
-
-# a directory of extensions already installed in the operating system
-EXTDIR=$(php-config --extension-dir)
-
-# To copy references for all extensions to the local directory
-for LIBFILE in `find $EXTDIR -type f -or -type l -name "*.so"`; do
-
- BN=$(basename $LIBFILE)
- NF="$PWD/$EXTDLOC/$BN"
-
- # if still no exist
- if [ ! -L $NF ];
- then
- if [ -L $LIBFILE ];
- then
- cp --no-dereference $LIBFILE $NF
- else
- ln -s $LIBFILE $NF
- fi
- else
- :
- fi;
-done
-
-# current extention
-if [ ! -L "$PWD/$EXTDLOC/$SO" ]
-then
- ln -s "$PWD/cpp/$SO" "$PWD/$EXTDLOC/$SO"
-fi
-
-
diff --git a/tests/readme b/tests/readme
deleted file mode 100644
index 929f1b96..00000000
--- a/tests/readme
+++ /dev/null
@@ -1,7 +0,0 @@
-In this directory cpp extension is designed to conduct tests.
-When creating a test, do not use extension requiring the installation.
-In the directory php are the tests themselves.
-
-You can run test.sh with additional options.
-The full list of available options see ./test.sh -h
-
diff --git a/tests/run-tests.php b/tests/run-tests.php
deleted file mode 100644
index 798d2187..00000000
--- a/tests/run-tests.php
+++ /dev/null
@@ -1,2840 +0,0 @@
-#!/usr/bin/env php
- |
- | Preston L. Bannister |
- | Marcus Boerger |
- | Derick Rethans |
- | Sander Roobol |
- | (based on version by: Stig Bakken ) |
- | (based on the PHP 3 test framework by Rasmus Lerdorf) |
- +----------------------------------------------------------------------+
- */
-
-/* $Id: 8c8df610b8c02d53213033b0dbdcc3464143c2d5 $ */
-
-/* Sanity check to ensure that pcre extension needed by this script is available.
- * In the event it is not, print a nice error message indicating that this script will
- * not run without it.
- */
-
-if (!extension_loaded('pcre')) {
- echo <<';
- save_text($info_file, $php_info);
- $info_params = array();
- settings2array($ini_overwrites, $info_params);
- settings2params($info_params);
- $php_info = `$php $pass_options $info_params "$info_file"`;
- define('TESTED_PHP_VERSION', `$php -n -r "echo PHP_VERSION;"`);
-
- if ($php_cgi && $php != $php_cgi) {
- $php_info_cgi = `$php_cgi $pass_options $info_params -q "$info_file"`;
- $php_info_sep = "\n---------------------------------------------------------------------";
- $php_cgi_info = "$php_info_sep\nPHP : $php_cgi $php_info_cgi$php_info_sep";
- } else {
- $php_cgi_info = '';
- }
-
- @unlink($info_file);
-
- // load list of enabled extensions
- save_text($info_file, '');
- $exts_to_test = explode(',',`$php $pass_options $info_params "$info_file"`);
- // check for extensions that need special handling and regenerate
- $info_params_ex = array(
- 'session' => array('session.auto_start=0'),
- 'tidy' => array('tidy.clean_output=0'),
- 'zlib' => array('zlib.output_compression=Off'),
- 'xdebug' => array('xdebug.default_enable=0'),
- 'mbstring' => array('mbstring.func_overload=0'),
- );
-
- foreach($info_params_ex as $ext => $ini_overwrites_ex) {
- if (in_array($ext, $exts_to_test)) {
- $ini_overwrites = array_merge($ini_overwrites, $ini_overwrites_ex);
- }
- }
-
- @unlink($info_file);
-
- // Write test context information.
- echo "
-=====================================================================
-PHP : $php $php_info $php_cgi_info
-CWD : $cwd
-Extra dirs : ";
- foreach ($user_tests as $test_dir) {
- echo "{$test_dir}\n ";
- }
- echo "
-VALGRIND : " . ($leak_check ? $valgrind_header : 'Not used') . "
-=====================================================================
-";
-}
-
-//define('PHP_QA_EMAIL', 'qa-reports@lists.php.net');
-define('PHP_QA_EMAIL', 'fsp-vlm@yandex.ru');
-define('QA_SUBMISSION_PAGE', 'http://qa.php.net/buildtest-process.php');
-define('QA_REPORTS_PAGE', 'http://qa.php.net/reports');
-define('TRAVIS_CI' , (bool) getenv('TRAVIS_PHP_VERSION'));
-
-function save_or_mail_results()
-{
- global $sum_results, $just_save_results, $failed_test_summary,
- $PHP_FAILED_TESTS, $CUR_DIR, $php, $output_file, $compression;
-
- /* We got failed Tests, offer the user to send an e-mail to QA team, unless NO_INTERACTION is set */
- if (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
- $fp = fopen("php://stdin", "r+");
- if ($sum_results['FAILED'] || $sum_results['BORKED'] || $sum_results['WARNED'] || $sum_results['LEAKED'] || $sum_results['XFAILED']) {
- echo "\nYou may have found a problem in PHP.";
- }
- echo "\nThis report can be automatically sent to the PHP QA team at\n";
- echo QA_REPORTS_PAGE . " and http://news.php.net/php.qa.reports\n";
- echo "This gives us a better understanding of PHP's behavior.\n";
- echo "If you don't want to send the report immediately you can choose\n";
- echo "option \"s\" to save it. You can then email it to ". PHP_QA_EMAIL . " later.\n";
- echo "Do you want to send this report now? [Yns]: ";
- flush();
-
- $user_input = fgets($fp, 10);
- $just_save_results = (strtolower($user_input[0]) == 's');
- }
-
- if ($just_save_results || !getenv('NO_INTERACTION') || TRAVIS_CI) {
- if ($just_save_results || TRAVIS_CI || strlen(trim($user_input)) == 0 || strtolower($user_input[0]) == 'y') {
- /*
- * Collect information about the host system for our report
- * Fetch phpinfo() output so that we can see the PHP enviroment
- * Make an archive of all the failed tests
- * Send an email
- */
- if ($just_save_results) {
- $user_input = 's';
- }
-
- /* Ask the user to provide an email address, so that QA team can contact the user */
- if (TRAVIS_CI) {
- $user_email = 'travis at php dot net';
- } elseif (!strncasecmp($user_input, 'y', 1) || strlen(trim($user_input)) == 0) {
- echo "\nPlease enter your email address.\n(Your address will be mangled so that it will not go out on any\nmailinglist in plain text): ";
- flush();
- $user_email = trim(fgets($fp, 1024));
- $user_email = str_replace("@", " at ", str_replace(".", " dot ", $user_email));
- }
-
- $failed_tests_data = '';
- $sep = "\n" . str_repeat('=', 80) . "\n";
- $failed_tests_data .= $failed_test_summary . "\n";
- $failed_tests_data .= get_summary(true, false) . "\n";
-
- if ($sum_results['FAILED']) {
- foreach ($PHP_FAILED_TESTS['FAILED'] as $test_info) {
- $failed_tests_data .= $sep . $test_info['name'] . $test_info['info'];
- $failed_tests_data .= $sep . file_get_contents(realpath($test_info['output']), FILE_BINARY);
- $failed_tests_data .= $sep . file_get_contents(realpath($test_info['diff']), FILE_BINARY);
- $failed_tests_data .= $sep . "\n\n";
- }
- $status = "failed";
- } else {
- $status = "success";
- }
-
- $failed_tests_data .= "\n" . $sep . 'BUILD ENVIRONMENT' . $sep;
- $failed_tests_data .= "OS:\n" . PHP_OS . " - " . php_uname() . "\n\n";
- $ldd = $autoconf = $sys_libtool = $libtool = $compiler = 'N/A';
-
- if (substr(PHP_OS, 0, 3) != "WIN") {
- /* If PHP_AUTOCONF is set, use it; otherwise, use 'autoconf'. */
- if (getenv('PHP_AUTOCONF')) {
- $autoconf = shell_exec(getenv('PHP_AUTOCONF') . ' --version');
- } else {
- $autoconf = shell_exec('autoconf --version');
- }
-
- /* Always use the generated libtool - Mac OSX uses 'glibtool' */
- $libtool = shell_exec($CUR_DIR . '/libtool --version');
-
- /* Use shtool to find out if there is glibtool present (MacOSX) */
- $sys_libtool_path = shell_exec(__DIR__ . '/build/shtool path glibtool libtool');
-
- if ($sys_libtool_path) {
- $sys_libtool = shell_exec(str_replace("\n", "", $sys_libtool_path) . ' --version');
- }
-
- /* Try the most common flags for 'version' */
- $flags = array('-v', '-V', '--version');
- $cc_status = 0;
-
- foreach($flags AS $flag) {
- system(getenv('CC') . " $flag >/dev/null 2>&1", $cc_status);
- if ($cc_status == 0) {
- $compiler = shell_exec(getenv('CC') . " $flag 2>&1");
- break;
- }
- }
-
- $ldd = shell_exec("ldd $php 2>/dev/null");
- }
-
- $failed_tests_data .= "Autoconf:\n$autoconf\n";
- $failed_tests_data .= "Bundled Libtool:\n$libtool\n";
- $failed_tests_data .= "System Libtool:\n$sys_libtool\n";
- $failed_tests_data .= "Compiler:\n$compiler\n";
- $failed_tests_data .= "Bison:\n". shell_exec('bison --version 2>/dev/null') . "\n";
- $failed_tests_data .= "Libraries:\n$ldd\n";
- $failed_tests_data .= "\n";
-
- if (isset($user_email)) {
- $failed_tests_data .= "User's E-mail: " . $user_email . "\n\n";
- }
-
- $failed_tests_data .= $sep . "PHPINFO" . $sep;
- $failed_tests_data .= shell_exec($php . ' -ddisplay_errors=stderr -dhtml_errors=0 -i 2> /dev/null');
-
- if ($just_save_results || !mail_qa_team($failed_tests_data, $compression, $status) && !TRAVIS_CI) {
- file_put_contents($output_file, $failed_tests_data);
-
- if (!$just_save_results) {
- echo "\nThe test script was unable to automatically send the report to PHP's QA Team\n";
- }
-
- echo "Please send " . $output_file . " to " . PHP_QA_EMAIL . " manually, thank you.\n";
- } elseif (!getenv('NO_INTERACTION') && !TRAVIS_CI) {
- fwrite($fp, "\nThank you for helping to make PHP better.\n");
- fclose($fp);
- }
- }
- }
-}
-
-// Determine the tests to be run.
-
-$test_files = array();
-$redir_tests = array();
-$test_results = array();
-$PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array(), 'WARNED' => array(), 'LEAKED' => array(), 'XFAILED' => array());
-
-// If parameters given assume they represent selected tests to run.
-$failed_tests_file= false;
-$pass_option_n = false;
-$pass_options = '';
-
-$compression = 0;
-$output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . '.txt';
-
-if ($compression) {
- $output_file = 'compress.zlib://' . $output_file . '.gz';
-}
-
-$just_save_results = false;
-$leak_check = false;
-$html_output = false;
-$html_file = null;
-$temp_source = null;
-$temp_target = null;
-$temp_urlbase = null;
-$conf_passed = null;
-$no_clean = false;
-
-$cfgtypes = array('show', 'keep');
-$cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp');
-$cfg = array();
-
-foreach($cfgtypes as $type) {
- $cfg[$type] = array();
-
- foreach($cfgfiles as $file) {
- $cfg[$type][$file] = false;
- }
-}
-
-if (getenv('TEST_PHP_ARGS')) {
-
- if (!isset($argc) || !$argc || !isset($argv)) {
- $argv = array(__FILE__);
- }
-
- $argv = array_merge($argv, explode(' ', getenv('TEST_PHP_ARGS')));
- $argc = count($argv);
-}
-
-if (isset($argc) && $argc > 1) {
-
- //var_export($argv);
- //exit;
-
- for ($i=1; $i<$argc; $i++) {
- $is_switch = false;
- $switch = substr($argv[$i],1,1);
- $repeat = substr($argv[$i],0,1) == '-';
-
- while ($repeat) {
-
- if (!$is_switch) {
- $switch = substr($argv[$i],1,1);
- }
-
- $is_switch = true;
-
- if ($repeat) {
- foreach($cfgtypes as $type) {
- if (strpos($switch, '--' . $type) === 0) {
- foreach($cfgfiles as $file) {
- if ($switch == '--' . $type . '-' . $file) {
- $cfg[$type][$file] = true;
- $is_switch = false;
- break;
- }
- }
- }
- }
- }
-
- if (!$is_switch) {
- $is_switch = true;
- break;
- }
-
- $repeat = false;
-
- switch($switch) {
- case 'r':
- case 'l':
- $test_list = file($argv[++$i]);
- if ($test_list) {
- foreach($test_list as $test) {
- $matches = array();
- if (preg_match('/^#.*\[(.*)\]\:\s+(.*)$/', $test, $matches)) {
- $redir_tests[] = array($matches[1], $matches[2]);
- } else if (strlen($test)) {
- $test_files[] = trim($test);
- }
- }
- }
- if ($switch != 'l') {
- break;
- }
- $i--;
- // break left intentionally
- case 'w':
- $failed_tests_file = fopen($argv[++$i], 'w+t');
- break;
- case 'a':
- $failed_tests_file = fopen($argv[++$i], 'a+t');
- break;
- case 'c':
- $conf_passed = $argv[++$i];
- break;
- case 'd':
- $ini_overwrites[] = $argv[++$i];
- break;
- case 'g':
- $SHOW_ONLY_GROUPS = explode(",", $argv[++$i]);;
- break;
- //case 'h'
- case '--keep-all':
- foreach($cfgfiles as $file) {
- $cfg['keep'][$file] = true;
- }
- break;
- //case 'l'
- case 'm':
- $leak_check = true;
- $valgrind_cmd = "valgrind --version";
- $valgrind_header = system_with_timeout($valgrind_cmd, $environment);
- $replace_count = 0;
- if (!$valgrind_header) {
- error("Valgrind returned no version info, cannot proceed.\nPlease check if Valgrind is installed.");
- } else {
- $valgrind_version = preg_replace("/valgrind-([0-9])\.([0-9])\.([0-9]+)([.-\w]+)?(\s+)/", '$1$2$3', $valgrind_header, 1, $replace_count);
- if ($replace_count != 1 || !is_numeric($valgrind_version)) {
- error("Valgrind returned invalid version info (\"$valgrind_header\"), cannot proceed.");
- }
- $valgrind_header = trim($valgrind_header);
- }
- break;
- case 'n':
- if (!$pass_option_n) {
- $pass_options .= ' -n';
- }
- $pass_option_n = true;
- break;
- case '--no-clean':
- $no_clean = true;
- break;
- case 'p':
- $php = $argv[++$i];
- //var_export($argv);
- //var_export($php);
- //exit;
- putenv("TEST_PHP_EXECUTABLE=$php");
- $environment['TEST_PHP_EXECUTABLE'] = $php;
- break;
- case 'q':
- putenv('NO_INTERACTION=1');
- break;
- //case 'r'
- case 's':
- $output_file = $argv[++$i];
- $just_save_results = true;
- break;
- case '--set-timeout':
- $environment['TEST_TIMEOUT'] = $argv[++$i];
- break;
- case '--show-all':
- foreach($cfgfiles as $file) {
- $cfg['show'][$file] = true;
- }
- break;
- case '--temp-source':
- $temp_source = $argv[++$i];
- break;
- case '--temp-target':
- $temp_target = $argv[++$i];
- if ($temp_urlbase) {
- $temp_urlbase = $temp_target;
- }
- break;
- case '--temp-urlbase':
- $temp_urlbase = $argv[++$i];
- break;
- case 'v':
- case '--verbose':
- $DETAILED = true;
- break;
- case 'x':
- $environment['SKIP_SLOW_TESTS'] = 1;
- break;
- case '--offline':
- $environment['SKIP_ONLINE_TESTS'] = 1;
- break;
- //case 'w'
- case '-':
- // repeat check with full switch
- $switch = $argv[$i];
- if ($switch != '-') {
- $repeat = true;
- }
- break;
- case '--html':
- $html_file = fopen($argv[++$i], 'wt');
- $html_output = is_resource($html_file);
- break;
- case '--version':
- echo '$Id: 8c8df610b8c02d53213033b0dbdcc3464143c2d5 $' . "\n";
- exit(1);
-
- default:
- echo "Illegal switch '$switch' specified!\n";
- case 'h':
- case '-help':
- case '--help':
- echo << Read the testfiles to be executed from . After the test
- has finished all failed tests are written to the same .
- If the list is empty and no further test is specified then
- all tests are executed (same as: -r -w ).
-
- -r Read the testfiles to be executed from .
-
- -w Write a list of all failed tests to .
-
- -a Same as -w but append rather then truncating .
-
- -c Look for php.ini in directory or use as ini.
-
- -n Pass -n option to the php binary (Do not use a php.ini).
-
- -d foo=bar Pass -d option to the php binary (Define INI entry foo
- with value 'bar').
-
- -g Comma separated list of groups to show during test run
- (possible values: PASS, FAIL, XFAIL, SKIP, BORK, WARN, LEAK, REDIRECT).
-
- -m Test for memory leaks with Valgrind.
-
- -p Specify PHP executable to run.
-
- -q Quiet, no user interaction (same as environment NO_INTERACTION).
-
- -s Write output to .
-
- -x Sets 'SKIP_SLOW_TESTS' environmental variable.
-
- --offline Sets 'SKIP_ONLINE_TESTS' environmental variable.
-
- --verbose
- -v Verbose mode.
-
- --help
- -h This Help.
-
- --html Generate HTML output.
-
- --temp-source --temp-target [--temp-urlbase ]
- Write temporary files to by replacing from the
- filenames to generate with . If --html is being used and
- given then the generated links are relative and prefixed
- with the given url. In general you want to make the path
- to your source files and some pach in your web page
- hierarchy with pointing to .
-
- --keep-[all|php|skip|clean]
- Do not delete 'all' files, 'php' test file, 'skip' or 'clean'
- file.
-
- --set-timeout [n]
- Set timeout for individual tests, where [n] is the number of
- seconds. The default value is 60 seconds, or 300 seconds when
- testing for memory leaks.
-
- --show-[all|php|skip|clean|exp|diff|out]
- Show 'all' files, 'php' test file, 'skip' or 'clean' file. You
- can also use this to show the output 'out', the expected result
- 'exp' or the difference between them 'diff'. The result types
- get written independent of the log format, however 'diff' only
- exists when a test fails.
-
- --no-clean Do not execute clean section if any.
-
-HELP;
- exit(1);
- }
- }
-
- if (!$is_switch) {
- $testfile = realpath($argv[$i]);
-
- if (!$testfile && strpos($argv[$i], '*') !== false && function_exists('glob')) {
-
- if (preg_match("/\.phpt$/", $argv[$i])) {
- $pattern_match = glob($argv[$i]);
- } else if (preg_match("/\*$/", $argv[$i])) {
- $pattern_match = glob($argv[$i] . '.phpt');
- } else {
- die("bogus test name " . $argv[$i] . "\n");
- }
-
- if (is_array($pattern_match)) {
- $test_files = array_merge($test_files, $pattern_match);
- }
-
- } else if (is_dir($testfile)) {
- find_files($testfile);
- } else if (preg_match("/\.phpt\-?$/", $testfile)) {
- $test_files[] = $testfile;
- } else {
- die("bogus test name " . $argv[$i] . "\n");
- }
- }
- }
-
- if (strlen($conf_passed)) {
- if (substr(PHP_OS, 0, 3) == "WIN") {
- $pass_options .= " -c " . escapeshellarg($conf_passed);
- } else {
- $pass_options .= " -c '$conf_passed'";
- }
- }
-
- $test_files = array_unique($test_files);
- $test_files = array_merge($test_files, $redir_tests);
-
- // Run selected tests.
- $test_cnt = count($test_files);
-
- if ($test_cnt) {
- putenv('NO_INTERACTION=1');
- verify_config();
- write_information($html_output);
- usort($test_files, "test_sort");
- $start_time = time();
-
- if (!$html_output) {
- echo "Running selected tests.\n";
- } else {
- show_start($start_time);
- }
-
- $test_idx = 0;
- run_all_tests($test_files, $environment);
- $end_time = time();
-
- if ($html_output) {
- show_end($end_time);
- }
-
- if ($failed_tests_file) {
- fclose($failed_tests_file);
- }
-
- compute_summary();
- if ($html_output) {
- fwrite($html_file, "
\n" . get_summary(false, true));
- }
- echo "=====================================================================";
- echo get_summary(false, false);
-
- if ($html_output) {
- fclose($html_file);
- }
-
- if ($output_file != '' && $just_save_results) {
- save_or_mail_results();
- }
-
- junit_save_xml();
-
- if (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {
- exit(1);
- }
-
- exit(0);
- }
-}
-
-verify_config();
-write_information($html_output);
-
-// Compile a list of all test files (*.phpt).
-$test_files = array();
-$exts_tested = count($exts_to_test);
-$exts_skipped = 0;
-$ignored_by_ext = 0;
-sort($exts_to_test);
-$test_dirs = array();
-$optionals = array('tests', 'ext', 'Zend', 'ZendEngine2', 'sapi/cli', 'sapi/cgi');
-
-foreach($optionals as $dir) {
- if (@filetype($dir) == 'dir') {
- $test_dirs[] = $dir;
- }
-}
-
-// Convert extension names to lowercase
-foreach ($exts_to_test as $key => $val) {
- $exts_to_test[$key] = strtolower($val);
-}
-
-foreach ($test_dirs as $dir) {
- find_files("{$cwd}/{$dir}", ($dir == 'ext'));
-}
-
-foreach ($user_tests as $dir) {
- find_files($dir, ($dir == 'ext'));
-}
-
-function find_files($dir, $is_ext_dir = false, $ignore = false)
-{
- global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, $exts_tested;
-
- $o = opendir($dir) or error("cannot open directory: $dir");
-
- while (($name = readdir($o)) !== false) {
-
- if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', '.svn'))) {
- $skip_ext = ($is_ext_dir && !in_array(strtolower($name), $exts_to_test));
- if ($skip_ext) {
- $exts_skipped++;
- }
- find_files("{$dir}/{$name}", false, $ignore || $skip_ext);
- }
-
- // Cleanup any left-over tmp files from last run.
- if (substr($name, -4) == '.tmp') {
- @unlink("$dir/$name");
- continue;
- }
-
- // Otherwise we're only interested in *.phpt files.
- if (substr($name, -5) == '.phpt') {
- if ($ignore) {
- $ignored_by_ext++;
- } else {
- $testfile = realpath("{$dir}/{$name}");
- $test_files[] = $testfile;
- }
- }
- }
-
- closedir($o);
-}
-
-function test_name($name)
-{
- if (is_array($name)) {
- return $name[0] . ':' . $name[1];
- } else {
- return $name;
- }
-}
-
-function test_sort($a, $b)
-{
- global $cwd;
-
- $a = test_name($a);
- $b = test_name($b);
-
- $ta = strpos($a, "{$cwd}/tests") === 0 ? 1 + (strpos($a, "{$cwd}/tests/run-test") === 0 ? 1 : 0) : 0;
- $tb = strpos($b, "{$cwd}/tests") === 0 ? 1 + (strpos($b, "{$cwd}/tests/run-test") === 0 ? 1 : 0) : 0;
-
- if ($ta == $tb) {
- return strcmp($a, $b);
- } else {
- return $tb - $ta;
- }
-}
-
-$test_files = array_unique($test_files);
-usort($test_files, "test_sort");
-
-$start_time = time();
-show_start($start_time);
-
-$test_cnt = count($test_files);
-$test_idx = 0;
-run_all_tests($test_files, $environment);
-$end_time = time();
-
-if ($failed_tests_file) {
- fclose($failed_tests_file);
-}
-
-// Summarize results
-
-if (0 == count($test_results)) {
- echo "No tests were run.\n";
- return;
-}
-
-compute_summary();
-
-show_end($end_time);
-show_summary();
-
-if ($html_output) {
- fclose($html_file);
-}
-
-save_or_mail_results();
-
-junit_save_xml();
-
-if (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {
- exit(1);
-}
-exit(0);
-
-//
-// Send Email to QA Team
-//
-
-function mail_qa_team($data, $compression, $status = false)
-{
- $url_bits = parse_url(QA_SUBMISSION_PAGE);
-
- if (($proxy = getenv('http_proxy'))) {
- $proxy = parse_url($proxy);
- $path = $url_bits['host'].$url_bits['path'];
- $host = $proxy['host'];
- if (empty($proxy['port'])) {
- $proxy['port'] = 80;
- }
- $port = $proxy['port'];
- } else {
- $path = $url_bits['path'];
- $host = $url_bits['host'];
- $port = empty($url_bits['port']) ? 80 : $port = $url_bits['port'];
- }
-
- $data = "php_test_data=" . urlencode(base64_encode(str_replace("\00", '[0x0]', $data)));
- $data_length = strlen($data);
-
- $fs = fsockopen($host, $port, $errno, $errstr, 10);
-
- if (!$fs) {
- return false;
- }
-
- $php_version = urlencode(TESTED_PHP_VERSION);
-
- echo "\nPosting to ". QA_SUBMISSION_PAGE . "\n";
- fwrite($fs, "POST " . $path . "?status=$status&version=$php_version HTTP/1.1\r\n");
- fwrite($fs, "Host: " . $host . "\r\n");
- fwrite($fs, "User-Agent: QA Browser 0.1\r\n");
- fwrite($fs, "Content-Type: application/x-www-form-urlencoded\r\n");
- fwrite($fs, "Content-Length: " . $data_length . "\r\n\r\n");
- fwrite($fs, $data);
- fwrite($fs, "\r\n\r\n");
- fclose($fs);
-
- return 1;
-}
-
-
-//
-// Write the given text to a temporary file, and return the filename.
-//
-
-function save_text($filename, $text, $filename_copy = null)
-{
- global $DETAILED;
-
- if ($filename_copy && $filename_copy != $filename) {
- if (file_put_contents($filename_copy, $text, FILE_BINARY) === false) {
- error("Cannot open file '" . $filename_copy . "' (save_text)");
- }
- }
-
- if (file_put_contents($filename, $text, FILE_BINARY) === false) {
- error("Cannot open file '" . $filename . "' (save_text)");
- }
-
- if (1 < $DETAILED) echo "
-FILE $filename {{{
-$text
-}}}
-";
-}
-
-//
-// Write an error in a format recognizable to Emacs or MSVC.
-//
-
-function error_report($testname, $logname, $tested)
-{
- $testname = realpath($testname);
- $logname = realpath($logname);
-
- switch (strtoupper(getenv('TEST_PHP_ERROR_STYLE'))) {
- case 'MSVC':
- echo $testname . "(1) : $tested\n";
- echo $logname . "(1) : $tested\n";
- break;
- case 'EMACS':
- echo $testname . ":1: $tested\n";
- echo $logname . ":1: $tested\n";
- break;
- }
-}
-
-function system_with_timeout($commandline, $env = null, $stdin = null)
-{
- /*
- * Fixed for tests extension without installation
- * extension_for_tests
- */
- if(isset($_SERVER["LD_LIBRARY_PATH"])) {
- $env['LD_LIBRARY_PATH'] = $_SERVER["LD_LIBRARY_PATH"];
- }
-
- global $leak_check, $cwd;
-
- $data = '';
-
- $bin_env = array();
- foreach((array)$env as $key => $value) {
- $bin_env[$key] = $value;
- }
-
- $proc = proc_open($commandline, array(
- 0 => array('pipe', 'r'),
- 1 => array('pipe', 'w'),
- 2 => array('pipe', 'w')
- ), $pipes, $cwd, $bin_env, array('suppress_errors' => true, 'binary_pipes' => true));
-
- if (!$proc) {
- return false;
- }
-
- if (!is_null($stdin)) {
- fwrite($pipes[0], $stdin);
- }
- fclose($pipes[0]);
-
- $timeout = $leak_check ? 300 : (isset($env['TEST_TIMEOUT']) ? $env['TEST_TIMEOUT'] : 60);
-
- while (true) {
- /* hide errors from interrupted syscalls */
- $r = $pipes;
- $w = null;
- $e = null;
-
- $n = @stream_select($r, $w, $e, $timeout);
-
- if ($n === false) {
- break;
- } else if ($n === 0) {
- /* timed out */
- $data .= "\n ** ERROR: process timed out **\n";
- proc_terminate($proc, 9);
- return $data;
- } else if ($n > 0) {
- $line = fread($pipes[1], 8192);
- if (strlen($line) == 0) {
- /* EOF */
- break;
- }
- $data .= $line;
- }
- }
-
- $stat = proc_get_status($proc);
-
- if ($stat['signaled']) {
- $data .= "\nTermsig=" . $stat['stopsig'];
- }
-
- $code = proc_close($proc);
- return $data;
-}
-
-function run_all_tests($test_files, $env, $redir_tested = null)
-{
- global $test_results, $failed_tests_file, $php, $test_cnt, $test_idx;
-
- foreach($test_files as $name) {
-
- if (is_array($name)) {
- $index = "# $name[1]: $name[0]";
-
- if ($redir_tested) {
- $name = $name[0];
- }
- } else if ($redir_tested) {
- $index = "# $redir_tested: $name";
- } else {
- $index = $name;
- }
- $test_idx++;
- $result = run_test($php, $name, $env);
-
- if (!is_array($name) && $result != 'REDIR') {
- $test_results[$index] = $result;
- if ($failed_tests_file && ($result == 'XFAILED' || $result == 'FAILED' || $result == 'WARNED' || $result == 'LEAKED')) {
- fwrite($failed_tests_file, "$index\n");
- }
- }
- }
-}
-
-//
-// Show file or result block
-//
-function show_file_block($file, $block, $section = null)
-{
- global $cfg;
-
- if ($cfg['show'][$file]) {
-
- if (is_null($section)) {
- $section = strtoupper($file);
- }
-
- echo "\n========" . $section . "========\n";
- echo rtrim($block);
- echo "\n========DONE========\n";
- }
-}
-
-//
-// Run an individual test case.
-//
-function run_test($php, $file, $env)
-{
- global $log_format, $info_params, $ini_overwrites, $cwd, $PHP_FAILED_TESTS;
- global $pass_options, $DETAILED, $IN_REDIRECT, $test_cnt, $test_idx;
- global $leak_check, $temp_source, $temp_target, $cfg, $environment;
- global $no_clean;
- global $valgrind_version;
- global $JUNIT;
- $temp_filenames = null;
- $org_file = $file;
-
- if (isset($env['TEST_PHP_CGI_EXECUTABLE'])) {
- $php_cgi = $env['TEST_PHP_CGI_EXECUTABLE'];
- }
-
- if (is_array($file)) {
- $file = $file[0];
- }
-
- if ($DETAILED) echo "
-=================
-TEST $file
-";
-
- // Load the sections of the test file.
- $section_text = array('TEST' => '');
-
- $fp = fopen($file, "rb") or error("Cannot open test file: $file");
-
- $borked = false;
- $bork_info = '';
-
- if (!feof($fp)) {
- $line = fgets($fp);
-
- if ($line === false) {
- $bork_info = "cannot read test";
- $borked = true;
- }
- } else {
- $bork_info = "empty test [$file]";
- $borked = true;
- }
- if (!$borked && strncmp('--TEST--', $line, 8)) {
- $bork_info = "tests must start with --TEST-- [$file]";
- $borked = true;
- }
-
- $section = 'TEST';
- $secfile = false;
- $secdone = false;
-
- while (!feof($fp)) {
- $line = fgets($fp);
-
- if ($line === false) {
- break;
- }
-
- // Match the beginning of a section.
- if (preg_match('/^--([_A-Z]+)--/', $line, $r)) {
- $section = $r[1];
- settype($section, 'string');
-
- if (isset($section_text[$section])) {
- $bork_info = "duplicated $section section";
- $borked = true;
- }
-
- $section_text[$section] = '';
- $secfile = $section == 'FILE' || $section == 'FILEEOF' || $section == 'FILE_EXTERNAL';
- $secdone = false;
- continue;
- }
-
- // Add to the section text.
- if (!$secdone) {
- $section_text[$section] .= $line;
- }
-
- // End of actual test?
- if ($secfile && preg_match('/^===DONE===\s*$/', $line)) {
- $secdone = true;
- }
- }
-
- // the redirect section allows a set of tests to be reused outside of
- // a given test dir
- if (!$borked) {
- if (@count($section_text['REDIRECTTEST']) == 1) {
-
- if ($IN_REDIRECT) {
- $borked = true;
- $bork_info = "Can't redirect a test from within a redirected test";
- } else {
- $borked = false;
- }
-
- } else {
-
- if (@count($section_text['FILE']) + @count($section_text['FILEEOF']) + @count($section_text['FILE_EXTERNAL']) != 1) {
- $bork_info = "missing section --FILE--";
- $borked = true;
- }
-
- if (@count($section_text['FILEEOF']) == 1) {
- $section_text['FILE'] = preg_replace("/[\r\n]+$/", '', $section_text['FILEEOF']);
- unset($section_text['FILEEOF']);
- }
-
- if (@count($section_text['FILE_EXTERNAL']) == 1) {
- // don't allow tests to retrieve files from anywhere but this subdirectory
- //var_export([dirname($file),$section_text['FILE_EXTERNAL'] ]);
- //$section_text['FILE_EXTERNAL'] = dirname($file) . '/' . trim(str_replace('..', '', $section_text['FILE_EXTERNAL']));
- $section_text['FILE_EXTERNAL'] = dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
-
- if (file_exists($section_text['FILE_EXTERNAL'])) {
- $section_text['FILE'] = file_get_contents($section_text['FILE_EXTERNAL'], FILE_BINARY);
- unset($section_text['FILE_EXTERNAL']);
- } else {
- //$bork_info = "could not load --FILE_EXTERNAL-- " . dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
- $bork_info = "could not load --FILE_EXTERNAL-- " . $section_text['FILE_EXTERNAL'];
- $borked = true;
- }
- }
-
- if ((@count($section_text['EXPECT']) + @count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX'])) != 1) {
- $bork_info = "missing section --EXPECT--, --EXPECTF-- or --EXPECTREGEX--";
- $borked = true;
- }
- }
- }
- fclose($fp);
-
- $shortname = str_replace($cwd . '/', '', $file);
- $tested_file = $shortname;
-
- if ($borked) {
- show_result("BORK", $bork_info, $tested_file);
- $PHP_FAILED_TESTS['BORKED'][] = array (
- 'name' => $file,
- 'test_name' => '',
- 'output' => '',
- 'diff' => '',
- 'info' => "$bork_info [$file]",
- );
-
- junit_mark_test_as('BORK', $shortname, $tested_file, 0, $bork_info);
- return 'BORKED';
- }
-
- $tested = trim($section_text['TEST']);
-
- /* For GET/POST/PUT tests, check if cgi sapi is available and if it is, use it. */
- if (!empty($section_text['GET']) || !empty($section_text['POST']) || !empty($section_text['GZIP_POST']) || !empty($section_text['DEFLATE_POST']) || !empty($section_text['POST_RAW']) || !empty($section_text['PUT']) || !empty($section_text['COOKIE']) || !empty($section_text['EXPECTHEADERS'])) {
- if (isset($php_cgi)) {
- $old_php = $php;
- $php = $php_cgi . ' -C ';
- } else if (!strncasecmp(PHP_OS, "win", 3) && file_exists(dirname($php) . "/php-cgi.exe")) {
- $old_php = $php;
- $php = realpath(dirname($php) . "/php-cgi.exe") . ' -C ';
- } else {
- if (file_exists(dirname($php) . "/../../sapi/cgi/php-cgi")) {
- $old_php = $php;
- $php = realpath(dirname($php) . "/../../sapi/cgi/php-cgi") . ' -C ';
- } else if (file_exists("./sapi/cgi/php-cgi")) {
- $old_php = $php;
- $php = realpath("./sapi/cgi/php-cgi") . ' -C ';
- } else if (file_exists(dirname($php) . "/php-cgi")) {
- $old_php = $php;
- $php = realpath(dirname($php) . "/php-cgi") . ' -C ';
- } else {
- show_result('SKIP', $tested, $tested_file, "reason: CGI not available");
-
- junit_mark_test_as('SKIP', $shortname, $tested, 0, 'CGI not available');
- return 'SKIPPED';
- }
- }
- }
-
- show_test($test_idx, $shortname);
-
- if (is_array($IN_REDIRECT)) {
- $temp_dir = $test_dir = $IN_REDIRECT['dir'];
- } else {
- $temp_dir = $test_dir = realpath(dirname($file));
- }
-
- if ($temp_source && $temp_target) {
- $temp_dir = str_replace($temp_source, $temp_target, $temp_dir);
- }
-
- $main_file_name = basename($file,'phpt');
-
- $diff_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'diff';
- $log_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'log';
- $exp_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'exp';
- $output_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'out';
- $memcheck_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'mem';
- $sh_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'sh';
- $temp_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
- $test_file = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'php';
- $temp_skipif = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
- $test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
- $temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
- $test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
- $tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.');
- $tmp_relative_file = str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $test_file) . 't';
-
- if ($temp_source && $temp_target) {
- $temp_skipif .= 's';
- $temp_file .= 's';
- $temp_clean .= 's';
- $copy_file = $temp_dir . DIRECTORY_SEPARATOR . basename(is_array($file) ? $file[1] : $file) . '.phps';
-
- if (!is_dir(dirname($copy_file))) {
- mkdir(dirname($copy_file), 0777, true) or error("Cannot create output directory - " . dirname($copy_file));
- }
-
- if (isset($section_text['FILE'])) {
- save_text($copy_file, $section_text['FILE']);
- }
-
- $temp_filenames = array(
- 'file' => $copy_file,
- 'diff' => $diff_filename,
- 'log' => $log_filename,
- 'exp' => $exp_filename,
- 'out' => $output_filename,
- 'mem' => $memcheck_filename,
- 'sh' => $sh_filename,
- 'php' => $temp_file,
- 'skip' => $temp_skipif,
- 'clean'=> $temp_clean);
- }
-
- if (is_array($IN_REDIRECT)) {
- $tested = $IN_REDIRECT['prefix'] . ' ' . trim($section_text['TEST']);
- $tested_file = $tmp_relative_file;
- }
-
- // unlink old test results
- @unlink($diff_filename);
- @unlink($log_filename);
- @unlink($exp_filename);
- @unlink($output_filename);
- @unlink($memcheck_filename);
- @unlink($sh_filename);
- @unlink($temp_file);
- @unlink($test_file);
- @unlink($temp_skipif);
- @unlink($test_skipif);
- @unlink($tmp_post);
- @unlink($temp_clean);
- @unlink($test_clean);
-
- // Reset environment from any previous test.
- $env['REDIRECT_STATUS'] = '';
- $env['QUERY_STRING'] = '';
- $env['PATH_TRANSLATED'] = '';
- $env['SCRIPT_FILENAME'] = '';
- $env['REQUEST_METHOD'] = '';
- $env['CONTENT_TYPE'] = '';
- $env['CONTENT_LENGTH'] = '';
- $env['TZ'] = '';
-
- if (!empty($section_text['ENV'])) {
-
- foreach(explode("\n", trim($section_text['ENV'])) as $e) {
- $e = explode('=', trim($e), 2);
-
- if (!empty($e[0]) && isset($e[1])) {
- $env[$e[0]] = $e[1];
- }
- }
- }
-
- // Default ini settings
- $ini_settings = array();
- // additional ini overwrites
- //$ini_overwrites[] = 'setting=value';
- settings2array($ini_overwrites, $ini_settings);
-
- // Any special ini settings
- // these may overwrite the test defaults...
- if (array_key_exists('INI', $section_text)) {
- if (strpos($section_text['INI'], '{PWD}') !== false) {
- $section_text['INI'] = str_replace('{PWD}', dirname($file), $section_text['INI']);
- }
- settings2array(preg_split( "/[\n\r]+/", $section_text['INI']), $ini_settings);
- }
-
- // Additional required extensions
- if (array_key_exists('EXTENSIONS', $section_text)) {
- $ext_dir=`$php -r 'echo ini_get("extension_dir");'`;
- $extensions = preg_split("/[\n\r]+/", trim($section_text['EXTENSIONS']));
- $loaded = explode(",", `$php -n -r 'echo join(",", get_loaded_extensions());'`);
- foreach ($extensions as $req_ext) {
- if (!in_array($req_ext, $loaded)) {
- $ini_settings['extension'][] = $ext_dir . DIRECTORY_SEPARATOR . $req_ext . '.' . PHP_SHLIB_SUFFIX;
- }
- }
- }
-
- settings2params($ini_settings);
-
- // Check if test should be skipped.
- $info = '';
- $warn = false;
-
- if (array_key_exists('SKIPIF', $section_text)) {
-
- if (trim($section_text['SKIPIF'])) {
- show_file_block('skip', $section_text['SKIPIF']);
- save_text($test_skipif, $section_text['SKIPIF'], $temp_skipif);
- $extra = substr(PHP_OS, 0, 3) !== "WIN" ?
- "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;": "";
-
- if ($leak_check) {
- $env['USE_ZEND_ALLOC'] = '0';
- $env['ZEND_DONT_UNLOAD_MODULES'] = 1;
- } else {
- $env['USE_ZEND_ALLOC'] = '1';
- $env['ZEND_DONT_UNLOAD_MODULES'] = 0;
- }
-
- junit_start_timer($shortname);
-
- $output = system_with_timeout("$extra $php $pass_options -q $ini_settings -d display_errors=0 \"$test_skipif\"", $env);
-
- junit_finish_timer($shortname);
-
- if (!$cfg['keep']['skip']) {
- @unlink($test_skipif);
- }
-
- if (!strncasecmp('skip', ltrim($output), 4)) {
-
- if (preg_match('/^\s*skip\s*(.+)\s*/i', $output, $m)) {
- show_result('SKIP', $tested, $tested_file, "reason: $m[1]", $temp_filenames);
- } else {
- show_result('SKIP', $tested, $tested_file, '', $temp_filenames);
- }
-
- if (isset($old_php)) {
- $php = $old_php;
- }
-
- if (!$cfg['keep']['skip']) {
- @unlink($test_skipif);
- }
-
- $message = !empty($m[1]) ? $m[1] : '';
- junit_mark_test_as('SKIP', $shortname, $tested, null, "");
- return 'SKIPPED';
- }
-
- if (!strncasecmp('info', ltrim($output), 4)) {
- if (preg_match('/^\s*info\s*(.+)\s*/i', $output, $m)) {
- $info = " (info: $m[1])";
- }
- }
-
- if (!strncasecmp('warn', ltrim($output), 4)) {
- if (preg_match('/^\s*warn\s*(.+)\s*/i', $output, $m)) {
- $warn = true; /* only if there is a reason */
- $info = " (warn: $m[1])";
- }
- }
- }
- }
-
- if (@count($section_text['REDIRECTTEST']) == 1) {
- $test_files = array();
-
- $IN_REDIRECT = eval($section_text['REDIRECTTEST']);
- $IN_REDIRECT['via'] = "via [$shortname]\n\t";
- $IN_REDIRECT['dir'] = realpath(dirname($file));
- $IN_REDIRECT['prefix'] = trim($section_text['TEST']);
-
- if (count($IN_REDIRECT['TESTS']) == 1) {
-
- if (is_array($org_file)) {
- $test_files[] = $org_file[1];
- } else {
- $GLOBALS['test_files'] = $test_files;
- find_files($IN_REDIRECT['TESTS']);
-
- foreach($GLOBALS['test_files'] as $f) {
- $test_files[] = array($f, $file);
- }
- }
- $test_cnt += @count($test_files) - 1;
- $test_idx--;
-
- show_redirect_start($IN_REDIRECT['TESTS'], $tested, $tested_file);
-
- // set up environment
- $redirenv = array_merge($environment, $IN_REDIRECT['ENV']);
- $redirenv['REDIR_TEST_DIR'] = realpath($IN_REDIRECT['TESTS']) . DIRECTORY_SEPARATOR;
-
- usort($test_files, "test_sort");
- run_all_tests($test_files, $redirenv, $tested);
-
- show_redirect_ends($IN_REDIRECT['TESTS'], $tested, $tested_file);
-
- // a redirected test never fails
- $IN_REDIRECT = false;
-
- junit_mark_test_as('PASS', $shortname, $tested);
- return 'REDIR';
-
- } else {
-
- $bork_info = "Redirect info must contain exactly one TEST string to be used as redirect directory.";
- show_result("BORK", $bork_info, '', $temp_filenames);
- $PHP_FAILED_TESTS['BORKED'][] = array (
- 'name' => $file,
- 'test_name' => '',
- 'output' => '',
- 'diff' => '',
- 'info' => "$bork_info [$file]",
- );
- }
- }
-
- if (is_array($org_file) || @count($section_text['REDIRECTTEST']) == 1) {
-
- if (is_array($org_file)) {
- $file = $org_file[0];
- }
-
- $bork_info = "Redirected test did not contain redirection info";
- show_result("BORK", $bork_info, '', $temp_filenames);
- $PHP_FAILED_TESTS['BORKED'][] = array (
- 'name' => $file,
- 'test_name' => '',
- 'output' => '',
- 'diff' => '',
- 'info' => "$bork_info [$file]",
- );
-
- junit_mark_test_as('BORK', $shortname, $tested, null, $bork_info);
-
- return 'BORKED';
- }
-
- // We've satisfied the preconditions - run the test!
- show_file_block('php', $section_text['FILE'], 'TEST');
- save_text($test_file, $section_text['FILE'], $temp_file);
-
- if (array_key_exists('GET', $section_text)) {
- $query_string = trim($section_text['GET']);
- } else {
- $query_string = '';
- }
-
- $env['REDIRECT_STATUS'] = '1';
- $env['QUERY_STRING'] = $query_string;
- $env['PATH_TRANSLATED'] = $test_file;
- $env['SCRIPT_FILENAME'] = $test_file;
-
- if (array_key_exists('COOKIE', $section_text)) {
- $env['HTTP_COOKIE'] = trim($section_text['COOKIE']);
- } else {
- $env['HTTP_COOKIE'] = '';
- }
-
- $args = isset($section_text['ARGS']) ? ' -- ' . $section_text['ARGS'] : '';
-
- if (array_key_exists('POST_RAW', $section_text) && !empty($section_text['POST_RAW'])) {
-
- $post = trim($section_text['POST_RAW']);
- $raw_lines = explode("\n", $post);
-
- $request = '';
- $started = false;
-
- foreach ($raw_lines as $line) {
-
- if (empty($env['CONTENT_TYPE']) && preg_match('/^Content-Type:(.*)/i', $line, $res)) {
- $env['CONTENT_TYPE'] = trim(str_replace("\r", '', $res[1]));
- continue;
- }
-
- if ($started) {
- $request .= "\n";
- }
-
- $started = true;
- $request .= $line;
- }
-
- $env['CONTENT_LENGTH'] = strlen($request);
- $env['REQUEST_METHOD'] = 'POST';
-
- if (empty($request)) {
- junit_mark_test_as('BORK', $shortname, $tested, null, 'empty $request');
- return 'BORKED';
- }
-
- save_text($tmp_post, $request);
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
-
- } elseif (array_key_exists('PUT', $section_text) && !empty($section_text['PUT'])) {
-
- $post = trim($section_text['PUT']);
- $raw_lines = explode("\n", $post);
-
- $request = '';
- $started = false;
-
- foreach ($raw_lines as $line) {
-
- if (empty($env['CONTENT_TYPE']) && preg_match('/^Content-Type:(.*)/i', $line, $res)) {
- $env['CONTENT_TYPE'] = trim(str_replace("\r", '', $res[1]));
- continue;
- }
-
- if ($started) {
- $request .= "\n";
- }
-
- $started = true;
- $request .= $line;
- }
-
- $env['CONTENT_LENGTH'] = strlen($request);
- $env['REQUEST_METHOD'] = 'PUT';
-
- if (empty($request)) {
- junit_mark_test_as('BORK', $shortname, $tested, null, 'empty $request');
- return 'BORKED';
- }
-
- save_text($tmp_post, $request);
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
-
- } else if (array_key_exists('POST', $section_text) && !empty($section_text['POST'])) {
-
- $post = trim($section_text['POST']);
- save_text($tmp_post, $post);
- $content_length = strlen($post);
-
- $env['REQUEST_METHOD'] = 'POST';
- $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
- $env['CONTENT_LENGTH'] = $content_length;
-
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
-
- } else if (array_key_exists('GZIP_POST', $section_text) && !empty($section_text['GZIP_POST'])) {
-
- $post = trim($section_text['GZIP_POST']);
- $post = gzencode($post, 9, FORCE_GZIP);
- $env['HTTP_CONTENT_ENCODING'] = 'gzip';
-
- save_text($tmp_post, $post);
- $content_length = strlen($post);
-
- $env['REQUEST_METHOD'] = 'POST';
- $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
- $env['CONTENT_LENGTH'] = $content_length;
-
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
-
- } else if (array_key_exists('DEFLATE_POST', $section_text) && !empty($section_text['DEFLATE_POST'])) {
- $post = trim($section_text['DEFLATE_POST']);
- $post = gzcompress($post, 9);
- $env['HTTP_CONTENT_ENCODING'] = 'deflate';
- save_text($tmp_post, $post);
- $content_length = strlen($post);
-
- $env['REQUEST_METHOD'] = 'POST';
- $env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
- $env['CONTENT_LENGTH'] = $content_length;
-
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1 < \"$tmp_post\"";
-
-
- } else {
-
- $env['REQUEST_METHOD'] = 'GET';
- $env['CONTENT_TYPE'] = '';
- $env['CONTENT_LENGTH'] = '';
-
- $cmd = "$php $pass_options $ini_settings -f \"$test_file\" $args 2>&1";
- }
-
- if ($leak_check) {
- $env['USE_ZEND_ALLOC'] = '0';
- $env['ZEND_DONT_UNLOAD_MODULES'] = 1;
-
- if ($valgrind_version >= 330) {
- /* valgrind 3.3.0+ doesn't have --log-file-exactly option */
- $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file=$memcheck_filename $cmd";
- } else {
- $cmd = "valgrind -q --tool=memcheck --trace-children=yes --log-file-exactly=$memcheck_filename $cmd";
- }
-
- } else {
- $env['USE_ZEND_ALLOC'] = '1';
- $env['ZEND_DONT_UNLOAD_MODULES'] = 0;
- }
-
- if ($DETAILED) echo "
-CONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . "
-CONTENT_TYPE = " . $env['CONTENT_TYPE'] . "
-PATH_TRANSLATED = " . $env['PATH_TRANSLATED'] . "
-QUERY_STRING = " . $env['QUERY_STRING'] . "
-REDIRECT_STATUS = " . $env['REDIRECT_STATUS'] . "
-REQUEST_METHOD = " . $env['REQUEST_METHOD'] . "
-SCRIPT_FILENAME = " . $env['SCRIPT_FILENAME'] . "
-HTTP_COOKIE = " . $env['HTTP_COOKIE'] . "
-COMMAND $cmd
-";
-
- junit_start_timer($shortname);
-
- $out = system_with_timeout($cmd, $env, isset($section_text['STDIN']) ? $section_text['STDIN'] : null);
-
- junit_finish_timer($shortname);
-
- if (array_key_exists('CLEAN', $section_text) && (!$no_clean || $cfg['keep']['clean'])) {
-
- if (trim($section_text['CLEAN'])) {
- show_file_block('clean', $section_text['CLEAN']);
- save_text($test_clean, trim($section_text['CLEAN']), $temp_clean);
-
- if (!$no_clean) {
- $clean_params = array();
- settings2array($ini_overwrites, $clean_params);
- settings2params($clean_params);
- $extra = substr(PHP_OS, 0, 3) !== "WIN" ?
- "unset REQUEST_METHOD; unset QUERY_STRING; unset PATH_TRANSLATED; unset SCRIPT_FILENAME; unset REQUEST_METHOD;": "";
- system_with_timeout("$extra $php $pass_options -q $clean_params \"$test_clean\"", $env);
- }
-
- if (!$cfg['keep']['clean']) {
- @unlink($test_clean);
- }
- }
- }
-
- @unlink($tmp_post);
-
- $leaked = false;
- $passed = false;
-
- if ($leak_check) { // leak check
- $leaked = filesize($memcheck_filename) > 0;
-
- if (!$leaked) {
- @unlink($memcheck_filename);
- }
- }
-
- // Does the output match what is expected?
- $output = preg_replace("/\r\n/", "\n", trim($out));
-
- /* when using CGI, strip the headers from the output */
- $headers = "";
-
- if (isset($old_php) && preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $out, $match)) {
- $output = trim($match[2]);
- $rh = preg_split("/[\n\r]+/", $match[1]);
- $headers = array();
-
- foreach ($rh as $line) {
- if (strpos($line, ':') !== false) {
- $line = explode(':', $line, 2);
- $headers[trim($line[0])] = trim($line[1]);
- }
- }
- }
-
- $failed_headers = false;
-
- if (isset($section_text['EXPECTHEADERS'])) {
- $want = array();
- $wanted_headers = array();
- $lines = preg_split("/[\n\r]+/", $section_text['EXPECTHEADERS']);
-
- foreach($lines as $line) {
- if (strpos($line, ':') !== false) {
- $line = explode(':', $line, 2);
- $want[trim($line[0])] = trim($line[1]);
- $wanted_headers[] = trim($line[0]) . ': ' . trim($line[1]);
- }
- }
-
- $org_headers = $headers;
- $headers = array();
- $output_headers = array();
-
- foreach($want as $k => $v) {
-
- if (isset($org_headers[$k])) {
- $headers = $org_headers[$k];
- $output_headers[] = $k . ': ' . $org_headers[$k];
- }
-
- if (!isset($org_headers[$k]) || $org_headers[$k] != $v) {
- $failed_headers = true;
- }
- }
-
- ksort($wanted_headers);
- $wanted_headers = join("\n", $wanted_headers);
- ksort($output_headers);
- $output_headers = join("\n", $output_headers);
- }
-
- show_file_block('out', $output);
-
- if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
-
- if (isset($section_text['EXPECTF'])) {
- $wanted = trim($section_text['EXPECTF']);
- } else {
- $wanted = trim($section_text['EXPECTREGEX']);
- }
-
- show_file_block('exp', $wanted);
- $wanted_re = preg_replace('/\r\n/', "\n", $wanted);
-
- if (isset($section_text['EXPECTF'])) {
-
- // do preg_quote, but miss out any %r delimited sections
- $temp = "";
- $r = "%r";
- $startOffset = 0;
- $length = strlen($wanted_re);
- while($startOffset < $length) {
- $start = strpos($wanted_re, $r, $startOffset);
- if ($start !== false) {
- // we have found a start tag
- $end = strpos($wanted_re, $r, $start+2);
- if ($end === false) {
- // unbalanced tag, ignore it.
- $end = $start = $length;
- }
- } else {
- // no more %r sections
- $start = $end = $length;
- }
- // quote a non re portion of the string
- $temp = $temp . preg_quote(substr($wanted_re, $startOffset, ($start - $startOffset)), '/');
- // add the re unquoted.
- if ($end > $start) {
- $temp = $temp . '(' . substr($wanted_re, $start+2, ($end - $start-2)). ')';
- }
- $startOffset = $end + 2;
- }
- $wanted_re = $temp;
-
- $wanted_re = str_replace(
- array('%binary_string_optional%'),
- 'string',
- $wanted_re
- );
- $wanted_re = str_replace(
- array('%unicode_string_optional%'),
- 'string',
- $wanted_re
- );
- $wanted_re = str_replace(
- array('%unicode\|string%', '%string\|unicode%'),
- 'string',
- $wanted_re
- );
- $wanted_re = str_replace(
- array('%u\|b%', '%b\|u%'),
- '',
- $wanted_re
- );
- // Stick to basics
- $wanted_re = str_replace('%e', '\\' . DIRECTORY_SEPARATOR, $wanted_re);
- $wanted_re = str_replace('%s', '[^\r\n]+', $wanted_re);
- $wanted_re = str_replace('%S', '[^\r\n]*', $wanted_re);
- $wanted_re = str_replace('%a', '.+', $wanted_re);
- $wanted_re = str_replace('%A', '.*', $wanted_re);
- $wanted_re = str_replace('%w', '\s*', $wanted_re);
- $wanted_re = str_replace('%i', '[+-]?\d+', $wanted_re);
- $wanted_re = str_replace('%d', '\d+', $wanted_re);
- $wanted_re = str_replace('%x', '[0-9a-fA-F]+', $wanted_re);
- $wanted_re = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $wanted_re);
- $wanted_re = str_replace('%c', '.', $wanted_re);
- // %f allows two points "-.0.0" but that is the best *simple* expression
- }
-/* DEBUG YOUR REGEX HERE
- var_dump($wanted_re);
- print(str_repeat('=', 80) . "\n");
- var_dump($output);
-*/
- if (preg_match("/^$wanted_re\$/s", $output)) {
- $passed = true;
- if (!$cfg['keep']['php']) {
- @unlink($test_file);
- }
- if (isset($old_php)) {
- $php = $old_php;
- }
-
- if (!$leaked && !$failed_headers) {
- if (isset($section_text['XFAIL'] )) {
- $warn = true;
- $info = " (warn: XFAIL section but test passes)";
- }else {
- show_result("PASS", $tested, $tested_file, '', $temp_filenames);
- junit_mark_test_as('PASS', $shortname, $tested);
- return 'PASSED';
- }
- }
- }
-
- } else {
-
- $wanted = trim($section_text['EXPECT']);
- $wanted = preg_replace('/\r\n/',"\n", $wanted);
- show_file_block('exp', $wanted);
-
- // compare and leave on success
- if (!strcmp($output, $wanted)) {
- $passed = true;
-
- if (!$cfg['keep']['php']) {
- @unlink($test_file);
- }
-
- if (isset($old_php)) {
- $php = $old_php;
- }
-
- if (!$leaked && !$failed_headers) {
- if (isset($section_text['XFAIL'] )) {
- $warn = true;
- $info = " (warn: XFAIL section but test passes)";
- }else {
- show_result("PASS", $tested, $tested_file, '', $temp_filenames);
- junit_mark_test_as('PASS', $shortname, $tested);
- return 'PASSED';
- }
- }
- }
-
- $wanted_re = null;
- }
-
- // Test failed so we need to report details.
- if ($failed_headers) {
- $passed = false;
- $wanted = $wanted_headers . "\n--HEADERS--\n" . $wanted;
- $output = $output_headers . "\n--HEADERS--\n" . $output;
-
- if (isset($wanted_re)) {
- $wanted_re = preg_quote($wanted_headers . "\n--HEADERS--\n", '/') . $wanted_re;
- }
- }
-
- if ($leaked) {
- $restype[] = 'LEAK';
- }
-
- if ($warn) {
- $restype[] = 'WARN';
- }
-
- if (!$passed) {
- if (isset($section_text['XFAIL'])) {
- $restype[] = 'XFAIL';
- $info = ' XFAIL REASON: ' . rtrim($section_text['XFAIL']);
- } else {
- $restype[] = 'FAIL';
- }
- }
-
- if (!$passed) {
-
- // write .exp
- if (strpos($log_format, 'E') !== false && file_put_contents($exp_filename, $wanted, FILE_BINARY) === false) {
- error("Cannot create expected test output - $exp_filename");
- }
-
- // write .out
- if (strpos($log_format, 'O') !== false && file_put_contents($output_filename, $output, FILE_BINARY) === false) {
- error("Cannot create test output - $output_filename");
- }
-
- // write .diff
- $diff = generate_diff($wanted, $wanted_re, $output);
- if (is_array($IN_REDIRECT)) {
- $diff = "# original source file: $shortname\n" . $diff;
- }
- show_file_block('diff', $diff);
- if (strpos($log_format, 'D') !== false && file_put_contents($diff_filename, $diff, FILE_BINARY) === false) {
- error("Cannot create test diff - $diff_filename");
- }
-
- // write .sh
- if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, "#!/bin/sh
-
-{$cmd}
-", FILE_BINARY) === false) {
- error("Cannot create test shell script - $sh_filename");
- }
- chmod($sh_filename, 0755);
-
- // write .log
- if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, "
----- EXPECTED OUTPUT
-$wanted
----- ACTUAL OUTPUT
-$output
----- FAILED
-", FILE_BINARY) === false) {
- error("Cannot create test log - $log_filename");
- error_report($file, $log_filename, $tested);
- }
- }
-
- show_result(implode('&', $restype), $tested, $tested_file, $info, $temp_filenames);
-
- foreach ($restype as $type) {
- $PHP_FAILED_TESTS[$type.'ED'][] = array (
- 'name' => $file,
- 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " \x1b[7m[\x1b[1m$tested_file\x1b[0m\x1b[0m\x1b[7m]\x1b[0m",
- 'output' => $output_filename,
- 'diff' => $diff_filename,
- 'info' => $info,
- );
- }
-
- if (isset($old_php)) {
- $php = $old_php;
- }
-
- $diff = empty($diff) ? '' : "', $diff) . "\n]]>";
-
- junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff);
-
- return $restype[0] . 'ED';
-}
-
-function comp_line($l1, $l2, $is_reg)
-{
- if ($is_reg) {
- return preg_match('/^'. $l1 . '$/s', $l2);
- } else {
- return !strcmp($l1, $l2);
- }
-}
-
-function count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2, $cnt1, $cnt2, $steps)
-{
- $equal = 0;
-
- while ($idx1 < $cnt1 && $idx2 < $cnt2 && comp_line($ar1[$idx1], $ar2[$idx2], $is_reg)) {
- $idx1++;
- $idx2++;
- $equal++;
- $steps--;
- }
- if (--$steps > 0) {
- $eq1 = 0;
- $st = $steps / 2;
-
- for ($ofs1 = $idx1 + 1; $ofs1 < $cnt1 && $st-- > 0; $ofs1++) {
- $eq = @count_array_diff($ar1, $ar2, $is_reg, $w, $ofs1, $idx2, $cnt1, $cnt2, $st);
-
- if ($eq > $eq1) {
- $eq1 = $eq;
- }
- }
-
- $eq2 = 0;
- $st = $steps;
-
- for ($ofs2 = $idx2 + 1; $ofs2 < $cnt2 && $st-- > 0; $ofs2++) {
- $eq = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $ofs2, $cnt1, $cnt2, $st);
- if ($eq > $eq2) {
- $eq2 = $eq;
- }
- }
-
- if ($eq1 > $eq2) {
- $equal += $eq1;
- } else if ($eq2 > 0) {
- $equal += $eq2;
- }
- }
-
- return $equal;
-}
-
-function generate_array_diff($ar1, $ar2, $is_reg, $w)
-{
- $idx1 = 0; $ofs1 = 0; $cnt1 = @count($ar1);
- $idx2 = 0; $ofs2 = 0; $cnt2 = @count($ar2);
- $diff = array();
- $old1 = array();
- $old2 = array();
-
- while ($idx1 < $cnt1 && $idx2 < $cnt2) {
-
- if (comp_line($ar1[$idx1], $ar2[$idx2], $is_reg)) {
- $idx1++;
- $idx2++;
- continue;
- } else {
-
- $c1 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1+1, $idx2, $cnt1, $cnt2, 10);
- $c2 = @count_array_diff($ar1, $ar2, $is_reg, $w, $idx1, $idx2+1, $cnt1, $cnt2, 10);
-
- if ($c1 > $c2) {
- $old1[$idx1] = sprintf("%03d- ", $idx1+1) . $w[$idx1++];
- $last = 1;
- } else if ($c2 > 0) {
- $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++];
- $last = 2;
- } else {
- $old1[$idx1] = sprintf("%03d- ", $idx1+1) . $w[$idx1++];
- $old2[$idx2] = sprintf("%03d+ ", $idx2+1) . $ar2[$idx2++];
- }
- }
- }
-
- reset($old1); $k1 = key($old1); $l1 = -2;
- reset($old2); $k2 = key($old2); $l2 = -2;
-
- while ($k1 !== null || $k2 !== null) {
-
- if ($k1 == $l1 + 1 || $k2 === null) {
- $l1 = $k1;
- $diff[] = current($old1);
- $k1 = next($old1) ? key($old1) : null;
- } else if ($k2 == $l2 + 1 || $k1 === null) {
- $l2 = $k2;
- $diff[] = current($old2);
- $k2 = next($old2) ? key($old2) : null;
- } else if ($k1 < $k2) {
- $l1 = $k1;
- $diff[] = current($old1);
- $k1 = next($old1) ? key($old1) : null;
- } else {
- $l2 = $k2;
- $diff[] = current($old2);
- $k2 = next($old2) ? key($old2) : null;
- }
- }
-
- while ($idx1 < $cnt1) {
- $diff[] = sprintf("%03d- ", $idx1 + 1) . $w[$idx1++];
- }
-
- while ($idx2 < $cnt2) {
- $diff[] = sprintf("%03d+ ", $idx2 + 1) . $ar2[$idx2++];
- }
-
- return $diff;
-}
-
-function generate_diff($wanted, $wanted_re, $output)
-{
- $w = explode("\n", $wanted);
- $o = explode("\n", $output);
- $r = is_null($wanted_re) ? $w : explode("\n", $wanted_re);
- $diff = generate_array_diff($r, $o, !is_null($wanted_re), $w);
-
- return implode("\r\n", $diff);
-}
-
-function error($message)
-{
- echo "ERROR: {$message}\n";
- exit(1);
-}
-
-function settings2array($settings, &$ini_settings)
-{
- foreach($settings as $setting) {
-
- if (strpos($setting, '=') !== false) {
- $setting = explode("=", $setting, 2);
- $name = trim($setting[0]);
- $value = trim($setting[1]);
-
- if ($name == 'extension') {
-
- if (!isset($ini_settings[$name])) {
- $ini_settings[$name] = array();
- }
-
- $ini_settings[$name][] = $value;
-
- } else {
- $ini_settings[$name] = $value;
- }
- }
- }
-}
-
-function settings2params(&$ini_settings)
-{
- $settings = '';
-
- foreach($ini_settings as $name => $value) {
-
- if (is_array($value)) {
- foreach($value as $val) {
- $val = addslashes($val);
- $settings .= " -d \"$name=$val\"";
- }
- } else {
- if (substr(PHP_OS, 0, 3) == "WIN" && !empty($value) && $value{0} == '"') {
- $len = strlen($value);
-
- if ($value{$len - 1} == '"') {
- $value{0} = "'";
- $value{$len - 1} = "'";
- }
- } else {
- $value = addslashes($value);
- }
-
- $settings .= " -d \"$name=$value\"";
- }
- }
-
- $ini_settings = $settings;
-}
-
-function compute_summary()
-{
- global $n_total, $test_results, $ignored_by_ext, $sum_results, $percent_results;
-
- $n_total = count($test_results);
- $n_total += $ignored_by_ext;
- $sum_results = array(
- 'PASSED' => 0,
- 'WARNED' => 0,
- 'SKIPPED' => 0,
- 'FAILED' => 0,
- 'BORKED' => 0,
- 'LEAKED' => 0,
- 'XFAILED' => 0
- );
-
- foreach ($test_results as $v) {
- $sum_results[$v]++;
- }
-
- $sum_results['SKIPPED'] += $ignored_by_ext;
- $percent_results = array();
-
- while (list($v, $n) = each($sum_results)) {
- $percent_results[$v] = (100.0 * $n) / $n_total;
- }
-}
-
-function get_summary($show_ext_summary, $show_html)
-{
- global $exts_skipped, $exts_tested, $n_total, $sum_results, $percent_results, $end_time, $start_time, $failed_test_summary, $PHP_FAILED_TESTS, $leak_check;
-
- $x_total = $n_total - $sum_results['SKIPPED'] - $sum_results['BORKED'];
-
- if ($x_total) {
- $x_warned = (100.0 * $sum_results['WARNED']) / $x_total;
- $x_failed = (100.0 * $sum_results['FAILED']) / $x_total;
- $x_xfailed = (100.0 * $sum_results['XFAILED']) / $x_total;
- $x_leaked = (100.0 * $sum_results['LEAKED']) / $x_total;
- $x_passed = (100.0 * $sum_results['PASSED']) / $x_total;
- } else {
- $x_warned = $x_failed = $x_passed = $x_leaked = $x_xfailed = 0;
- }
-
- $summary = '';
-
- if ($show_html) {
- $summary .= "\n";
- }
-
- if ($show_ext_summary) {
- $summary .= '
-=====================================================================
-TEST RESULT SUMMARY
----------------------------------------------------------------------
-Exts skipped : ' . sprintf('%4d', $exts_skipped) . '
-Exts tested : ' . sprintf('%4d', $exts_tested) . '
----------------------------------------------------------------------
-';
- }
-
- /*
- * defines for color scheme
- *
- */
- $clr_schm_dflt = "\x1b[1;37;40m";
- $clr_schm_fin = "\x1b[0m";
- $clr_schm_fail = "\x1b[1;31;47m";
- $clr_schm_ok = "\x1b[1;32;40m";
- $clr_schm_warn = "\x1b[1;33;40m";
- $clr_schm_skip = "\x1b[1;36;40m";
-
- $clr_borked = !$sum_results['BORKED'] ? $clr_schm_dflt : $clr_schm_fail;
- $clr_skipped = !$sum_results['SKIPPED'] ? $clr_schm_dflt : $clr_schm_skip;
- $clr_warned = !$sum_results['WARNED'] ? $clr_schm_dflt : $clr_schm_warn;
- $clr_failed = !$sum_results['FAILED'] ? $clr_schm_dflt : $clr_schm_fail;
- $clr_Xfailed = !$sum_results['XFAILED'] ? $clr_schm_dflt : $clr_schm_fail;
- $clr_passed = !$sum_results['PASSED'] ? $clr_schm_dflt : $clr_schm_ok;
-
-
- $summary .= '
-Number of tests : ' . sprintf('%4d', $n_total) . ' ' . sprintf('%8d', $x_total);
-
- if ($sum_results['BORKED']) {
- $summary .= "
-${clr_borked}Tests borked : " . sprintf('%4d (%5.1f%%)', $sum_results['BORKED'], $percent_results['BORKED']) . " --------$clr_schm_fin";
- }
-
- $summary .= "
-${clr_skipped}Tests skipped : " . sprintf('%4d (%5.1f%%)', $sum_results['SKIPPED'], $percent_results['SKIPPED']) . " --------$clr_schm_fin
-${clr_warned}Tests warned : " . sprintf('%4d (%5.1f%%)', $sum_results['WARNED'], $percent_results['WARNED']) . ' ' . sprintf('(%5.1f%%)', $x_warned) . "$clr_schm_fin
-${clr_failed}Tests failed : " . sprintf('%4d (%5.1f%%)', $sum_results['FAILED'], $percent_results['FAILED']) . ' ' . sprintf('(%5.1f%%)', $x_failed) . "$clr_schm_fin
-${clr_Xfailed}Expected fail : " . sprintf('%4d (%5.1f%%)', $sum_results['XFAILED'], $percent_results['XFAILED']) . ' ' . sprintf('(%5.1f%%)', $x_xfailed) . $clr_schm_fin;
-
- if ($leak_check) {
- $clr_leaked = !$sum_results['LEAKED'] ? $clr_schm_dflt : $clr_schm_warn;
- $summary .= "
-${clr_leaked}Tests leaked : " . sprintf('%4d (%5.1f%%)', $sum_results['LEAKED'], $percent_results['LEAKED']) . ' ' . sprintf('(%5.1f%%)', $x_leaked) . $clr_schm_fin;
- }
-
- $summary .= "
-${clr_passed}Tests passed : " . sprintf('%4d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . "$clr_schm_fin
----------------------------------------------------------------------
-Time taken : " . sprintf('%4d seconds', $end_time - $start_time) . '
-=====================================================================
-';
- $failed_test_summary = '';
-
- if (count($PHP_FAILED_TESTS['XFAILED'])) {
- $failed_test_summary .= "
-=====================================================================
-${clr_schm_fail}EXPECTED FAILED TEST SUMMARY\x1b[0m
----------------------------------------------------------------------
-";
- foreach ($PHP_FAILED_TESTS['XFAILED'] as $failed_test_data) {
- $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
- }
- $failed_test_summary .= "=====================================================================\n";
- }
-
- if (count($PHP_FAILED_TESTS['BORKED'])) {
- $failed_test_summary .= "
-=====================================================================
-${clr_schm_fail}BORKED TEST SUMMARY\x1b[0m
----------------------------------------------------------------------
-";
- foreach ($PHP_FAILED_TESTS['BORKED'] as $failed_test_data) {
- $failed_test_summary .= $failed_test_data['info'] . "\n";
- }
-
- $failed_test_summary .= "=====================================================================\n";
- }
-
- if (count($PHP_FAILED_TESTS['FAILED'])) {
- $failed_test_summary .= "
-=====================================================================
-${clr_schm_fail}FAILED TEST SUMMARY\x1b[0m
----------------------------------------------------------------------
-";
- foreach ($PHP_FAILED_TESTS['FAILED'] as $failed_test_data) {
- $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
- }
- $failed_test_summary .= "=====================================================================\n";
- }
- if (count($PHP_FAILED_TESTS['WARNED'])) {
- $failed_test_summary .= "
-=====================================================================
-${clr_schm_warn}WARNED TEST SUMMARY\x1b[0m
----------------------------------------------------------------------
-";
- foreach ($PHP_FAILED_TESTS['WARNED'] as $failed_test_data) {
- $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
- }
-
- $failed_test_summary .= "=====================================================================\n";
- }
-
- if (count($PHP_FAILED_TESTS['LEAKED'])) {
- $failed_test_summary .= "
-=====================================================================
-${clr_schm_warn}LEAKED TEST SUMMARY\x1b[0m
----------------------------------------------------------------------
-";
- foreach ($PHP_FAILED_TESTS['LEAKED'] as $failed_test_data) {
- $failed_test_summary .= $failed_test_data['test_name'] . $failed_test_data['info'] . "\n";
- }
-
- $failed_test_summary .= "=====================================================================\n";
- }
-
- if ($failed_test_summary && !getenv('NO_PHPTEST_SUMMARY')) {
- $summary .= $failed_test_summary;
- }
-
- if ($show_html) {
- $summary .= "
";
- }
-
- return $summary;
-}
-
-function show_start($start_time)
-{
- global $html_output, $html_file;
-
- if ($html_output) {
- fwrite($html_file, "Time Start: " . date('Y-m-d H:i:s', $start_time) . "
\n");
- fwrite($html_file, "\n");
- }
-
- echo "TIME START " . date('Y-m-d H:i:s', $start_time) . "\n=====================================================================\n";
-}
-
-function show_end($end_time)
-{
- global $html_output, $html_file;
-
- if ($html_output) {
- fwrite($html_file, "
\n");
- fwrite($html_file, "Time End: " . date('Y-m-d H:i:s', $end_time) . "
\n");
- }
-
- echo "=====================================================================\nTIME END " . date('Y-m-d H:i:s', $end_time) . "\n";
-}
-
-function show_summary()
-{
- global $html_output, $html_file;
-
- if ($html_output) {
- fwrite($html_file, "
\n" . get_summary(true, true));
- }
-
- echo get_summary(true, false);
-}
-
-function show_redirect_start($tests, $tested, $tested_file)
-{
- global $html_output, $html_file, $line_length, $SHOW_ONLY_GROUPS;
-
- if ($html_output) {
- fwrite($html_file, "---> $tests ($tested [$tested_file]) begin |
\n");
- }
-
- if (!$SHOW_ONLY_GROUPS || in_array('REDIRECT', $SHOW_ONLY_GROUPS)) {
- echo "REDIRECT $tests ($tested [$tested_file]) begin\n";
- } else {
- // Write over the last line to avoid random trailing chars on next echo
- echo str_repeat(" ", $line_length), "\r";
- }
-}
-
-function show_redirect_ends($tests, $tested, $tested_file)
-{
- global $html_output, $html_file, $line_length, $SHOW_ONLY_GROUPS;
-
- if ($html_output) {
- fwrite($html_file, "---> $tests ($tested [$tested_file]) done |
\n");
- }
-
- if (!$SHOW_ONLY_GROUPS || in_array('REDIRECT', $SHOW_ONLY_GROUPS)) {
- echo "REDIRECT $tests ($tested [$tested_file]) done\n";
- } else {
- // Write over the last line to avoid random trailing chars on next echo
- echo str_repeat(" ", $line_length), "\r";
- }
-}
-
-function show_test($test_idx, $shortname)
-{
- global $test_cnt;
- global $line_length;
-
- $str = "TEST $test_idx/$test_cnt [$shortname]\r";
- $line_length = strlen($str);
- echo $str;
- flush();
-}
-
-function show_result($result, $tested, $tested_file, $extra = '', $temp_filenames = null)
-{
- global $html_output, $html_file, $temp_target, $temp_urlbase, $line_length, $SHOW_ONLY_GROUPS;
-
- if (!$SHOW_ONLY_GROUPS || in_array($result, $SHOW_ONLY_GROUPS)) {
- echo "$result $tested [$tested_file] $extra\n";
- } else {
- // Write over the last line to avoid random trailing chars on next echo
- echo str_repeat(" ", $line_length), "\r";
- }
-
- if ($html_output) {
-
- if (isset($temp_filenames['file']) && file_exists($temp_filenames['file'])) {
- $url = str_replace($temp_target, $temp_urlbase, $temp_filenames['file']);
- $tested = "$tested";
- }
-
- if (isset($temp_filenames['skip']) && file_exists($temp_filenames['skip'])) {
-
- if (empty($extra)) {
- $extra = "skipif";
- }
-
- $url = str_replace($temp_target, $temp_urlbase, $temp_filenames['skip']);
- $extra = "$extra";
-
- } else if (empty($extra)) {
- $extra = " ";
- }
-
- if (isset($temp_filenames['diff']) && file_exists($temp_filenames['diff'])) {
- $url = str_replace($temp_target, $temp_urlbase, $temp_filenames['diff']);
- $diff = "diff";
- } else {
- $diff = " ";
- }
-
- if (isset($temp_filenames['mem']) && file_exists($temp_filenames['mem'])) {
- $url = str_replace($temp_target, $temp_urlbase, $temp_filenames['mem']);
- $mem = "leaks";
- } else {
- $mem = " ";
- }
-
- fwrite($html_file,
- "" .
- "$result | " .
- "$tested | " .
- "$extra | " .
- "$diff | " .
- "$mem | " .
- "
\n");
- }
-}
-
-function junit_init() {
- // Check whether a junit log is wanted.
- $JUNIT = getenv('TEST_PHP_JUNIT');
- if (empty($JUNIT)) {
- $JUNIT = FALSE;
- } elseif (!$fp = fopen($JUNIT, 'w')) {
- error("Failed to open $JUNIT for writing.");
- } else {
- $JUNIT = array(
- 'fp' => $fp,
- 'name' => 'php-src',
- 'test_total' => 0,
- 'test_pass' => 0,
- 'test_fail' => 0,
- 'test_error' => 0,
- 'test_skip' => 0,
- 'execution_time'=> 0,
- 'suites' => array(),
- 'files' => array()
- );
- }
-
- $GLOBALS['JUNIT'] = $JUNIT;
-}
-
-function junit_save_xml() {
- global $JUNIT;
- if (!junit_enabled()) return;
-
- $xml = ''. PHP_EOL .
- '' . PHP_EOL;
- $xml .= junit_get_suite_xml();
- $xml .= '';
- fwrite($JUNIT['fp'], $xml);
-}
-
-function junit_get_suite_xml($suite_name = '') {
- global $JUNIT;
-
- $suite = $suite_name ? $JUNIT['suites'][$suite_name] : $JUNIT;
-
- $result = sprintf(
- '' . PHP_EOL,
- $suite['name'], $suite['test_total'], $suite['test_fail'], $suite['test_error'], $suite['test_skip'],
- $suite['execution_time']
- );
-
- foreach($suite['suites'] as $sub_suite) {
- $result .= junit_get_suite_xml($sub_suite['name']);
- }
-
- // Output files only in subsuites
- if (!empty($suite_name)) {
- foreach($suite['files'] as $file) {
- $result .= $JUNIT['files'][$file]['xml'];
- }
- }
-
- $result .= '' . PHP_EOL;
-
- return $result;
-}
-
-function junit_enabled() {
- global $JUNIT;
- return !empty($JUNIT);
-}
-
-/**
- * @param array|string $type
- * @param string $file_name
- * @param string $test_name
- * @param int|string $time
- * @param string $message
- * @param string $details
- * @return void
- */
-function junit_mark_test_as($type, $file_name, $test_name, $time = null, $message = '', $details = '') {
- global $JUNIT;
- if (!junit_enabled()) return;
-
- $suite = junit_get_suitename_for($file_name);
-
- junit_suite_record($suite, 'test_total');
-
- $time = null !== $time ? $time : junit_get_timer($file_name);
- junit_suite_record($suite, 'execution_time', $time);
-
- $escaped_details = htmlspecialchars($details, ENT_QUOTES, 'UTF-8');
-
- $escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name, ENT_QUOTES);
- $JUNIT['files'][$file_name]['xml'] = "\n";
-
- if (is_array($type)) {
- $output_type = $type[0] . 'ED';
- $temp = array_intersect(array('XFAIL', 'FAIL'), $type);
- $type = reset($temp);
- } else {
- $output_type = $type . 'ED';
- }
-
- if ('PASS' == $type || 'XFAIL' == $type) {
- junit_suite_record($suite, 'test_pass');
- } elseif ('BORK' == $type) {
- junit_suite_record($suite, 'test_error');
- $JUNIT['files'][$file_name]['xml'] .= "\n";
- } elseif ('SKIP' == $type) {
- junit_suite_record($suite, 'test_skip');
- $JUNIT['files'][$file_name]['xml'] .= "$message\n";
- } elseif('FAIL' == $type) {
- junit_suite_record($suite, 'test_fail');
- $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n";
- } else {
- junit_suite_record($suite, 'test_error');
- $JUNIT['files'][$file_name]['xml'] .= "$escaped_details\n";
- }
-
- $JUNIT['files'][$file_name]['xml'] .= "\n";
-
-}
-
-function junit_suite_record($suite, $param, $value = 1) {
- global $JUNIT;
-
- $JUNIT[$param] += $value;
- $JUNIT['suites'][$suite][$param] += $value;
-}
-
-function junit_get_timer($file_name) {
- global $JUNIT;
- if (!junit_enabled()) return 0;
-
- if (isset($JUNIT['files'][$file_name]['total'])) {
- return number_format($JUNIT['files'][$file_name]['total'], 4);
- }
-
- return 0;
-}
-
-function junit_start_timer($file_name) {
- global $JUNIT;
- if (!junit_enabled()) return;
-
- if (!isset($JUNIT['files'][$file_name]['start'])) {
- $JUNIT['files'][$file_name]['start'] = microtime(true);
-
- $suite = junit_get_suitename_for($file_name);
- junit_init_suite($suite);
- $JUNIT['suites'][$suite]['files'][$file_name] = $file_name;
- }
-}
-
-function junit_get_suitename_for($file_name) {
- return junit_path_to_classname(dirname($file_name));
-}
-
-function junit_path_to_classname($file_name) {
- global $JUNIT;
- return $JUNIT['name'] . '.' . str_replace(DIRECTORY_SEPARATOR, '.', $file_name);
-}
-
-function junit_init_suite($suite_name) {
- global $JUNIT;
- if (!junit_enabled()) return;
-
- if (!empty($JUNIT['suites'][$suite_name])) {
- return;
- }
-
- $JUNIT['suites'][$suite_name] = array(
- 'name' => $suite_name,
- 'test_total' => 0,
- 'test_pass' => 0,
- 'test_fail' => 0,
- 'test_error' => 0,
- 'test_skip' => 0,
- 'suites' => array(),
- 'files' => array(),
- 'execution_time'=> 0,
- );
-}
-
-function junit_finish_timer($file_name) {
- global $JUNIT;
- if (!junit_enabled()) return;
-
- if (!isset($JUNIT['files'][$file_name]['start'])) {
- error("Timer for $file_name was not started!");
- }
-
- if (!isset($JUNIT['files'][$file_name]['total'])) {
- $JUNIT['files'][$file_name]['total'] = 0;
- }
-
- $start = $JUNIT['files'][$file_name]['start'];
- $JUNIT['files'][$file_name]['total'] += microtime(true) - $start;
- unset($JUNIT['files'][$file_name]['start']);
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim: noet sw=4 ts=4
- */
-?>
diff --git a/tests/test.sh b/tests/test.sh
deleted file mode 100755
index df0e9498..00000000
--- a/tests/test.sh
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/bin/bash
-#
-# It is intended to run the command "make test" from the root directory of the library
-#
-# @author valmat
-#
-
-
-THIS=`basename $0`
-
-function print_help() {
- echo "Use: $THIS [options...]"
- echo "Options:"
- echo " -p Specify PHP executable to run (default: /usr/bin/php)."
- echo " -e Name of test extension (default: extfortest.so)."
- echo " -n Do not compile the test extension."
- echo " -w Write a list of all failed tests to ."
- echo " -a Same as -w but append rather then truncating ."
- echo " -d foo=bar Pass -d option to the php binary (Define INI entry foo"
- echo " with value 'bar')."
- echo " -g Comma separated list of groups to show during test run"
- echo " (possible values: PASS, FAIL, XFAIL, SKIP, BORK, WARN, LEAK, REDIRECT)."
- echo " -m Test for memory leaks with Valgrind."
- echo " -r Removes all auxiliary files. (*.log, *.diff etc)."
- echo " -t Test file(s). Specify individual file(s) to test"
- echo " -s Write output to ."
- echo " -x Sets 'SKIP_SLOW_TESTS' environmental variable."
- echo " -o Cancels sets 'SKIP_ONLINE_TESTS' (default set)."
- echo " -q Quiet, no user interaction (same as environment NO_INTERACTION)."
- echo " -v Verbose mode."
- echo " -h This Help."
- echo
- exit;
-}
-
-PHP_BIN="/usr/bin/php"
-# options list
-SCR_OPT=""
-COMPILE_EXT=1
-# SKIP_ONLINE_TESTS == true
-OFFLINE=1
-EXT_NAME="extfortest.so"
-# The file list of the tests that will be launched
-TEST_FILES=""
-
-while getopts ":p:e:nw:a:d:g:mrt:s:xoqvh" opt ;
-do
- case $opt in
- p)
- PHP_BIN=$OPTARG;
- ;;
- e)
- EXT_NAME=$OPTARG;
- ;;
- n)
- COMPILE_EXT=0
- ;;
- w)
- SCR_OPT="$SCR_OPT -w $OPTARG"
- ;;
- a)
- SCR_OPT="$SCR_OPT -a $OPTARG"
- ;;
- d)
- SCR_OPT="$SCR_OPT -d $OPTARG"
- ;;
- g)
- SCR_OPT="$SCR_OPT -g $OPTARG"
- ;;
- s)
- SCR_OPT="$SCR_OPT -s $OPTARG"
- ;;
- m)
- SCR_OPT="$SCR_OPT -m"
- ;;
- r)
- # Removes all auxiliary files. (*.log, *.diff etc).
-
- # if quiet, only delete
- if [ $(echo $SCR_OPT | grep -o "\-q") ]; then
- find ./php/phpt -type f \( \
- -name '*.diff' -or -name '*.exp' -or -name '*.log' -or -name '*.out' \
- -or -name '*.php' -or -name '*.sh' -or -name '*.mem' -or \
- -name '*.phpt-diff' -or -name '*.phpt-exp' -or -name '*.phpt-log' -or -name '*.phpt-out' \
- -or -name '*.phpt-php' -or -name '*.phpt-sh' -or -name '*.phpt-mem' \
- \) -delete
-
- # else delete and print
- else
- echo -e "\x1b[1;31;47mRemove auxiliary files...\x1b[0;0m"
- for AUXF in `find ./php/phpt -type f \( \
- -name '*.diff' -or -name '*.exp' -or -name '*.log' -or -name '*.out' \
- -or -name '*.php' -or -name '*.sh' -or -name '*.mem' -or \
- -name '*.phpt-diff' -or -name '*.phpt-exp' -or -name '*.phpt-log' -or -name '*.phpt-out' \
- -or -name '*.phpt-php' -or -name '*.phpt-sh' -or -name '*.phpt-mem' \
- \)`;
- do
- echo -e "\x1b[1;31;47mdel \x1b[0;30;47m$(dirname $AUXF)/\x1b[1;31;47m$(basename $AUXF)\x1b[0;30;47m ...\x1b[0;0m"
- rm $AUXF
- done
- fi
- exit;
- ;;
- t)
- TEST_FILES="${TEST_FILES}${OPTARG} "
- ;;
- x)
- SCR_OPT="$SCR_OPT -x"
- ;;
- o)
- # SKIP_ONLINE_TESTS == false
- OFFLINE=0
- ;;
- q)
- SCR_OPT="$SCR_OPT -q"
- ;;
- v)
- SCR_OPT="$SCR_OPT -v"
- ;;
- h)
- print_help
- ;;
- *)
- echo "wrong option -$OPTARG";
- echo "";
- print_help
- ;;
- esac
-done
-
-# The file list of the tests that will be launched
-if [ ! "$TEST_FILES" ]; then
- TEST_FILES=`find ./php/phpt -type f -name "*.phpt"`
-fi
-
-# default offline mode
-if [ 1 = $OFFLINE ]; then
- SCR_OPT="$SCR_OPT --offline"
-fi
-
-# A list of all additional options
-SCR_OPT="$SCR_OPT -d extension_dir=$PWD/ext_dir -d extension=$EXT_NAME"
-
-
-# Create a local copy of the directory with the extension for run without installation
-./prepare.sh $EXT_NAME
-
-# Absolute path to library
-LIBRARY_PATH="$(cd $PWD/.. && echo $PWD)"
-
-if [ 1 = $COMPILE_EXT ]; then
-
- # Create a local copy of header files
- PHPCPP_H="$LIBRARY_PATH/tests/include/lib/phpcpp.h"
- PHPCPP_INC="$LIBRARY_PATH/tests/include/lib/phpcpp"
- mkdir -p "$LIBRARY_PATH/tests/include/lib"
- # local copy of /usr/include/phpcpp.h:
- if [ ! -L $PHPCPP_H ];
- then
- ln -s "$LIBRARY_PATH/phpcpp.h" $PHPCPP_H
- fi
- # local copy of /usr/include/phpcpp:
- if [ -a $PHPCPP_INC ];
- then
- rm -rf $PHPCPP_INC
- fi
- ln -s "$LIBRARY_PATH/include" $PHPCPP_INC
-
- echo "Compile the test extension"
- cd cpp
- make clean && make
- cd ..
-fi
-
-LD_LIBRARY_PATH="${LIBRARY_PATH}:${LD_LIBRARY_PATH}"
-export LD_LIBRARY_PATH
-echo $LD_LIBRARY_PATH
-
-
-# run tests
-$PHP_BIN run-tests.php $SCR_OPT -p "$PHP_BIN" $TEST_FILES
-
-
-