Skip to content

Installation and Setup

Jeffrey Way edited this page Apr 25, 2015 · 2 revisions

Step 1: Composer

Integrated may be installed through Composer.

composer require laracasts/integrated --dev

Step 2: Extend

Integrated comes with four extensions out of the box:

  1. Goutte
  2. Selenium
  3. Laravel
  4. Lumen

The API you will use is identical, regardless of the extension (excluding some extras for Selenium). You only need to extend the appropriate class, and you're good to go.

Goutte

Simply create a PHPUnit test class, and extend Laracasts\Integrated\Extensions\Goutte.

<?php // tests/ExampleTest.php

use Laracasts\Integrated\Extensions\Goutte as IntegrationTest;

class ExampleTest extends IntegrationTest {}

You'll also need to set a baseUrl for your application. By default, it is set to "http://localhost:8888", however, you'll likely need to change this. Do so by either adding a $baseUrl to your test class.

class ExampleTest extends IntegrationTest {
    protected $baseUrl = 'http://localhost:1234';
}

Or by creating a configuration file for this package, integrated.json in the root of your application, like so:

{
    "baseUrl": "http://localhost:1234"
}

Laravel

If you build Laravel applications, a server needn't be running. This comes with the benefit of very fast tests! Have Laravel's default tests/TestCase.php class extend Laracasts\Integrated\Extensions\Laravel, like so:

<?php // tests/TestCase.php

use Laracasts\Integrated\Extensions\Laravel as IntegrationTest;

class TestCase extends IntegrationTest {
    // ...
}

Lumen

Lumen is virtually identical to the Laravel extension. The only difference is that, rather than extending Laracasts\Integrated\Extensions\Laravel, instead extend Laracasts\Integrated\Extensions\Lumen from your TestCase class. That's it!

Selenium

When using the Selenium extension, a physical browser (defaulting to Firefox) will open and interact with your application, according to the tests you've written.

Because these tests use a browser, you only need to extend the Selenium class from any test file. Here's an example:

<?php // tests/ExampleTest.php

use Laracasts\Integrated\Extensions\Selenium as IntegrationTest;

class ExampleTest extends IntegrationTest {
    // ...
}

You'll also need to set a baseUrl for your application. By default, it is set to "http://localhost:8888", however, you'll likely need to change this. Do so by either adding a $baseUrl to your test class.

class ExampleTest extends IntegrationTest {
    protected $baseUrl = 'http://localhost:1234';
}

Or by creating a configuration file for this package, integrated.json in the root of your application, like so:

{
    "baseUrl": "http://localhost:1234"
}

Note: Don't forget to install Selenium Stand-Alone server for your OS, and start it up. If you wish, you may download it to your current project, and then run:

java -jar selenium-server-standalone-2.45.0.jar

You could always save this to an alias, so that you can simply type selenium.

That should do it!

Clone this wiki locally