Skip to content

Instantly share code, notes, and snippets.

@gzankevich
Created May 15, 2012 08:59
Show Gist options
  • Save gzankevich/2700199 to your computer and use it in GitHub Desktop.
Save gzankevich/2700199 to your computer and use it in GitHub Desktop.
Basic Symfony2/Selenium2 Setup
<?php
// src/Acme/DemoBundle/Tests/Selenium/DemoTest.php
namespace Acme\DemoBundle\Tests\Selenium;
use Acme\DemoBundle\Tests\SeleniumTestCase;
class DemoTest extends SeleniumTestCase
{
public function testTitle()
{
$this->url('http://www.example.com/app_dev.php');
$this->assertEquals('Test', $this->title());
}
}
<!-- app/selenium.xml.dist -->
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "bootstrap.php.cache" >
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests/Selenium</directory>
<directory>../src/*/Bundle/*Bundle/Tests/Selenium</directory>
</testsuite>
</testsuites>
<!--
<php>
<server name="KERNEL_DIR" value="/path/to/your/app/" />
</php>
-->
<filter>
<whitelist>
<directory>../src</directory>
<exclude>
<directory>../src/*/*Bundle/Resources</directory>
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Resources</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
<?php
// src/Acme/DemoBundle/Tests/SeleniumTestCase.php
namespace Acme\DemoBundle\Tests;
abstract class SeleniumTestCase extends \PHPUnit_Extensions_Selenium2TestCase
{
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://www.example.com/app_dev.php');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment