PHPackages                             toast/acceptance - 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. toast/acceptance

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

toast/acceptance
================

Acceptance tests for the Toast test framework

0.4.4(1y ago)0128[2 PRs](https://github.com/toast-php/acceptance/pulls)MITPHPCI failing

Since Jul 10Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/toast-php/acceptance)[ Packagist](https://packagist.org/packages/toast/acceptance)[ RSS](/packages/toast-acceptance/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (4)Versions (18)Used By (0)

Acceptance
==========

[](#acceptance)

Acceptance tests for the Toast test framework

One notch up from integration tests, acceptance tests should test your entire application. That means actually using a web browser for most web applications.

> One could argue that a CLI test is also a form of an acceptance test, with the command line acting as a stand-in for a browser. Semantics, semantics...

Toast is written in PHP which (duh) gets compiled on the server. Websites consist of HTML, CSS and Javascript. Hence, you'll need a headless browser like PhantomJS to run your acceptance tests.

Prerequisites
-------------

[](#prerequisites)

Install the acceptance module:

```
composer require --dev toast/acceptance
```

Acceptance testing requires Chrome or Chromium Headless to be installed.

Preparing your project
----------------------

[](#preparing-your-project)

Your project needs to be made Toast-aware. For regular tests we did that via the `getenv('TOAST')` check; for HTTP calls it is similar. Toast's browser passes this variable as `$_COOKIE['TOAST']`.

In a central place - this can be any place depending on your project, as long as you're 100% sure every called page will run that bit of code - place a check for these headers and make sure your application understands it's running in test mode if they're set.

> So, in test mode, use a mock database etc.

Note: you probably also want to only check this on a development URL - production should of course ignore the `$_COOKIE['TOAST']` variable.

The `TOAST_CLIENT` environment variable is also passed in this manner.

Writing an acceptance test
--------------------------

[](#writing-an-acceptance-test)

To write these tests, we'll make use of the `Toast\Acceptance\Browser` object. This is a wrapper around Headless Chromium PHP with some convenience methods.

```
