ServicesResetterTest.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\HttpKernel\Tests\DependencyInjection;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
  13. use Symfony\Component\HttpKernel\Tests\Fixtures\ClearableService;
  14. use Symfony\Component\HttpKernel\Tests\Fixtures\ResettableService;
  15. class ServicesResetterTest extends TestCase
  16. {
  17. protected function setUp()
  18. {
  19. ResettableService::$counter = 0;
  20. ClearableService::$counter = 0;
  21. }
  22. public function testResetServices()
  23. {
  24. $resetter = new ServicesResetter(new \ArrayIterator(array(
  25. 'id1' => new ResettableService(),
  26. 'id2' => new ClearableService(),
  27. )), array(
  28. 'id1' => 'reset',
  29. 'id2' => 'clear',
  30. ));
  31. $resetter->reset();
  32. $this->assertEquals(1, ResettableService::$counter);
  33. $this->assertEquals(1, ClearableService::$counter);
  34. }
  35. }