Download the PHP package jsiefer/class-mocker without Composer

On this page you can find all versions of the php package jsiefer/class-mocker. 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 class-mocker

ClassMocker

[Build Status] (https://travis-ci.org/jsiefer/class-mocker) [Coverage Status] (https://coveralls.io/github/jsiefer/class-mocker?branch=master)

Introduction

A simple helper library that lets you mock an entire frameworks or namespaces. This is helpful for writing unit test for extensions or plugins for libraries that do not support unit tests.

The idea is to automatically mock entire namespaces. The classes are then generated on the fly as soon as they are required.

You can register traits to add special functionality to certain classes if required.

Alternatively you can create a class footprint reference file that will old information such as class hierarchy, interfaces or constants.

Example

A simple example, imagine you are writing a plugin or extension for a framework which does not support unit testing very well but it requires you to extend from classes that are hard to mock without initializing the whole framework.

Now lets assume in order to test the above method you need to initialize the entire framework which may take a few seconds and defeats the purpose of quick unit tests.

The class-mocker lib lets you generate any missing class matching a pattern (e.g. Example_Namespace_*) which is then generated on the fly for you.

All generated class will also implementing the PHPUnit_Framework_MockObject_MockObject interface and give you access to expects() and method() methods for testing.

To enable the class-mocker you need a custom bootstrap file for your PHPUnit test project and define the classes that you want to generate on the fly.

That's it, now once enabled, you can simple test your classes without requiring any original framework classes.

Advanced

There is a lot more to it when you want to mock a framework, e.g. class hierarchies, class constants and some basic classes.

The important part when mocking many classes, is that the whole PHPUnit Test needs to agree to the same implementation.

You can define class footprints and include JSON class footprint reference files for cloning an entire class tree.

Ideally you don't use this library directly but instead create a framework-mock library which provides all class references and constants etc that are required and use that library in your project for testing.

This project was initial created to mock Magento for UnitTests. Check out the mock-mage lib which uses this lib to mock the entire Magento Framework/Application.


All versions of class-mocker with dependencies

PHP Build Version
Package Version
Requires php Version ~5.6||~7.0||~7.1
zendframework/zend-code Version ^3.0
phpunit/phpunit Version ~3.7||~4.0
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 jsiefer/class-mocker contains the following files

Loading the files please wait ....