Wallogit.com
2017 © Pedro Peláez
Allows the use of Mink inside Kahlan
🌍 Provides functionality to work with Mink within Kahlan. Also provides a way to boot a PHP web server when tests run., (*2)
Inspired and based on this: http://radify.io/blog/end-to-end-functional-testing-with-kahan/ - many thanks to Simon JAILLET for not only Kahlan, but the blog post on end to end testing in Kahlan., (*3)
composer require brunty/kahlan-mink --dev, (*4)
Once required, setup your configuration file kahlan-config.php to register mink with Kahlan (making sure to pass through $this to the method):, (*5)
<?php // kahlan-config.php \Brunty\Kahlan\Mink\Mink::register($this);
If you want to start a PHP server when your tests start and stop it when test execution finishes then register the PhpServer with Kahlan as well:, (*6)
<?php // kahlan-config.php \Brunty\Kahlan\Mink\PhpServer::register($this);
If you want to use the url() helper function, register a base URL in your config file under the brunty.kahlan-mink.base-url key. All URLs via the url() function will be appended to this., (*7)
<?php
\Kahlan\box('brunty.kahlan-mink.base-url', 'http://localhost:8888');
Based on the above, calling url('my-page') will return http://localhost:8888/my-page, (*8)
Once that's done, you can use the functions to access things via Mink:, (*9)
\Brunty\Kahlan\Mink\browser(string $sessionName = 'default'): Session returns the instance of Mink inside our test suite.\Brunty\Kahlan\Mink\page($sessionName = 'default'): DocumentElement returns the page we're currently accessing.\Brunty\Kahlan\Mink\element($locator = 'body', Element $parent = null): Element find an element on the page we're browsing.<?php // spec/MySiteSpec.php
use function Brunty\Kahlan\Mink\browser;
use function Brunty\Kahlan\Mink\element;
describe('My website', function () {
it('accesses the site', function () {
browser()->visit('http://localhost:8888/my-page');
expect(element('#content p')->getText())->toContain('Hello world!');
});
});
This started as a small personal project., (*10)
Although this project is small, openness and inclusivity are taken seriously. To that end a code of conduct (listed in the contributing guide) has been adopted., (*11)
Contributor Guide, (*12)