PHPackages                             xp-framework/webtest - 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. xp-framework/webtest

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

xp-framework/webtest
====================

Web tests for the XP Framework

v7.1.0(4y ago)014BSD-3-ClausePHPPHP &gt;=7.0.0CI failing

Since Aug 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/xp-framework/webtest)[ Packagist](https://packagist.org/packages/xp-framework/webtest)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-webtest/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (6)Versions (9)Used By (0)

Webtest
=======

[](#webtest)

[![Build status on GitHub](https://github.com/xp-framework/webtest/workflows/Tests/badge.svg)](https://github.com/xp-framework/webtest/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/1c8b988dfaf519aa5121c48ecc1a77648130d067f5d63966a3fd0d0298e90097/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f776562746573742f76657273696f6e2e706e67)](https://packagist.org/packages/xp-framework/webtest)

Web tests for the XP Framework

Example
-------

[](#example)

The following web test case consists of opening GitHub's homepage and asserting the title to equal the company's name:

```
use unittest\web\{WebTestCase, Webtest};
use unittest\Test;

#[Webtest(url: 'https://github.com/')]
class GitHubTestCase extends WebTestCase {

  #[Test]
  public function home() {
    $this->beginAt('/');
    $this->assertStatus(200);
    $this->assertTitleEquals('GitHub: Where the world builds software · GitHub');
  }
}
```

Running it works as with normal test cases:

```
$ xp test GitHubTestCase
[.]

✓: 1/1 run (0 skipped), 1 succeeded, 0 failed
Memory used: 1861.12 kB (2474.66 kB peak)
Time taken: 1.225 seconds
```

To overwrite the default URL specified in the annotation, supply it as command line argument, e.g. `unittest GitHubTestCase -a https://github.staging.lan/`.

Assertion methods
-----------------

[](#assertion-methods)

On top of the assertion methods provided by the unittest library, the following response-related assertions are available:

```
public void assertStatus(int $status)
public void assertUrlEquals(peer.URL $url)
public void assertContentType(string $ctype)
public void assertHeader(string $header, string $value)
public void assertElementPresent(string $id)
public void assertTextPresent(string $text)
public void assertImagePresent(string $src)
public void assertLinkPresent(string $url)
public void assertLinkPresentWithText(string $text)
public void assertFormPresent(string $name= null)
public void assertTitleEquals($title)
```

Navigation
----------

[](#navigation)

To follow links inside a page, a web test can utilize the click methods:

```
protected void clickLink(string $id);
protected void clickLinkWithText(string $text);
```

Forms
-----

[](#forms)

To work with forms, the `getForm()` method can be used:

```
use unittest\web\{WebTestCase, Webtest};
use unittest\Test;

#[Webtest(url: 'https://github.com/')]
class GitHubTestCase extends WebTestCase {

  #[Test]
  public function search_for() {
    $this->beginAt('/');
    $form= $this->getForm();
    $form->getField('q')->setValue('XP Framework');
    $form->submit();
    $this->assertStatus(200);
    $this->assertTitleEquals('Search · XP Framework · GitHub');
  }
}
```

See also
--------

[](#see-also)

[xp-framework/rfc#169](https://github.com/xp-framework/rfc/issues/169)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~343 days

Recently: every ~568 days

Total

8

Last Release

1583d ago

Major Versions

v6.6.0 → v7.0.02020-04-05

PHP version history (4 changes)v6.4.2PHP &gt;=5.4.0

v6.5.0PHP &gt;=5.5.0

v6.6.0PHP &gt;=5.6.0

v7.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (68 commits)")

---

Tags

unittestxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-framework-webtest/health.svg)

```
[![Health](https://phpackages.com/badges/xp-framework-webtest/health.svg)](https://phpackages.com/packages/xp-framework-webtest)
```

###  Alternatives

[xp-framework/compiler

XP Compiler

1926.8k10](/packages/xp-framework-compiler)

PHPackages © 2026

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