Skip to content

Commit 0f60c2b

Browse files
cedriczieldunglas
authored andcommitted
Mention composition to integrate with existing test tools (symfony#94)
* Mention composition to integrate with existing test tools * also fix some wordings * Remove "internal" tag from PantherTestCaseTrait * Update README.md
1 parent 029b431 commit 0f60c2b

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

README.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88

99
*Panther* is a convenient standalone library to scrape websites and to run end-to-end tests **using real browsers**.
1010

11-
Panther is super powerful, it leverages [the W3C's WebDriver protocol](https://www.w3.org/TR/webdriver/) to drive native web browsers such as Google Chrome and Firefox.
11+
Panther is super powerful. It leverages [the W3C's WebDriver protocol](https://www.w3.org/TR/webdriver/) to drive native web browsers such as Google Chrome and Firefox.
1212

13-
Panther is very easy to use, because it implements the popular Symfony's [BrowserKit](https://symfony.com/doc/current/components/browser_kit.html) and
13+
Panther is very easy to use, because it implements Symfony's popular [BrowserKit](https://symfony.com/doc/current/components/browser_kit.html) and
1414
[DomCrawler](https://symfony.com/doc/current/components/dom_crawler.html) APIs, and contains
1515
all features you need to test your apps. It will sound familiar if you have ever created [a functional test for a Symfony app](https://symfony.com/doc/current/testing.html#functional-tests):
1616
as the API is exactly the same!
17-
Keep in mind that Panther can be used in every PHP project, it's a standalone library.
17+
Keep in mind that Panther can be used in every PHP project, as it is a standalone library.
1818

1919
Panther automatically finds your local installation of Chrome and launches it (thanks to [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)),
20-
so you don't need to install anything on your computer, neither Selenium server nor obscure driver.
20+
so you don't need to install anything on your computer, neither Selenium server nor any other obscure driver.
2121

2222
In test mode, Panther automatically starts your application using [the PHP built-in web-server](http://php.net/manual/en/features.commandline.webserver.php).
23-
You can just focus on writing your tests or web-scraping scenario, Panther takes care of everything else.
23+
You can focus on writing your tests or web-scraping scenario and Panther will take care of everything else.
2424

2525
## Install
2626

27-
Use [Composer](https://getcomposer.org/) to install Panther in your project. You may want to use the --dev flag if you want to use Panther for testing only and not for web scraping:
27+
Use [Composer](https://getcomposer.org/) to install Panther in your project. You may want to use the --dev flag if you want to use Panther for testing only and not for web scraping in a production environment:
2828

2929
composer req symfony/panther
3030

@@ -59,6 +59,8 @@ It extends [PHPUnit](https://phpunit.de/)'s `TestCase` and provide all testing t
5959
```php
6060
<?php
6161

62+
namespace App\Tests;
63+
6264
use Symfony\Component\Panther\PantherTestCase;
6365

6466
class E2eTest extends PantherTestCase
@@ -96,6 +98,8 @@ to authenticate to an external SSO server, do I want to access the kernel of the
9698
```php
9799
<?php
98100

101+
namespace App\Tests;
102+
99103
use Symfony\Component\Panther\PantherTestCase;
100104
use Symfony\Component\Panther\Client;
101105

@@ -116,21 +120,48 @@ class E2eTest extends PantherTestCase
116120
// enjoy the same API for the 3 felines
117121
// $*client->request('GET', '...')
118122

119-
$kernel = static::createKernel(); // You can also access to the app's kernel
123+
$kernel = static::createKernel(); // You have also access to the app's kernel
120124

121125
// ...
122126
}
123127
}
124128
```
125129

130+
### Usage with Other Testing Tools
131+
132+
If you want to use Panther with other testing tools like [LiipFunctionalTestBundle](https://github.com/liip/LiipFunctionalTestBundle) or if you just need to use a different base class, Panther has got you covered. It provides you with the `Symfony\Component\Panther\PantherTestCaseTrait` and you can use it to enhance your existing test-infrastructure with some Panther awesomeness:
133+
134+
```php
135+
<?php
136+
137+
namespace App\Tests\Controller;
138+
139+
use Liip\FunctionalTestBundle\Test\WebTestCase;
140+
use Symfony\Component\HttpFoundation\Response;
141+
use Symfony\Component\Panther\PantherTestCaseTrait;
142+
143+
class DefaultControllerTest extends WebTestCase
144+
{
145+
use PantherTestCaseTrait; // this is the magic. Panther is now available.
146+
147+
public function testWithFixtures()
148+
{
149+
$this->loadFixtures([]); // load your fixtures
150+
$client = self::createPantherClient(); // create your panther client
151+
152+
$client->request('GET', '/');
153+
}
154+
}
155+
```
156+
126157
## Features
127158

128159
Unlike testing and web scraping libraries you're used to, Panther:
129160

130161
* executes the JavaScript code contained in webpages
131162
* supports everything that Chrome (or Firefox) implements
132163
* allows screenshots taking
133-
* can wait for the appearance of elements loaded asynchronously
164+
* can wait for the appearance of asynchronously loaded elements
134165
* lets you run your own JS code or XPath queries in the context of the loaded page
135166
* supports custom [Selenium server](https://www.seleniumhq.org) installations
136167
* supports remote browser testing services including [SauceLabs](https://saucelabs.com/) and [BrowserStack](https://www.browserstack.com/)

src/PantherTestCaseTrait.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
/**
2222
* Eases conditional class definition.
2323
*
24-
* @internal
25-
*
2624
* @author Kévin Dunglas <[email protected]>
2725
*/
2826
trait PantherTestCaseTrait

0 commit comments

Comments
 (0)