Example repository that shows how to use a mock API server with Codeception acceptance tests.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.gitignore
README.md
codeception.yml
composer.json
composer.lock
config.php-example
index.php

README.md

Example: Codeception with Mock HTTP server

This repository contains the sample code used in my blog post Mock API requests in Codeception Acceptance tests.

Installation

  1. Clone this repository and go the directory:

    git clone https://github.com/stevenrombauts/example-codeception-mock-server.git
    cd example-codeception-mock-server
  2. Run Composer install to fetch the dependencies:

    composer install
  3. Copy config.php-example to config.php:

    cp config.php-example config.php
  4. Start PHP's standalone webserver:

    php -S localhost:8080
  5. Browse to http://localhost:8080 to see it in action.

Running the tests

  1. Change the API_URL in config.php to point to the mock HTTP server:

    <?php
    return [
    	'API_URL' => 'http://localhost:8001/wp-json/posts'
    ];
  2. Run Codeception:

    codecept run acceptance --steps