Download the PHP package lapistano/proxy-object without Composer

On this page you can find all versions of the php package lapistano/proxy-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package proxy-object

=========== ProxyObject

Initiated by Thomas Weinert back in 2008 I picked up his work and completed, extended, and tested it. The outcome is this little library making it much easier to generate a proxy of your system under test (SUT). Another thought on this library was, that it should be very easy to use if you know the way to mock classes and methods in PHPUnit. Proxy-object has almost the same API, but does not change the behavior of the proxied class/method. The only purpose is to expose hidden (protected & private) methods and members.

Current travis status: Build Status

Installation

Thanks to the feedback of beberlei the source is now PSR-0 compatible. There is no specific installation routine to be followed. Just clone or checkout the source into to your project and use it. In case you don't use a PSR-0 compatible autoloader, you only have to add the bootstrap.php into your bootstrap or autoloader.

Composer

Add the following lines to your composer.json file and update your project's composer installation.

This composer configuration will checkout the sources tagged as the 2nd release. In case your want the 'cutting eadge' version replace '2.*' by 'dev-master'. But be alarmed that this might be broken sometimes.

NOTE: In case you do not know what this means the composer project website is a good place to start.

Github

Thus I recommend the composer way to make proxy-object a dependency to your project. The sources are also available via github. Just clone it as you might be familiar with.

Usecases

  1. Exposing invisible Methods

    One of the main purpose of this library is to expose invisible (private or protected) methods to the SUT. To do so use just create a new ProxyBuilder object and pass the method to be exposed.

  2. Exposing invisible Members

    Another purpose of this library is to expose invisible members not reachable via a setter. This is to prevent you from writing setter methods just for the purpose of unit testing. Use the setProperties() method to archieve.

Despite the fact that it is possible to expose private members by naming them in the setProperties array, generating a proxy object without the property declaration will only expose protected members. This is because I am not a big fan of exposing too much from a class. If someone thinks this should be changed, I would be more than happy to discuss this topic.

  1. Creating a proxied object without calling the constructor

    Sometimes it is necessary to supress the invokation of the defined constructor. Therefore I followed the API of PHPunits MockBuilder and added the disableOriginalConstructor() method.

Ease access to the proxy-object in your test suite

Since I am really lazy ;) and I really like convenience I extended the PHPUnit_Framework_TestCase class and added the following method.

Every of your test cases should now extend your own extended test case class so you can create a new proxy builder by just calling $this->getProxyBuilder('\\my\\namespace\\myclass');. Used in one of the examples above it will look like this.

Documentation

Since there is a exhausting documentation of the API in the source code, I decided not to write a separate one. Use phpDocumentor to extract and generate your own documentation. I added a phpdoc.example.ini in the doc/config folder. Follow the instructions in the doc/config/README to setup the generation of the documentation.

Limitations

As you might expect there are also some limitations this library has to deal with. This limitations are not introduced by this implementation, but are limitations which come from PHP. So it is not possible to expose methods marked as final or static.

Future stuff


All versions of proxy-object with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lapistano/proxy-object contains the following files

Loading the files please wait ....