public function StopwatchTest::testSection

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/StopwatchTest.php, line 67

Class

StopwatchTest
StopwatchTest

Namespace

Symfony\Component\HttpKernel\Tests\Debug

Code

public function testSection() {
  $stopwatch = new Stopwatch();
  $stopwatch
    ->openSection();
  $stopwatch
    ->start('foo', 'cat');
  $stopwatch
    ->stop('foo');
  $stopwatch
    ->start('bar', 'cat');
  $stopwatch
    ->stop('bar');
  $stopwatch
    ->stopSection('1');
  $stopwatch
    ->openSection();
  $stopwatch
    ->start('foobar', 'cat');
  $stopwatch
    ->stop('foobar');
  $stopwatch
    ->stopSection('2');
  $stopwatch
    ->openSection();
  $stopwatch
    ->start('foobar', 'cat');
  $stopwatch
    ->stop('foobar');
  $stopwatch
    ->stopSection('0');

  // the section is an event by itself
  $this
    ->assertCount(3, $stopwatch
    ->getSectionEvents('1'));
  $this
    ->assertCount(2, $stopwatch
    ->getSectionEvents('2'));
  $this
    ->assertCount(2, $stopwatch
    ->getSectionEvents('0'));
}