-
Notifications
You must be signed in to change notification settings - Fork 87
Installation and Setup
Integrated may be installed through Composer.
composer require laracasts/integrated --dev
Integrated comes with three extensions out of the box:
- Goutte
- Selenium
- Laravel
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.
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"
}
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 {
// ...
}
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!