Another very important part of software development is building test suits for
automated testing of your piece of work. This is to ensure it's working correctly and
after any changes it maintains backward compatibility. To ease the process for PHP
developers, there are a lot of testing tools available on the market. Among them
are some very popular tools like PHPUnit. In this chapter we will learn about unit
testing with PHP.
Reflection
Reflection API provides some functionality to find out what is inside an object or a
class at runtime. Besides that, reflection API lets you invoke dynamically any
method or property of any object. Let's get our hands dirty with reflection. There
are numerous objects introduced in reflection API. Among them, the following
are important:
class Reflection { }
interface Reflector { }
class ReflectionException extends Exception { }
class ReflectionFunction implements Reflector { }
class ReflectionParameter implements Reflector { }
class ReflectionMethod extends ReflectionFunction { }
class ReflectionClass implements Reflector { }
class ReflectionObject extends ReflectionClass { }
class ReflectionProperty implements Reflector { }
class ReflectionExtension implements Reflector { }
Reflection and Unit Testing
[ 98 ]
Let us go and play with ReflectionClass first.
Pages:
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115