PHPackages                             vu/zf2-test-extensions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vu/zf2-test-extensions

AbandonedArchivedLibrary

vu/zf2-test-extensions
======================

Makes testing controllers and services easier in Zf2

1.0.1(11y ago)16.8k21BSD-3-ClausePHPPHP &gt;=5.3.3

Since Aug 6Pushed 11y ago19 watchersCompare

[ Source](https://github.com/vuhl/zf2-test-extensions)[ Packagist](https://packagist.org/packages/vu/zf2-test-extensions)[ RSS](/packages/vu-zf2-test-extensions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (1)

vu/zf2-test-extensions
======================

[](#vuzf2-test-extensions)

Introduction
------------

[](#introduction)

vu/zf2-test-extensions enables easier testing of our Zf2 controllers and services. Most code contained within this project is specifically for use with VeteransUnited Zf2 projects, however is open for anyone to use.

Installation Using Composer
---------------------------

[](#installation-using-composer)

Add "vu/zf2-test-extensions" to the require section of your composer.json file and run a respective install or update. For more information on Composer, please visit [their website](https://getcomposer.org/).

Controllers
-----------

[](#controllers)

The abstract controllers in vu/zf2-test-extensions help ensure that controllers are fully and easily tested. This is done by mocking out the ServiceManager, Request, and Response objects upon test creation.

\###Action Controllers The AbstractActionController is what should be used in place of the ActionController from Zf2. This controller will extend the Zf2 ActionController while adding in the benefits of being easier to test.

```
namespace NewNamespace;

use Vu\Zf2TestExtensions\Controller\AbstractActionController;

class NewActionController extends AbstractActionController{
    //typical controller code goes here
}
```

\###Restful Controllers The AbstractRestfulController is what should be used in place of the AbstractRestfulController from Zf2. This controller will extend the Zf2 AbstractRestfulController while adding in the benefits of being easier to test.

```
namespace NewNamespace;

use Vu\Zf2TestExtensions\Controller\AbstractRestfulController;

class NewRestfulController extends AbstractRestfulController{
    //typical restful controller code goes here
}
```

Testing Controllers
-------------------

[](#testing-controllers)

When testing your controllers, you will want to extend the respective test controller on your test class. This way you can get full benefit out of the library. The extended class will set up the class you're testing and inject an instance of the ServiceLocator. Note that all test classes must implement the getControllerName() method.

\###Action Controllers When testing a controller extending the AbstractActionController, you will want your test class to extend AbstractActionControllerTest. Example:

```
namespace NewNamespace;

use Vu\Zf2TestExtensions\Test\Controller\AbstractActionControllerTest;

class NewActionControllerTest extends AbstractActionControllerTest{

    public function getControllerName(){
        return "NewNamespace\NewActionController";
    }

    //Other test code goes here
}
```

\###Restful Controllers When testing a controller extending the AbstractRestfulController, you will want your test class to extend AbstractRestfulControllerTest. Example:

```
namespace NewNamespace;

use Vu\Zf2TestExtensions\Test\Controller\AbstractRestfulControllerTest;

class NewRestfulControllerTest extends AbstractRestfulControllerTest{

    public function getControllerName(){
        return "NewNamespace\NewRestfulController";
    }

    //Other test code goes here
}
```

Services
--------

[](#services)

\###Service Locator The provided AbstractServiceLocatorAwareService helps by automatically injecting the Zf2 ServiceLocator into your class. Classes that will be loaded via the ServiceLocator should extend this class.

```
namespace NewNamespace;

use Vu\Zf2TestExtensions\Service\AbstractServiceLocatorAwareService;

class NewBusinessLogicClass extends AbstractServiceLocatorAwareService{
    //your code...
}
```

Testing Services
----------------

[](#testing-services)

\###Service Locator The AbstractServiceLocatorAwareServiceTest sets up the service being tested and injects an instance of the ServiceLocator for you. This should be used to test all classes that extend AbstractServiceLocatorAwareService. Note that all test classes using AbstractServiceLocatorAwareServiceTest must implement the getClassName() method

```
namespace NewNamespace;

use Vu\Zf2TestExtensions\Test\Service\AbstractServiceLocatorAwareServiceTest;

class NewBusinessLogicClassTest extends AbstractServiceLocatorAwareServiceTest{

    public function getClassName(){
        return 'NewNamespace\NewBusinessLogicClass';
    }

    //Other test code goes here
}
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

4295d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef18f6b55d80f4e63c2b463df7e76cf9d91a6ebeb4613656e9e1d517815230ad?d=identicon)[cerealean](/maintainers/cerealean)

![](https://www.gravatar.com/avatar/42b5d05f6133750d55c371e052d5bf2f6fb0bb045fec0b368149427d9ff3d3d5?d=identicon)[lepermessiah57](/maintainers/lepermessiah57)

![](https://www.gravatar.com/avatar/045795867e28dbb811d7bd2da3af18a56dc4f0bfaec93b825a4a04356ed6ac78?d=identicon)[clarkstuth](/maintainers/clarkstuth)

---

Top Contributors

[![cerealean](https://avatars.githubusercontent.com/u/6100756?v=4)](https://github.com/cerealean "cerealean (10 commits)")[![lepermessiah57](https://avatars.githubusercontent.com/u/1280635?v=4)](https://github.com/lepermessiah57 "lepermessiah57 (4 commits)")[![clarkstuth](https://avatars.githubusercontent.com/u/1616268?v=4)](https://github.com/clarkstuth "clarkstuth (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vu-zf2-test-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/vu-zf2-test-extensions/health.svg)](https://phpackages.com/packages/vu-zf2-test-extensions)
```

###  Alternatives

[zf-commons/zfc-base

A set of genetic (abstract) classes which are commonly used across multiple modules.

1441.1M25](/packages/zf-commons-zfc-base)[zfr/zfr-cors

Zend Framework module that let you deal with CORS requests

611.2M3](/packages/zfr-zfr-cors)[org_heigl/hybridauth

Lightweight Authentication Module for Zend-Framework 2 using the hybridauth-library

211.9k](/packages/org-heigl-hybridauth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
