Skip to content

Commit 49a41ff

Browse files
lsmith77wouterj
authored andcommitted
make it possible to use an existing client when creating the container
Conflicts: src/Functional/BaseTestCase.php
1 parent b367c91 commit 49a41ff

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/Functional/BaseTestCase.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
namespace Symfony\Cmf\Component\Testing\Functional;
1414

1515
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
16+
use Symfony\Bundle\FrameworkBundle\Client;
17+
use Symfony\Component\HttpFoundation\Response;
1618
use Symfony\Component\DependencyInjection\Container;
1719

1820
/**
@@ -24,17 +26,22 @@
2426
abstract class BaseTestCase extends WebTestCase
2527
{
2628
/**
27-
* Use this property to save the DbManager.
29+
* Use this property to save the DbManagers
30+
*
31+
* @var array
2832
*/
29-
protected $db;
30-
3133
protected $dbManagers = array();
3234

3335
/**
3436
* @var Container
3537
*/
3638
protected $container;
3739

40+
/**
41+
* @var Client
42+
*/
43+
protected $client;
44+
3845
/**
3946
* Return the configuration to use when creating the Kernel.
4047
*
@@ -50,6 +57,20 @@ protected function getKernelConfiguration()
5057
return array();
5158
}
5259

60+
/**
61+
* Gets the Client.
62+
*
63+
* @return Client
64+
*/
65+
public function getClient()
66+
{
67+
if (null === $this->client) {
68+
$this->client = $this->createClient($this->getKernelConfiguration());
69+
}
70+
71+
return $this->client;
72+
}
73+
5374
/**
5475
* Gets the container.
5576
*
@@ -58,8 +79,7 @@ protected function getKernelConfiguration()
5879
public function getContainer()
5980
{
6081
if (null === $this->container) {
61-
$client = $this->createClient($this->getKernelConfiguration());
62-
$this->container = $client->getContainer();
82+
$this->container = $this->getClient()->getContainer();
6383
}
6484

6585
return $this->container;
@@ -104,7 +124,7 @@ public function getDbManager($type)
104124

105125
$this->dbManagers[$type] = $dbManager;
106126

107-
return $this->getDbManager($type);
127+
return $dbManager;
108128
}
109129

110130
/**

0 commit comments

Comments
 (0)