PHPackages                             ink/haphazard - 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. ink/haphazard

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

ink/haphazard
=============

Library for quick and dirty page functional testing

v2.2.0(11y ago)15502[1 issues](https://github.com/InkApplications/haphazard/issues)MITPHPPHP &gt;=5.3.0

Since Sep 28Pushed 11y ago1 watchersCompare

[ Source](https://github.com/InkApplications/haphazard)[ Packagist](https://packagist.org/packages/ink/haphazard)[ RSS](/packages/ink-haphazard/feed)WikiDiscussions master Synced 3d ago

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

Haphazard
=========

[](#haphazard)

Haphazard is a library extension to Symfony's WebTestCase that provides a quick and dirty method to functional test basic pages.

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

[](#installation)

You can install Haphazard through composer:

```
composer.phar require ink/haphazard

```

Usage
-----

[](#usage)

### Simple page load test

[](#simple-page-load-test)

When all you want to test is that the page at *least* loads properly, you can use the `HaphazardTestCase::assertGet()` or `HaphazardTestCase::assertPost()`methods. This will create a web client and assert that a response code of 200 is returned for the page.

```
use Ink\Haphazard\TestCase\HaphazardTestCase;

class ProductControllerTest extends HaphazardTestCase
{
    /**
     * Test Index Action
     */
    public function testIndexAction()
    {
        $this->assertGet('index');
    }

    /**
     * Test Post Action
     */
     public function testCreatePostAction()
     {
         $this->assertPost('create');
     }
}

```

### Page with parameters

[](#page-with-parameters)

If the page you're testing requires parameters, you can pass those in as well.

```
/**
 * Test View Action
 */
public function testViewAction()
{
    $this->assertGet('product-view', ['productId' => 1]);
}

/**
 * Test Edit Action
 */
 public function testEditAction()
 {
     $this->assertPost('product-edit', ['productId' => 1]);
 }

```

### Page with a Post body

[](#page-with-a-post-body)

If you need to send additional parameters along with your POST request, you can send them along.

```
/**
 * Test Edit Action
 */
 public function testEditAction()
 {
     $this->assertPost('product-edit', ['productId' => 1], ['product-name' => 'Acme Product']);
 }

```

### Different Status codes

[](#different-status-codes)

Occasionally you will want to test that pages return a different status code, for example a 403 / Forbidden status code when an anonymous user should *not*be able to access a given page, or a 302 when the page redirects.

```
/**
 * Test Edit Action
 */
public function testEditAction()
{
    $this->assertGet('product-edit', ['productId' => 1], 403);
}

/**
 * Test Edit Action
 */
 public function testEditAction()
 {
     $this->assertPost('product-edit', ['productId' => 1], ['product-name' => 'Acme Product'], 302);
 }

```

### Spoof Authentication Role

[](#spoof-authentication-role)

In order to effectively test that pages are open / closed to the correct users, this library provides an easy way to make assertions using a specified role.

```
/**
 * Test Edit Action
 */
public function testEditAction()
{
    // Allow our Admin role
    $user = new User();
    $this->login($user);
    $this->assertGet('product-edit', ['productId' => 1], 200);

    // Disallow Anonymous users
    $this->refreshClient();
    $this->assertGet('product-edit', ['productId' => 1], 403);
}

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 85% 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 ~27 days

Recently: every ~37 days

Total

11

Last Release

4341d ago

Major Versions

v1.0.5 → v2.0.02013-12-02

### Community

Maintainers

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

---

Top Contributors

[![ReneeVandervelde](https://avatars.githubusercontent.com/u/400318?v=4)](https://github.com/ReneeVandervelde "ReneeVandervelde (17 commits)")[![natebrunette](https://avatars.githubusercontent.com/u/1831497?v=4)](https://github.com/natebrunette "natebrunette (3 commits)")

### Embed Badge

![Health badge](/badges/ink-haphazard/health.svg)

```
[![Health](https://phpackages.com/badges/ink-haphazard/health.svg)](https://phpackages.com/packages/ink-haphazard)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

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

Official version of pdepend to be handled with Composer

954110.9M815](/packages/pdepend-pdepend)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3257.8M898](/packages/szepeviktor-phpstan-wordpress)[codeception/module-asserts

Codeception module containing various assertions

8550.6M1.2k](/packages/codeception-module-asserts)

PHPackages © 2026

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