PHPackages                             spyl/cool-contexts - 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. spyl/cool-contexts

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

spyl/cool-contexts
==================

Some cool contexts for Behat

5305PHP

Since Jun 9Pushed 10y agoCompare

[ Source](https://github.com/spyl94/CoolContexts)[ Packagist](https://packagist.org/packages/spyl/cool-contexts)[ RSS](/packages/spyl-cool-contexts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Since I use these contexts in every projects, I thought it would be nice to have them in a separate repo...

Here they are : **CoolContexts** !

They are highly coupled to my projects, but you can find some inspiration there. Be nice with them and create cool things ;-)

Quick start
-----------

[](#quick-start)

Install CoolContexts with composer:

```
composer require spyl/cool-contexts

```

Contexts
--------

[](#contexts)

- DefaultContext : some helpers methods in addition to KernelAwareContext
- DoctrineFixturesContext : load your fixtures before suite and after each @database tags
- [WebApiContext](https://github.com/spyl94/CoolContexts/blob/master/src/Spyl/CoolContexts/WebApiContext.php) : useful steps to test your (REST) APIs
- [CommandContext](https://github.com/spyl94/CoolContexts/blob/master/src/Spyl/CoolContexts/CommandContext.php) : useful steps to test your commands ;)

Configuration
-------------

[](#configuration)

Edit behat.yml

```
default:
    # ...
    suites:
        api:
            # ...
            contexts:
                - Spyl\CoolContexts\WebApiContext
                - # ...
        commands:
            # ...
            contexts:
                - Spyl\CoolContexts\CommandContext
```

Examples
--------

[](#examples)

```
# features/api/login.features

Feature: Login Restful Api
  As an API client
  I want to be able to login
  So I can access the application

Scenario: Anonymous API client wants to login
    Given I send a POST request to "/login_check" with body:
"""
{
  "username": "user",
  "password": "userpass"
}
"""
    Then the JSON response should match:
"""
{
    "token": @string@,
    "user": {
      "username": "user"
    }
}
"""
```

```
# features/commands/instances.feature

@database
Scenario: Anonymous user wants to create an instance coucou.fr
    Given I run "instance:create coucou coucou.fr"
    Then the command exit code should be 0
    And I should see "Instance coucou has been created !"
```

Information
-----------

[](#information)

If you need to add custom steps, you can easily extends them, feel free to send me a PR if you think your changes could be useful to everyone !

Build with love by **@spyl94**.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/551e75d2574e8ef80b119a0a0085ac495a3803853e4f85f839bc2c8a6610b818?d=identicon)[spyl94](/maintainers/spyl94)

---

Top Contributors

[![spyl94](https://avatars.githubusercontent.com/u/933437?v=4)](https://github.com/spyl94 "spyl94 (5 commits)")

### Embed Badge

![Health badge](/badges/spyl-cool-contexts/health.svg)

```
[![Health](https://phpackages.com/badges/spyl-cool-contexts/health.svg)](https://phpackages.com/packages/spyl-cool-contexts)
```

###  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)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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