ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Tests_Profiler_ProfileTest Class Reference
+ Inheritance diagram for Twig_Tests_Profiler_ProfileTest:
+ Collaboration diagram for Twig_Tests_Profiler_ProfileTest:

Public Member Functions

 testConstructor ()
 
 testIsRoot ()
 
 testIsTemplate ()
 
 testIsBlock ()
 
 testIsMacro ()
 
 testGetAddProfile ()
 
 testGetDuration ()
 
 testSerialize ()
 
 testReset ()
 

Detailed Description

Definition at line 12 of file ProfileTest.php.

Member Function Documentation

◆ testConstructor()

Twig_Tests_Profiler_ProfileTest::testConstructor ( )

Definition at line 14 of file ProfileTest.php.

15  {
16  $profile = new Twig_Profiler_Profile('template', 'type', 'name');
17 
18  $this->assertEquals('template', $profile->getTemplate());
19  $this->assertEquals('type', $profile->getType());
20  $this->assertEquals('name', $profile->getName());
21  }

◆ testGetAddProfile()

Twig_Tests_Profiler_ProfileTest::testGetAddProfile ( )

Definition at line 59 of file ProfileTest.php.

References array.

60  {
61  $profile = new Twig_Profiler_Profile();
62  $profile->addProfile($a = new Twig_Profiler_Profile());
63  $profile->addProfile($b = new Twig_Profiler_Profile());
64 
65  $this->assertSame(array($a, $b), $profile->getProfiles());
66  $this->assertSame(array($a, $b), iterator_to_array($profile));
67  }
Create styles array
The data for the language used.

◆ testGetDuration()

Twig_Tests_Profiler_ProfileTest::testGetDuration ( )

Definition at line 69 of file ProfileTest.php.

70  {
71  $profile = new Twig_Profiler_Profile();
72  usleep(1);
73  $profile->leave();
74 
75  $this->assertTrue($profile->getDuration() > 0, sprintf('Expected duration > 0, got: %f', $profile->getDuration()));
76  }

◆ testIsBlock()

Twig_Tests_Profiler_ProfileTest::testIsBlock ( )

Definition at line 41 of file ProfileTest.php.

References Twig_Profiler_Profile\BLOCK, and Twig_Profiler_Profile\ROOT.

42  {
43  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::BLOCK);
44  $this->assertTrue($profile->isBlock());
45 
46  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
47  $this->assertFalse($profile->isBlock());
48  }

◆ testIsMacro()

Twig_Tests_Profiler_ProfileTest::testIsMacro ( )

Definition at line 50 of file ProfileTest.php.

References Twig_Profiler_Profile\MACRO, and Twig_Profiler_Profile\ROOT.

51  {
52  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::MACRO);
53  $this->assertTrue($profile->isMacro());
54 
55  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
56  $this->assertFalse($profile->isMacro());
57  }

◆ testIsRoot()

Twig_Tests_Profiler_ProfileTest::testIsRoot ( )

Definition at line 23 of file ProfileTest.php.

References Twig_Profiler_Profile\ROOT, and Twig_Profiler_Profile\TEMPLATE.

24  {
25  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
26  $this->assertTrue($profile->isRoot());
27 
28  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::TEMPLATE);
29  $this->assertFalse($profile->isRoot());
30  }

◆ testIsTemplate()

Twig_Tests_Profiler_ProfileTest::testIsTemplate ( )

Definition at line 32 of file ProfileTest.php.

References Twig_Profiler_Profile\ROOT, and Twig_Profiler_Profile\TEMPLATE.

33  {
34  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::TEMPLATE);
35  $this->assertTrue($profile->isTemplate());
36 
37  $profile = new Twig_Profiler_Profile('template', Twig_Profiler_Profile::ROOT);
38  $this->assertFalse($profile->isTemplate());
39  }

◆ testReset()

Twig_Tests_Profiler_ProfileTest::testReset ( )

Definition at line 101 of file ProfileTest.php.

102  {
103  $profile = new Twig_Profiler_Profile();
104  usleep(1);
105  $profile->leave();
106  $profile->reset();
107 
108  $this->assertEquals(0, $profile->getDuration());
109  }

◆ testSerialize()

Twig_Tests_Profiler_ProfileTest::testSerialize ( )

Definition at line 78 of file ProfileTest.php.

79  {
80  $profile = new Twig_Profiler_Profile('template', 'type', 'name');
81  $profile1 = new Twig_Profiler_Profile('template1', 'type1', 'name1');
82  $profile->addProfile($profile1);
83  $profile->leave();
84  $profile1->leave();
85 
86  $profile2 = unserialize(serialize($profile));
87  $profiles = $profile->getProfiles();
88  $this->assertCount(1, $profiles);
89  $profile3 = $profiles[0];
90 
91  $this->assertEquals($profile->getTemplate(), $profile2->getTemplate());
92  $this->assertEquals($profile->getType(), $profile2->getType());
93  $this->assertEquals($profile->getName(), $profile2->getName());
94  $this->assertEquals($profile->getDuration(), $profile2->getDuration());
95 
96  $this->assertEquals($profile1->getTemplate(), $profile3->getTemplate());
97  $this->assertEquals($profile1->getType(), $profile3->getType());
98  $this->assertEquals($profile1->getName(), $profile3->getName());
99  }

The documentation for this class was generated from the following file: