phpunit/phpunit-mink-trait

Trait that provides minimal integration layer for using Mink in PHPUnit test cases

2.0.0 2017-10-12 05:58 UTC

README

Trait that provides a minimal integration layer for using Mink (with the Goutte driver) in PHPUnit test cases.

The main goal of this project is to demonstrate how PHPUnit can be extended through traits.

Installation

You can add this library as a local, per-project dependency to your project using Composer:

composer require phpunit/phpunit-mink-trait

If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:

composer require --dev phpunit/phpunit-mink-trait

Usage

<?php
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
    use phpunit\mink\TestCaseTrait;

    public function testHasCorrectTitle()
    {
        $page = $this->visit('http://example.com/');

        $this->assertContains(
            'Example Domain', $page->find('css', 'title')->getHtml()
        );
    }

    public function testMoreInformationCanBeAccessed()
    {
        $page = $this->visit('http://example.com/');
        $page->clickLink('More information...');

        $this->assertContains(
            'IANA', $page->find('css', 'title')->getHtml()
        );
    }
}