Skip to content

Commit a6bb0cf

Browse files
author
Florian Eckerstorfer
committed
Merge pull request #9 from braincrafted/typehint-fix
Typehint fix
2 parents 15f1ac9 + 32d8b7d commit a6bb0cf

3 files changed

Lines changed: 46 additions & 20 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ vendor/
22
composer.lock
33
*.sublime-project
44
*.sublime-workspace
5+
.idea/

README.md

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
BraincraftedTestingBundle
22
=========================
33

4-
Handcrafted in Vienna by [Florian Eckerstorfer](http://braincrafted.com).
4+
Handcrafted in Vienna by [Florian Eckerstorfer](https://florian.ec).
55

66

77
About
88
-----
99

10-
This bundle currently provides an abstract class to better isolate functional tests of Symfony2 applications. The `WebTestCase` class drops the schema, recreates it and loads all fixture files. Currently [DoctrineFixturesBundle](https://github.com/doctrine/DoctrineFixturesBundle) is a required dependency of this bundle.
10+
This bundle currently provides an abstract class to better isolate functional tests of Symfony2 applications. The
11+
`WebTestCase` class drops the schema, recreates it and loads all fixture files. Currently
12+
[DoctrineFixturesBundle](https://github.com/doctrine/DoctrineFixturesBundle) is a required dependency of this bundle.
1113

1214
At some point this bundle may contain other useful classes, services and helpers related to testing.
1315

@@ -20,12 +22,15 @@ You need to add bundle to your `composer.json` file:
2022
```json
2123
{
2224
"require-dev": {
23-
"braincrafted/testing-bundle": "dev-master"
25+
"braincrafted/testing-bundle": "@stable"
2426
}
2527
}
2628
```
2729

28-
The master branch has been updated to be compatible with Symfony 2.3. If you are using Symfony <2.3 you can use the `0.1` branch.
30+
*Tip: You should replace `@stable` with a specific [version](https://github.com/braincrafted/testing-bundle/releases).*
31+
32+
The master branch has been updated to be compatible with Symfony 2.3. If you are using Symfony <2.3 you can use the
33+
`0.1` branch.
2934

3035
```json
3136
{
@@ -35,7 +40,8 @@ The master branch has been updated to be compatible with Symfony 2.3. If you are
3540
}
3641
```
3742

38-
Add the bundle to your kernel (only activate the bundle in the dev and test environment, you don't need to have it activated in the production environment):
43+
Add the bundle to your kernel (only activate the bundle in the dev and test environment, you don't need to have it
44+
activated in the production environment):
3945

4046
```php
4147
// app/AppKernel.php
@@ -72,7 +78,8 @@ class DemoTest extends WebTestCase
7278
}
7379
```
7480

75-
By default `WebTestCase` provides a `setUp()` and a `tearDown()` method that boot respectively shut down the kernel. However, if you have your own `setUp()` and/or `tearDown()` methods in your test case you need to manually do this.
81+
By default `WebTestCase` provides a `setUp()` and a `tearDown()` method that boot respectively shut down the kernel.
82+
However, if you have your own `setUp()` and/or `tearDown()` methods in your test case you need to manually do this.
7683

7784
```php
7885
// AcmeDemoBundle/Tests/DemoTest.php
@@ -112,30 +119,46 @@ $container = $this->getContainer();
112119

113120
### Render Crawler HTML
114121

115-
The `WebTestCase` class also has an nice helper method that returns the HTML code of a crawler. You can use it in all test cases that subclass `Braincrafted\Bundle\TestingBundle\Test\WebTestCase`:
122+
The `WebTestCase` class also has an nice helper method that returns the HTML code of a crawler. You can use it in all
123+
test cases that subclass `Braincrafted\Bundle\TestingBundle\Test\WebTestCase`:
116124

117125
```php
118126
echo $this->renderCrawlerHtml($crawler);
119127
```
120128

121129
### Testing Translation Keys
122130

123-
`BraincraftedTestingBundle` installs an alternative translator that is only activated in the `test` environment. This translator returns the translation key instead of the translated text. That way you can use the translation keys in your functional tests instead of the translated text.
131+
`BraincraftedTestingBundle` installs an alternative translator that is only activated in the `test` environment. This
132+
translator returns the translation key instead of the translated text. That way you can use the translation keys in your
133+
functional tests instead of the translated text.
124134

125135

126-
License
127-
-------
136+
Change Log
137+
----------
138+
139+
### Version 0.3.1 (25 August 2014)
140+
141+
- Fixed type hint for `WebTestCase::createClient()` method
142+
- Pass `$options` to `WebTestCase::createKernel()` in `WebTestCase::createClient()`
128143

129-
### The MIT License (MIT)
130144

131-
Copyright (c) 2012-2013 Florian Eckerstorfer
145+
### Version 0.3 (18 November 2013)
132146

133-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
147+
- Changed namespace to `Braincrafted`.
134148

135-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
136149

137-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
150+
License
151+
-------
152+
153+
### The MIT License (MIT)
154+
155+
Copyright (c) 2012-2014 Florian Eckerstorfer
138156

157+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
158+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
139159

140-
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/braincrafted/testing-bundle/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
160+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
161+
Software.
141162

163+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
164+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Test/WebTestCase.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Braincrafted\Bundle\TestingBundle\Test;
99

1010
use Symfony\Bundle\FrameworkBundle\Console\Application;
11+
use Symfony\Component\BrowserKit\Client;
1112
use Symfony\Component\Console\Input\ArrayInput;
1213
use Symfony\Component\DomCrawler\Crawler;
1314

@@ -23,7 +24,7 @@
2324
*/
2425
abstract class WebTestCase extends \PHPUnit_Framework_TestCase
2526
{
26-
/** @var \AppKernel */
27+
/** @var \Symfony\Component\HttpKernel\Kernel */
2728
protected $kernel;
2829

2930
/** @var Application */
@@ -84,15 +85,16 @@ protected function tearDownKernel()
8485
/**
8586
* Creates an AppKernel.
8687
*
87-
* @param array $options The array with options for the kernel.
88+
* @param array $options The array with options for the kernel.
8889
*
89-
* @return \AppKernel The app kernel
90+
* @return \Symfony\Component\HttpKernel\Kernel The app kernel
9091
*/
9192
protected function createKernel(array $options = array())
9293
{
9394
if (!class_exists('\AppKernel')) {
9495
require_once $_SERVER['KERNEL_DIR'].'/AppKernel.php';
9596
}
97+
9698
return new \AppKernel(
9799
isset($options['environment']) ? $options['environment'] : 'test',
98100
isset($options['debug']) ? $options['debug'] : true
@@ -110,7 +112,7 @@ protected function createKernel(array $options = array())
110112
protected function createClient(array $options = array(), array $server = array())
111113
{
112114
if (null === $this->kernel) {
113-
$this->setUpKernel();
115+
$this->setUpKernel($options);
114116
}
115117

116118
$client = $this->getContainer()->get('test.client');

0 commit comments

Comments
 (0)