summaryrefslogtreecommitdiff
path: root/ext/standard/tests
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2003-06-29 18:26:24 +0000
committerSVN Migration <svn@php.net>2003-06-29 18:26:24 +0000
commit54715b27657f09025ca2d59b6caae0901fcaed3c (patch)
treea30b6db1ed69a8f48fd70712cff673d2fca9b0a4 /ext/standard/tests
parent082a1489d20686763496ae09b128c2cdfa9e5637 (diff)
downloadphp-git-php-5.0.0b1.tar.gz
This commit was manufactured by cvs2svn to create tag 'php_5_0_0b1'.php-5.0.0b1
Diffstat (limited to 'ext/standard/tests')
-rw-r--r--ext/standard/tests/aggregation/aggregate.lib65
-rw-r--r--ext/standard/tests/aggregation/aggregate.phpt19
-rw-r--r--ext/standard/tests/aggregation/aggregate_methods.phpt25
-rw-r--r--ext/standard/tests/aggregation/aggregate_methods_by_list.phpt22
-rw-r--r--ext/standard/tests/aggregation/aggregate_methods_by_regexp.phpt20
-rw-r--r--ext/standard/tests/aggregation/aggregate_properties.phpt19
-rw-r--r--ext/standard/tests/aggregation/aggregate_properties_by_list.phpt20
-rw-r--r--ext/standard/tests/aggregation/aggregate_properties_by_regexp.phpt22
-rw-r--r--ext/standard/tests/aggregation/aggregation_info.phpt31
-rw-r--r--ext/standard/tests/aggregation/deaggregate.phpt72
10 files changed, 315 insertions, 0 deletions
diff --git a/ext/standard/tests/aggregation/aggregate.lib b/ext/standard/tests/aggregation/aggregate.lib
new file mode 100644
index 0000000000..3799285f75
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate.lib
@@ -0,0 +1,65 @@
+<?php
+
+class simple {
+ var $simple_prop = 100;
+
+ function simple()
+ {
+ print "I'm alive!\n";
+ }
+}
+
+class helper {
+ var $my_prop = 5;
+ var $your_prop = array('init' => PHP_VERSION);
+ var $our_prop = '****';
+ var $_priv_prop = null;
+
+ function helper()
+ {
+ print "just trying to help\n";
+ }
+
+ function do_this()
+ {
+ print "I'm helping!\n";
+ }
+
+ function do_that()
+ {
+ print "I'm aggregating!\n";
+ }
+
+ function just_another_method()
+ {
+ print "yep, that's me\n";
+ }
+
+ function _private()
+ {
+ print "Don't touch me!\n";
+ }
+
+ function __wakeup()
+ {
+ }
+}
+
+class mixin {
+ var $simple_prop = true;
+ var $mix = true;
+
+ function mix_it()
+ {
+ print "mixing\n";
+ }
+}
+
+class moby {
+ function mix_it()
+ {
+ print "I'm redundant!\n";
+ }
+}
+
+?>
diff --git a/ext/standard/tests/aggregation/aggregate.phpt b/ext/standard/tests/aggregation/aggregate.phpt
new file mode 100644
index 0000000000..46aa9133b6
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate.phpt
@@ -0,0 +1,19 @@
+--TEST--
+aggregating everything
+--FILE--
+<?php
+
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate($obj, 'helper');
+$obj->do_this();
+$obj->do_that();
+print $obj->our_prop;
+
+?>
+--EXPECT--
+I'm alive!
+I'm helping!
+I'm aggregating!
+****
diff --git a/ext/standard/tests/aggregation/aggregate_methods.phpt b/ext/standard/tests/aggregation/aggregate_methods.phpt
new file mode 100644
index 0000000000..b612881c59
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate_methods.phpt
@@ -0,0 +1,25 @@
+--TEST--
+aggregating all methods
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate_methods($obj, 'mixin');
+$obj->mix_it();
+print $obj->simple_prop."\n";
+print implode(',', get_class_methods($obj))."\n";
+print implode(',', array_keys(get_object_vars($obj)))."\n";
+aggregate_methods($obj, 'moby');
+$obj->mix_it();
+
+?>
+--EXPECT--
+I'm alive!
+mixing
+100
+simple,mix_it
+simple_prop
+mixing
diff --git a/ext/standard/tests/aggregation/aggregate_methods_by_list.phpt b/ext/standard/tests/aggregation/aggregate_methods_by_list.phpt
new file mode 100644
index 0000000000..312a57d1b2
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate_methods_by_list.phpt
@@ -0,0 +1,22 @@
+--TEST--
+aggregating methods specified in the list
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate_methods_by_list($obj, 'helper', array('just_another_method'));
+print implode(',', get_class_methods($obj))."\n";
+$obj2 = new simple();
+aggregate_methods_by_list($obj2, 'helper', array('just_another_method'), true);
+print implode(',', get_class_methods($obj2))."\n";
+$obj->just_another_method();
+?>
+--EXPECT--
+I'm alive!
+simple,just_another_method
+I'm alive!
+simple,do_this,do_that
+yep, that's me
diff --git a/ext/standard/tests/aggregation/aggregate_methods_by_regexp.phpt b/ext/standard/tests/aggregation/aggregate_methods_by_regexp.phpt
new file mode 100644
index 0000000000..6525e50cff
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate_methods_by_regexp.phpt
@@ -0,0 +1,20 @@
+--TEST--
+aggregating methods matching regular expression
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate_methods_by_regexp($obj, 'helper', '/^do/');
+print implode(',', get_class_methods($obj))."\n";
+$obj2 = new simple();
+aggregate_methods_by_regexp($obj2, 'helper', '/^do/', true);
+print implode(',', get_class_methods($obj2))."\n";
+?>
+--EXPECT--
+I'm alive!
+simple,do_this,do_that
+I'm alive!
+simple,just_another_method
diff --git a/ext/standard/tests/aggregation/aggregate_properties.phpt b/ext/standard/tests/aggregation/aggregate_properties.phpt
new file mode 100644
index 0000000000..2a976c71a7
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate_properties.phpt
@@ -0,0 +1,19 @@
+--TEST--
+aggregating all default properties
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate_properties($obj, 'mixin');
+print implode(',', array_keys(get_object_vars($obj)))."\n";
+print $obj->simple_prop."\n";
+print implode(',', get_class_methods($obj))."\n";
+?>
+--EXPECT--
+I'm alive!
+simple_prop,mix
+100
+simple
diff --git a/ext/standard/tests/aggregation/aggregate_properties_by_list.phpt b/ext/standard/tests/aggregation/aggregate_properties_by_list.phpt
new file mode 100644
index 0000000000..fa12d36bcb
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate_properties_by_list.phpt
@@ -0,0 +1,20 @@
+--TEST--
+aggregating default properties specified in the list
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate_properties_by_list($obj, 'helper', array('my_prop', 'our_prop'));
+print implode(',', array_keys(get_object_vars($obj)))."\n";
+$obj2 = new simple();
+aggregate_properties_by_list($obj2, 'helper', array('my_prop'), true);
+print implode(',', array_keys(get_object_vars($obj2)))."\n";
+?>
+--EXPECT--
+I'm alive!
+simple_prop,my_prop,our_prop
+I'm alive!
+simple_prop,your_prop,our_prop
diff --git a/ext/standard/tests/aggregation/aggregate_properties_by_regexp.phpt b/ext/standard/tests/aggregation/aggregate_properties_by_regexp.phpt
new file mode 100644
index 0000000000..9a74f5536d
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregate_properties_by_regexp.phpt
@@ -0,0 +1,22 @@
+--TEST--
+aggregating default properties matching regular expression
+--SKIPIF--
+<?php if (!function_exists('aggregate_properties_by_regexp')) print "skip"; ?>
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate_properties_by_regexp($obj, 'helper', '/^my/');
+print implode(',', array_keys(get_object_vars($obj)))."\n";
+$obj2 = new simple();
+aggregate_properties_by_regexp($obj2, 'helper', '/^my/', true);
+print implode(',', array_keys(get_object_vars($obj2)))."\n";
+?>
+--EXPECT--
+I'm alive!
+simple_prop,my_prop
+I'm alive!
+simple_prop,your_prop,our_prop
diff --git a/ext/standard/tests/aggregation/aggregation_info.phpt b/ext/standard/tests/aggregation/aggregation_info.phpt
new file mode 100644
index 0000000000..8dd943cbcc
--- /dev/null
+++ b/ext/standard/tests/aggregation/aggregation_info.phpt
@@ -0,0 +1,31 @@
+--TEST--
+retrieving aggregation info
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate($obj, 'mixin');
+print_r(aggregation_info($obj));
+?>
+--EXPECT--
+I'm alive!
+Array
+(
+ [mixin] => Array
+ (
+ [methods] => Array
+ (
+ [0] => mix_it
+ )
+
+ [properties] => Array
+ (
+ [0] => mix
+ )
+
+ )
+
+)
diff --git a/ext/standard/tests/aggregation/deaggregate.phpt b/ext/standard/tests/aggregation/deaggregate.phpt
new file mode 100644
index 0000000000..5c551d75bd
--- /dev/null
+++ b/ext/standard/tests/aggregation/deaggregate.phpt
@@ -0,0 +1,72 @@
+--TEST--
+deaggreating
+--POST--
+--GET--
+--FILE--
+<?php
+include "ext/standard/tests/aggregation/aggregate.lib";
+
+$obj = new simple();
+aggregate($obj, 'helper');
+aggregate($obj, 'mixin');
+print_r(aggregation_info($obj));
+deaggregate($obj, 'helper');
+print_r(aggregation_info($obj));
+deaggregate($obj);
+var_dump(aggregation_info($obj));
+?>
+--EXPECT--
+I'm alive!
+Array
+(
+ [helper] => Array
+ (
+ [methods] => Array
+ (
+ [0] => do_this
+ [1] => do_that
+ [2] => just_another_method
+ )
+
+ [properties] => Array
+ (
+ [0] => my_prop
+ [1] => your_prop
+ [2] => our_prop
+ )
+
+ )
+
+ [mixin] => Array
+ (
+ [methods] => Array
+ (
+ [0] => mix_it
+ )
+
+ [properties] => Array
+ (
+ [0] => mix
+ )
+
+ )
+
+)
+Array
+(
+ [mixin] => Array
+ (
+ [methods] => Array
+ (
+ [0] => mix_it
+ )
+
+ [properties] => Array
+ (
+ [0] => mix
+ )
+
+ )
+
+)
+bool(false)