PHPackages                             webnazakazku/mango-presenter-tester - 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. webnazakazku/mango-presenter-tester

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

webnazakazku/mango-presenter-tester
===================================

v0.5(1y ago)25.9k↓50%1MITPHPPHP &gt;=7.2

Since Mar 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/webnazakazku/mango-presenter-tester)[ Packagist](https://packagist.org/packages/webnazakazku/mango-presenter-tester)[ GitHub Sponsors](https://github.com/petrparolek)[ RSS](/packages/webnazakazku-mango-presenter-tester/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (15)Versions (6)Used By (0)

Mango Presenter Tester
======================

[](#mango-presenter-tester)

[![Build Status](https://github.com/webnazakazku/mango-presenter-tester/actions/workflows/main.yaml/badge.svg)](https://github.com/webnazakazku/mango-presenter-tester/actions/workflows/main.yaml)

Testing tool for Nette presenter with easy to use API.

Installation
------------

[](#installation)

The recommended way to install is via Composer:

```
composer require webnazakazku/nango-presenter-tester

```

It requires PHP version 7.2.

Integration &amp; configuration
-------------------------------

[](#integration--configuration)

If you are using power of Nette DI Container in your tests, you can use Presenter Tester in your current testing environment. All you need is to register PresenterTester service in `.neon` configuration for tests.

```
services:
	- Webnazakazku\MangoTester\PresenterTester\PresenterTester(baseUrl: "http://my-app.dev")
```

You can also specify list of [listeners](#listeners):

```
services:
	- Webnazakazku\MangoTester\PresenterTester(
		baseUrl: "http://my-app.dev"
		listeners: [
			MyListener()
		]
	)
```

Other way is to use Presenter Tester together with [webnazakazku/mango-tester-infrastructure](https://github.com/webnazakazku/mango-tester-infrastructure). In that case you have to register DI extension in infrastructure `.neon` file:

```
extensions:
	mango.presenterTester: Webnazakazku\MangoTester\PresenterTester\Bridges\Infrastructure\PresenterTesterExtension

```

In configuration of the extension you can set a base url and custom [identity factory](#identity-factory).

```
mango.presenterTester:
	baseUrl: http://my-app.dev
	identityFactory: MyIdentityFactory()

```

Usage
-----

[](#usage)

In Mango Tester Infrastructure environment, service `PresenterTester` is available in infrastructure container. When you get the service, you can start testing your presenters:

```
$testRequest = $presenterTester->createRequest('Admin:Article')
	->withParameters([
		'action' => 'edit',
		'id' => 1,
	]);
$testResult = $presenterTester->execute($testRequet);
$testResult->assertRenders('%A%Hello world article editation%A%');
```

As you can see, you first create a `TestPresenterRequest` using `createRequest` method on `PresenterTester`. You pass a presenter name (without an action) and later you configure the test request. You can set additional request parameters like `action` or your own application parameters. There are many other things you can configure on the request, like form values or headers.

After the test request is configured, you pass it to `execute` method, which performs presenter execution and returns `TestPresenterResult`, which wraps `Nette\Application\IResponse` with some additional data collected during execution.

The `TestPresenterResult` contains many useful assert functions like render check or form validity check. In our example there is `assertRenders` method, which asserts that presenter returns `TextResponse` and that the text contains given pattern. You probably already know the pattern format from [Tester\\Assert::match()](https://tester.nette.org/en/writing-tests#toc-assert-match) function.

TestPresenterRequest API
------------------------

[](#testpresenterrequest-api)

**Beware that `TestPresenterRequest` is immutable object.**

### `withParameters(array $parameters)`

[](#withparametersarray-parameters)

Set application request parameters.

### `withForm(string $formName, array $post, array $files)`

[](#withformstring-formname-array-post-array-files)

Add form submission data to request. You have to specify full component tree path to in `$formName`.

Presenter Tester supports forms with CSRF protection, but since it uses session, it is recommended to install [webnazakazku/mango-tester-http-mocks](https://github.com/webnazakazku/mango-tester-http-mocks) package.

### `withSignal(string $signal, array $componentParameters = [], string $componentClass = null)`

[](#withsignalstring-signal-array-componentparameters---string-componentclass--null)

With Presenter Tester, you can also easily test signal method. The componentClass is only required in the case you are using `nextras/secured-links` (which you should). It is also recommended to install [webnazakazku/mango-tester-http-mocks](https://github.com/webnazakazku/mango-tester-http-mocks) package.

### `withAjax`

[](#withajax)

(Not only) signals often uses AJAX, which you can enable using this method.

### `withMethod(string $methodName)`

[](#withmethodstring-methodname)

Change the HTTP method. The default is `GET`. You don't have to explicitly set a method for forms.

### `withHeaders(array $headers)`

[](#withheadersarray-headers)

Pass additional HTTP headers.

### `withIdentity(Nette\Security\IIdentity $identity)`

[](#withidentitynettesecurityiidentity-identity)

Change identity of User, which is executing given request. This is useful when login is required to perform the action. You can implement [identity factory](#identity-factory), which provides a default identity for each request.

### `withPost(array $post)`

[](#withpostarray-post)

### `withFiles(array $files)`

[](#withfilesarray-files)

### `withRawBody(string$rawBody)`

[](#withrawbodystringrawbody)

TestPresenterResult API
-----------------------

[](#testpresenterresult-api)

It is a result of test execution. It wraps `Nette\Application\IResponse` and adds few methods to check the response easily.

### `assertRenders($match)`

[](#assertrendersmatch)

Checks that response is `TextResponse`. Also, you can provide a `$match` parameter to check that response contains some text. You can either pass [pattern](https://tester.nette.org/en/writing-tests#toc-assert-match) or an array plain strings.

### `assertNotRenders($matches)`

[](#assertnotrendersmatches)

Checks that given pattern or strings were not rendered.

### `assertJson($expected)`

[](#assertjsonexpected)

Checks that response is JSON. You can optionally pass expected payload.

### `assertBadRequest($code)`

[](#assertbadrequestcode)

Checks that requests terminates with bad request exception (e.g. 404 not found).

### `assertRedirects(string $presenterName, array $parameters)`

[](#assertredirectsstring-presentername-array-parameters)

Checks that request redirects to given presenter. You can also pass parameters to check. Extra parameters in redirect request are ignored.

### `assertRedirectsUrl($url)`

[](#assertredirectsurlurl)

### `assertFormValid($formName)`

[](#assertformvalidformname)

### `assertFormHasErrors($formName, $formErrors)`

[](#assertformhaserrorsformname-formerrors)

---

Also, there are methods like `getResponse` or `getPresenter` to access original data a perform some custom checks.

Listeners
---------

[](#listeners)

You can hook to some events by implementing `Webnazakazku\MangoTester\PresenterTester\IPresenterTesterListener` interface. Then you can e.g. modify test request or execute some implicit result checks.

To register a listener, simply register it as a service in DI container (infrastructure container if you are using Mango Tester Infrastructure).

Identity factory
----------------

[](#identity-factory)

Using identity factory you can implement a factory which creates a default identity. The factory is a simple PHP callback, which accepts `PresenterTestRequest` and returns `Nette\Security\IIdentity`.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~608 days

Total

5

Last Release

553d ago

PHP version history (2 changes)v0.1PHP ~7.1

v0.4PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6066243?v=4)[Petr Parolek](/maintainers/petrparolek)[@petrparolek](https://github.com/petrparolek)

---

Top Contributors

[![matej21](https://avatars.githubusercontent.com/u/1276059?v=4)](https://github.com/matej21 "matej21 (20 commits)")[![petrparolek](https://avatars.githubusercontent.com/u/6066243?v=4)](https://github.com/petrparolek "petrparolek (15 commits)")[![KuceraMartin](https://avatars.githubusercontent.com/u/3159068?v=4)](https://github.com/KuceraMartin "KuceraMartin (5 commits)")[![JanTvrdik](https://avatars.githubusercontent.com/u/175109?v=4)](https://github.com/JanTvrdik "JanTvrdik (2 commits)")[![jiripudil](https://avatars.githubusercontent.com/u/1042159?v=4)](https://github.com/jiripudil "jiripudil (1 commits)")[![trejjam](https://avatars.githubusercontent.com/u/3594540?v=4)](https://github.com/trejjam "trejjam (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/webnazakazku-mango-presenter-tester/health.svg)

```
[![Health](https://phpackages.com/badges/webnazakazku-mango-presenter-tester/health.svg)](https://phpackages.com/packages/webnazakazku-mango-presenter-tester)
```

###  Alternatives

[nette/nette

👪 Nette Framework - innovative framework for fast and easy development of secured web applications in PHP (metapackage)

1.6k2.8M335](/packages/nette-nette)[mangoweb/presenter-tester

18173.5k](/packages/mangoweb-presenter-tester)[contributte/codeception

Integration of Nette framework to Codeception.

27886.9k1](/packages/contributte-codeception)[contributte/forms-bootstrap

Nette extension for Bootstrap forms

211.1M4](/packages/contributte-forms-bootstrap)[tomaj/nette-api

Nette api

36261.8k4](/packages/tomaj-nette-api)[nasext/dependent-select-box

Dependent Select Box for Nette Framework.

21262.8k2](/packages/nasext-dependent-select-box)

PHPackages © 2026

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