Skip to content

Commit b0b2571

Browse files
committed
Merge pull request #109 from symfony-cmf/fix_container_creation
make it possible to use an existing client when creating the container
2 parents 3d8dbe5 + 2b76a5c commit b0b2571

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/Functional/BaseTestCase.php

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

1515
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
16+
use Symfony\Bundle\FrameworkBundle\Client;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\DependencyInjection\Container;
1819

@@ -25,17 +26,22 @@
2526
abstract class BaseTestCase extends WebTestCase
2627
{
2728
/**
28-
* Use this property to save the DbManager.
29+
* Use this property to save the DbManagers
30+
*
31+
* @var array
2932
*/
30-
protected $db;
31-
3233
protected $dbManagers = array();
3334

3435
/**
3536
* @var Container
3637
*/
3738
protected $container;
3839

40+
/**
41+
* @var Client
42+
*/
43+
protected $client;
44+
3945
/**
4046
* Return the configuration to use when creating the Kernel.
4147
*
@@ -51,6 +57,20 @@ protected function getKernelConfiguration()
5157
return array();
5258
}
5359

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+
5474
/**
5575
* Gets the container.
5676
*
@@ -59,8 +79,7 @@ protected function getKernelConfiguration()
5979
public function getContainer()
6080
{
6181
if (null === $this->container) {
62-
$client = $this->createClient($this->getKernelConfiguration());
63-
$this->container = $client->getContainer();
82+
$this->container = $this->getClient()->getContainer();
6483
}
6584

6685
return $this->container;
@@ -105,7 +124,7 @@ public function getDbManager($type)
105124

106125
$this->dbManagers[$type] = $dbManager;
107126

108-
return $this->getDbManager($type);
127+
return $dbManager;
109128
}
110129

111130
/**

0 commit comments

Comments
 (0)