TYPO3 API  SVNRelease
Testclasses.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * a  singleton class
00005  *
00006  */
00007 class t3lib_object_tests_singleton implements t3lib_Singleton {
00008 
00009 }
00010 
00011 /**
00012  * test class A that depends on B and C
00013  *
00014  */
00015 class t3lib_object_tests_a {
00016     public $b;
00017     public $c;
00018 
00019     public function __construct( t3lib_object_tests_c $c, t3lib_object_tests_b $b) {
00020         $this->b = $b;
00021         $this->c = $c;
00022     }
00023 }
00024 /**
00025  * test class A that depends on B and C and has a third default parameter in constructor
00026  *
00027  */
00028 class t3lib_object_tests_amixed_array {
00029     public $b;
00030     public $c;
00031     public $myvalue;
00032     public function __construct(t3lib_object_tests_b $b, t3lib_object_tests_c $c, array $myvalue=array('some' => 'default')) {
00033         $this->b = $b;
00034         $this->c = $c;
00035         $this->myvalue = $myvalue;
00036     }
00037 }
00038 
00039 /**
00040  * test class A that depends on B and C and has a third default parameter in constructor that defaults to NULL
00041  *
00042  */
00043 class t3lib_object_tests_amixed_null {
00044     public $b;
00045     public $c;
00046     public $myvalue;
00047     public function __construct(t3lib_object_tests_b $b, t3lib_object_tests_c $c, $myvalue = NULL) {
00048         $this->b = $b;
00049         $this->c = $c;
00050         $this->myvalue = $myvalue;
00051     }
00052 }
00053 
00054 /**
00055  * test class A that depends on B and C and has a third default parameter in constructor
00056  *
00057  */
00058 class t3lib_object_tests_amixed_array_singleton implements t3lib_Singleton {
00059     public $b;
00060     public $c;
00061     public $myvalue;
00062     public function __construct(t3lib_object_tests_b $b, t3lib_object_tests_c $c, $someDefaultParameter = array('some' => 'default')) {
00063         $this->b = $b;
00064         $this->c = $c;
00065         $this->myvalue = $someDefaultParameter;
00066     }
00067 }
00068 
00069 /**
00070  * test class B that depends on C
00071  *
00072  */
00073 class t3lib_object_tests_b implements t3lib_Singleton {
00074     public $c;
00075     public function __construct(t3lib_object_tests_c $c) {
00076         $this->c = $c;
00077     }
00078 }
00079 
00080 
00081 /**
00082  * test class C without dependencys
00083  *
00084  */
00085 class t3lib_object_tests_c implements t3lib_Singleton {
00086 
00087 }
00088 
00089 /**
00090  * test class B-Child that extends Class B (therfore depends also on Class C)
00091  *
00092  */
00093 class t3lib_object_tests_b_child extends t3lib_object_tests_b {
00094 }
00095 
00096 interface t3lib_object_tests_someinterface extends t3lib_Singleton {
00097 
00098 }
00099 
00100 /**
00101  * class which implements a Interface
00102  *
00103  */
00104 class t3lib_object_tests_someimplementation implements t3lib_object_tests_someinterface {
00105 }
00106 
00107 /**
00108  * test class B-Child that extends Class B (therfore depends also on Class C)
00109  *
00110  */
00111 class t3lib_object_tests_b_child_someimplementation extends t3lib_object_tests_b implements t3lib_object_tests_someinterface {
00112 }
00113 
00114 /**
00115  * class which depends on a Interface
00116  *
00117  */
00118 class t3lib_object_tests_needsinterface {
00119     public function __construct(t3lib_object_tests_someinterface $i) {
00120         $this->dependency = $i;
00121     }
00122 }
00123 
00124 /**
00125  * Prototype classes that depend on each other
00126  *
00127  */
00128 class t3lib_object_tests_cyclic1 {
00129     public function __construct(t3lib_object_tests_cyclic2 $c) {
00130 
00131     }
00132 }
00133 
00134 class t3lib_object_tests_cyclic2 {
00135     public function __construct(t3lib_object_tests_cyclic1 $c) {
00136 
00137     }
00138 }
00139 
00140 class t3lib_object_tests_cyclic1WithSetterDependency {
00141     public function injectFoo(t3lib_object_tests_cyclic2WithSetterDependency $c) {
00142 
00143     }
00144 }
00145 
00146 class t3lib_object_tests_cyclic2WithSetterDependency {
00147     public function injectFoo(t3lib_object_tests_cyclic1WithSetterDependency $c) {
00148 
00149     }
00150 }
00151 
00152 /**
00153  * class which has setter injections defined
00154  *
00155  */
00156 class t3lib_object_tests_injectmethods {
00157     public $b;
00158     public $bchild;
00159 
00160     public function injectClassB(t3lib_object_tests_b $o) {
00161         $this->b = $o;
00162     }
00163 
00164     /**
00165      * @inject
00166      * @param t3lib_object_tests_b $o
00167      */
00168     public function setClassBChild(t3lib_object_tests_b_child $o) {
00169         $this->bchild = $o;
00170     }
00171 }
00172 
00173 /**
00174  * class which needs extenson settings injected
00175  *
00176  */
00177 class t3lib_object_tests_injectsettings {
00178     public $settings;
00179     public function injectExtensionSettings(array $settings) {
00180         $this->settings = $settings;
00181     }
00182 }
00183 
00184 /**
00185  *
00186  *
00187  */
00188 class t3lib_object_tests_resolveablecyclic1 implements t3lib_Singleton {
00189     public $o2;
00190     public function __construct(t3lib_object_tests_resolveablecyclic2 $cyclic2) {
00191         $this->o2 = $cyclic2;
00192     }
00193 }
00194 
00195 /**
00196  *
00197  *
00198  */
00199 class t3lib_object_tests_resolveablecyclic2 implements t3lib_Singleton {
00200     public $o1;
00201     public $o3;
00202     public function injectCyclic1(t3lib_object_tests_resolveablecyclic1 $cyclic1) {
00203         $this->o1 = $cyclic1;
00204     }
00205     public function injectCyclic3(t3lib_object_tests_resolveablecyclic3 $cyclic3) {
00206         $this->o3 = $cyclic3;
00207     }
00208 }
00209 
00210 /**
00211  *
00212  *
00213  */
00214 class t3lib_object_tests_resolveablecyclic3 implements t3lib_Singleton {
00215     public $o1;
00216     public function injectCyclic1(t3lib_object_tests_resolveablecyclic1 $cyclic1) {
00217         $this->o1 = $cyclic1;
00218     }
00219 }
00220 
00221 class t3lib_object_tests_class_with_injectsettings {
00222     public function injectFoo(t3lib_object_tests_resolveablecyclic1 $c1) {
00223     }
00224 
00225     public function injectSettings(array $settings) {
00226     }
00227 }
00228 
00229 /*
00230  *  a Singleton requires a Prototype for Injection -> allowed, autowiring active, but in development context we write a log message, as it is bad practice and most likely points to some logic error.
00231 If a Singleton requires a Singleton for Injection -> allowed, autowiring active
00232 If a Prototype requires a Prototype for Injection -> allowed, autowiring active
00233 If a Prototype requires a Singleton for Injection -> allowed, autowiring active
00234  */
00235 class t3lib_object_singleton implements t3lib_Singleton {
00236 }
00237 
00238 class t3lib_object_prototype {
00239 }
00240 
00241 class t3lib_object_singletonNeedsPrototype implements t3lib_Singleton {
00242     public function injectDependency(t3lib_object_prototype $dependency) {
00243         $this->dependency = $dependency;
00244     }
00245 }
00246 
00247 class t3lib_object_singletonNeedsSingleton implements t3lib_Singleton {
00248     public function injectDependency(t3lib_object_singleton $dependency) {
00249         $this->dependency = $dependency;
00250     }
00251 }
00252 class t3lib_object_prototypeNeedsPrototype {
00253     public function injectDependency(t3lib_object_prototype $dependency) {
00254         $this->dependency = $dependency;
00255     }
00256 }
00257 class t3lib_object_prototypeNeedsSingleton {
00258     public function injectDependency(t3lib_object_singleton $dependency) {
00259         $this->dependency = $dependency;
00260     }
00261 }
00262 
00263 class t3lib_object_singletonNeedsPrototypeInConstructor implements t3lib_Singleton {
00264     public function __construct(t3lib_object_prototype $dependency) {
00265         $this->dependency = $dependency;
00266     }
00267 }
00268 
00269 class t3lib_object_singletonNeedsSingletonInConstructor implements t3lib_Singleton {
00270     public function __construct(t3lib_object_singleton $dependency) {
00271         $this->dependency = $dependency;
00272     }
00273 }
00274 class t3lib_object_prototypeNeedsPrototypeInConstructor {
00275     public function __construct(t3lib_object_prototype $dependency) {
00276         $this->dependency = $dependency;
00277     }
00278 }
00279 class t3lib_object_prototypeNeedsSingletonInConstructor {
00280     public function __construct(t3lib_object_singleton $dependency) {
00281         $this->dependency = $dependency;
00282     }
00283 }