/
TestServiceContainerTest.php
47 lines (40 loc) · 2.25 KB
/
TestServiceContainerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Symfony\Bundle\FrameworkBundle\Test\TestContainer;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer\NonPublicService;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer\PrivateService;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer\PublicService;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer\UnusedPrivateService;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TestServiceContainerTest extends WebTestCase
{
public function testThatPrivateServicesAreUnavailableIfTestConfigIsDisabled()
{
static::bootKernel(array('test_case' => 'TestServiceContainer', 'root_config' => 'test_disabled.yml', 'environment' => 'test_disabled'));
$this->assertInstanceOf(ContainerInterface::class, static::$container);
$this->assertNotInstanceOf(TestContainer::class, static::$container);
$this->assertTrue(static::$container->has(PublicService::class));
$this->assertFalse(static::$container->has(NonPublicService::class));
$this->assertFalse(static::$container->has(PrivateService::class));
$this->assertFalse(static::$container->has('private_service'));
$this->assertFalse(static::$container->has(UnusedPrivateService::class));
}
public function testThatPrivateServicesAreAvailableIfTestConfigIsEnabled()
{
static::bootKernel(array('test_case' => 'TestServiceContainer'));
$this->assertInstanceOf(TestContainer::class, static::$container);
$this->assertTrue(static::$container->has(PublicService::class));
$this->assertTrue(static::$container->has(NonPublicService::class));
$this->assertTrue(static::$container->has(PrivateService::class));
$this->assertTrue(static::$container->has('private_service'));
$this->assertTrue(static::$container->has(UnusedPrivateService::class));
}
}