FrozenParameterBagTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 PHPUnit\Framework\TestCase;
  12. use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
  13. class FrozenParameterBagTest extends TestCase
  14. {
  15. public function testConstructor()
  16. {
  17. $parameters = array(
  18. 'foo' => 'foo',
  19. 'bar' => 'bar',
  20. );
  21. $bag = new FrozenParameterBag($parameters);
  22. $this->assertEquals($parameters, $bag->all(), '__construct() takes an array of parameters as its first argument');
  23. }
  24. /**
  25. * @expectedException \LogicException
  26. */
  27. public function testClear()
  28. {
  29. $bag = new FrozenParameterBag(array());
  30. $bag->clear();
  31. }
  32. /**
  33. * @expectedException \LogicException
  34. */
  35. public function testSet()
  36. {
  37. $bag = new FrozenParameterBag(array());
  38. $bag->set('foo', 'bar');
  39. }
  40. /**
  41. * @expectedException \LogicException
  42. */
  43. public function testAdd()
  44. {
  45. $bag = new FrozenParameterBag(array());
  46. $bag->add(array());
  47. }
  48. /**
  49. * @expectedException \LogicException
  50. */
  51. public function testRemove()
  52. {
  53. $bag = new FrozenParameterBag(array('foo' => 'bar'));
  54. $bag->remove('foo');
  55. }
  56. }