Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1a96372

Browse filesBrowse files
srozenicolas-grekas
authored andcommitted
Add tests on the ContainerBag
1 parent 0e18d3e commit 1a96372
Copy full SHA for 1a96372

File tree

1 file changed

+65
-0
lines changed
Filter options

1 file changed

+65
-0
lines changed
+65Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Psr\Container\ContainerInterface;
16+
use Symfony\Component\DependencyInjection\Container;
17+
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
18+
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
19+
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
20+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
21+
22+
class ContainerBagTest extends TestCase
23+
{
24+
/** @var ParameterBag */
25+
private $parameterBag;
26+
/** @var ContainerBag */
27+
private $containerBag;
28+
29+
public function setUp()
30+
{
31+
$this->parameterBag = new ParameterBag(array('foo' => 'value'));
32+
$this->containerBag = new ContainerBag(new Container($this->parameterBag));
33+
}
34+
35+
public function testGetAllParameters()
36+
{
37+
$this->assertEquals(array('foo' => 'value'), $this->containerBag->all());
38+
}
39+
40+
public function testHasAParameter()
41+
{
42+
$this->assertTrue($this->containerBag->has('foo'));
43+
$this->assertFalse($this->containerBag->has('bar'));
44+
}
45+
46+
public function testGetParameter()
47+
{
48+
$this->assertEquals('value', $this->containerBag->get('foo'));
49+
}
50+
51+
/**
52+
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
53+
*/
54+
public function testGetParameterNotFound()
55+
{
56+
$this->containerBag->get('bar');
57+
}
58+
59+
public function testInstanceOf()
60+
{
61+
$this->assertInstanceOf(FrozenParameterBag::class, $this->containerBag);
62+
$this->assertInstanceOf(ContainerBagInterface::class, $this->containerBag);
63+
$this->assertInstanceOf(ContainerInterface::class, $this->containerBag);
64+
}
65+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.