PHPackages                             kambo/classopener - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. kambo/classopener

ActiveLibrary[Testing &amp; Quality](/categories/testing)

kambo/classopener
=================

Mock/stub final classes and methods in PHPUnit.

v0.0.1(8y ago)010MITPHPPHP &gt;=7.0.0

Since Feb 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/kambo-1st/ClassOpener)[ Packagist](https://packagist.org/packages/kambo/classopener)[ RSS](/packages/kambo-classopener/feed)WikiDiscussions master Synced 3d ago

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

Class opener - Mock/stub final classes and methods in PHPUnit.
==============================================================

[](#class-opener---mockstub-final-classes-and-methods-in-phpunit)

[![Build Status](https://camo.githubusercontent.com/aad4df639d60c81c3a42cc46be7180e4f06b159dd47b6f155484bd51e271be37/68747470733a2f2f7472617669732d63692e6f72672f6b616d626f2d3173742f436c6173734f70656e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kambo-1st/ClassOpener)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/14b6ef50b5d0cf263c260dab7c0b21376810bb66583cd7c4fe2e43047f1df438/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b616d626f2d3173742f436c6173734f70656e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kambo-1st/ClassOpener/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/18b3d5d516876d778833e0bf333704abf90c5a86594e52463709f0de50fefd17/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b616d626f2d3173742f436c6173734f70656e65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/kambo-1st/ClassOpener/)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)Wouldn't it be great if you can mock/stub final classes and methods in PHPUnit? With this package you can do exactly that. Just extend your test case from `ClassOpenerTestCase` and add to the test method comment following annotation`@disableFinal name\of\the\final\class` After this you can continue with your regular mock/stub techniques.

But be aware, there are few gotchas as this is basically a hack packed in a nice package with ribbon.

Install
-------

[](#install)

Prefered way to install library is with composer:

```
composer require kambo/classopener
```

Usage
-----

[](#usage)

Extend your test case from `ClassOpenerTestCase` and add to the test method comment following annotation`@disableFinal name\of\the\final\class` After this you can continue with your regular mock/stub techniques.

Example:

```
