FrozenParameterBagTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Tests\ParameterBag;
  11. use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
  12. class FrozenParameterBagTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @covers Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag::__construct
  16. */
  17. public function testConstructor()
  18. {
  19. $parameters = array(
  20. 'foo' => 'foo',
  21. 'bar' => 'bar',
  22. );
  23. $bag = new FrozenParameterBag($parameters);
  24. $this->assertEquals($parameters, $bag->all(), '__construct() takes an array of parameters as its first argument');
  25. }
  26. /**
  27. * @covers Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag::clear
  28. * @expectedException \LogicException
  29. */
  30. public function testClear()
  31. {
  32. $bag = new FrozenParameterBag(array());
  33. $bag->clear();
  34. }
  35. /**
  36. * @covers Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag::set
  37. * @expectedException \LogicException
  38. */
  39. public function testSet()
  40. {
  41. $bag = new FrozenParameterBag(array());
  42. $bag->set('foo', 'bar');
  43. }
  44. /**
  45. * @covers Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag::add
  46. * @expectedException \LogicException
  47. */
  48. public function testAdd()
  49. {
  50. $bag = new FrozenParameterBag(array());
  51. $bag->add(array());
  52. }
  53. }