ServicesResetterTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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([
  25. 'id1' => new ResettableService(),
  26. 'id2' => new ClearableService(),
  27. ]), [
  28. 'id1' => 'reset',
  29. 'id2' => 'clear',
  30. ]);
  31. $resetter->reset();
  32. $this->assertEquals(1, ResettableService::$counter);
  33. $this->assertEquals(1, ClearableService::$counter);
  34. }
  35. }