PHPackages                             macrominds/website-testing - 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. macrominds/website-testing

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

macrominds/website-testing
==========================

Cross-Platform Helper for functional testing of websites.

v0.1.0(10y ago)031MITPHPPHP ^5.6 || ^7.0

Since Apr 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/macrominds/website-testing)[ Packagist](https://packagist.org/packages/macrominds/website-testing)[ RSS](/packages/macrominds-website-testing/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

Cross-Platform Helper for functional testing of websites.
=========================================================

[](#cross-platform-helper-for-functional-testing-of-websites)

Start built-in php server from php unit test
--------------------------------------------

[](#start-built-in-php-server-from-php-unit-test)

macrominds/website-testing allows you to start the built-in php server directly inside unit tests or other php scripts. Especially useful for functional testing. Helps to reduce external dependencies and to make your project self-contained.

### Usage example

[](#usage-example)

A rough usage overview. See below for a detailed example.

```
$this->testServer = new EmbeddedServerController(HOST,PORT,DOCROOT,'./tests/web/router.php');
$this->testServer->start();
//...
$this->testServer->stopAndWaitForConnectionLoss();
```

See this projects' phpunit.xml to learn how you can define HOST, PORT and DOCROOT for your own project.

### Installing macrominds/website-testing

[](#installing-macromindswebsite-testing)

#### Recommended: Composer

[](#recommended-composer)

The recommended installation way is through [Composer](http://getcomposer.org/).

Run the Composer command to add the latest stable version of macrominds/website-testing to your development dependencies:

```
composer require --dev macrominds/website-testing

```

or add it to the appropriate section of your composer.json:

```
    "require-dev": {
        "macrominds/website-testing": "^0.1.0",
    }
```

#### Without Composer

[](#without-composer)

You may as well use macrominds/website-testing without Composer. Just fetch src/EmbeddedServerController.php and then in your php file

```
require_once('path-to-your/src/EmbeddedServerController.php');
```

There you go. Ready for the detailed example?

### Detailed usage example

[](#detailed-usage-example)

Testing the behavior of your web application. This example uses [Guzzle](https://github.com/guzzle/guzzle) as the HTTP client and phpunit. It requires the usage of Composer.

Your `composer.json` should contain this section:

```
    "require-dev": {
        "phpunit/phpunit": "^5.3",
        "macrominds/website-testing": "^0.1.0",
        "guzzlehttp/guzzle": "^6.2"
    }
```

Make sure to update composer:

```
composer update

```

```
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use macrominds\website\testing\EmbeddedServerController;

class FunctionalPageTest extends \PHPUnit_Framework_TestCase{
    /**
     *
     * @var EmbeddedServerController
     */
    private static $serverController;
    private static $client;

// setup server

    public static function setupBeforeClass()
    {
        //see phpunit.xml for configuration of PORT, DOCROOT, ROUTERSCRIPT
        self::$serverController = new EmbeddedServerController('0.0.0.0',PORT,DOCROOT,ROUTERSCRIPT);
        self::$serverController->start();
        $host = self::$serverController->getHost();
        $port = PORT;
        self::$client = new Client([
            'base_uri' => "http://$host:$port"
        ]);
    }

// tear down server

    public static function tearDownAfterClass()
    {
        if (self::$serverController !== null) {
            self::$serverController->stopAndWaitForConnectionLoss();
        }
        self::$serverController = null;
    }

// arbitrary tests

    /**
     * @test
     */
    public function shouldSendCorrectRedirectHeaders()
    {
        // we expect a temporary redirect
        $this->assertCorrectnessOfRedirectHeader(302);
        // we expect a permanent redirect
        $this->assertCorrectnessOfRedirectHeader(301);
    }

    private function assertCorrectnessOfRedirectHeader($code)
    {
        // our test scenario is setup to answer requests to /301.html
        // or /302.html with the corresponding redirect.
        $response = self::$client->get("/$code.html", [
            RequestOptions::ALLOW_REDIRECTS=>false
        ]);
        $this->assertEquals($code, $response->getStatusCode());
    }
}
```

### Troubleshooting

[](#troubleshooting)

If you've got any issues or feature-requests, just add it to the Issues section.

Running the tests from your project root in the first place could help tracking down any issues related to your system.

```
bin/phpunit -c vendor/macrominds/website-testing/phpunit.xml

```

Have fun.

---

[macrominds – Webdesign and development](http://www.macrominds.de)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Total

3

Last Release

3654d ago

### Community

Maintainers

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

---

Tags

testing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/macrominds-website-testing/health.svg)

```
[![Health](https://phpackages.com/badges/macrominds-website-testing/health.svg)](https://phpackages.com/packages/macrominds-website-testing)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpunit/php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.

8.9k892.4M1.5k](/packages/phpunit-php-code-coverage)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/phpunit-bridge

Provides utilities for PHPUnit, especially user deprecation notices management

2.5k201.2M4.2k](/packages/symfony-phpunit-bridge)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)

PHPackages © 2026

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