ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
AbstractTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends \PHPUnit\Framework\TestCase
13 {
14  protected function getProfile()
15  {
16  $profile = $this->getMockBuilder('Twig_Profiler_Profile')->disableOriginalConstructor()->getMock();
17 
18  $profile->expects($this->any())->method('isRoot')->will($this->returnValue(true));
19  $profile->expects($this->any())->method('getName')->will($this->returnValue('main'));
20  $profile->expects($this->any())->method('getDuration')->will($this->returnValue(1));
21  $profile->expects($this->any())->method('getMemoryUsage')->will($this->returnValue(0));
22  $profile->expects($this->any())->method('getPeakMemoryUsage')->will($this->returnValue(0));
23 
24  $subProfiles = array(
25  $this->getIndexProfile(
26  array(
27  $this->getEmbeddedBlockProfile(),
29  array(
31  )
32  ),
33  $this->getMacroProfile(),
35  array(
37  )
38  ),
39  )
40  ),
41  );
42 
43  $profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles));
44  $profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles)));
45 
46  return $profile;
47  }
48 
49  private function getIndexProfile(array $subProfiles = array())
50  {
51  return $this->generateProfile('main', 1, true, 'template', 'index.twig', $subProfiles);
52  }
53 
54  private function getEmbeddedBlockProfile(array $subProfiles = array())
55  {
56  return $this->generateProfile('body', 0.0001, false, 'block', 'embedded.twig', $subProfiles);
57  }
58 
59  private function getEmbeddedTemplateProfile(array $subProfiles = array())
60  {
61  return $this->generateProfile('main', 0.0001, true, 'template', 'embedded.twig', $subProfiles);
62  }
63 
64  private function getIncludedTemplateProfile(array $subProfiles = array())
65  {
66  return $this->generateProfile('main', 0.0001, true, 'template', 'included.twig', $subProfiles);
67  }
68 
69  private function getMacroProfile(array $subProfiles = array())
70  {
71  return $this->generateProfile('foo', 0.0001, false, 'macro', 'index.twig', $subProfiles);
72  }
73 
84  private function generateProfile($name, $duration, $isTemplate, $type, $templateName, array $subProfiles = array())
85  {
86  $profile = $this->getMockBuilder('Twig_Profiler_Profile')->disableOriginalConstructor()->getMock();
87 
88  $profile->expects($this->any())->method('isRoot')->will($this->returnValue(false));
89  $profile->expects($this->any())->method('getName')->will($this->returnValue($name));
90  $profile->expects($this->any())->method('getDuration')->will($this->returnValue($duration));
91  $profile->expects($this->any())->method('getMemoryUsage')->will($this->returnValue(0));
92  $profile->expects($this->any())->method('getPeakMemoryUsage')->will($this->returnValue(0));
93  $profile->expects($this->any())->method('isTemplate')->will($this->returnValue($isTemplate));
94  $profile->expects($this->any())->method('getType')->will($this->returnValue($type));
95  $profile->expects($this->any())->method('getTemplate')->will($this->returnValue($templateName));
96  $profile->expects($this->any())->method('getProfiles')->will($this->returnValue($subProfiles));
97  $profile->expects($this->any())->method('getIterator')->will($this->returnValue(new ArrayIterator($subProfiles)));
98 
99  return $profile;
100  }
101 }
$type
generateProfile($name, $duration, $isTemplate, $type, $templateName, array $subProfiles=array())
getEmbeddedBlockProfile(array $subProfiles=array())
if($format !==null) $name
Definition: metadata.php:146
getIndexProfile(array $subProfiles=array())
Create styles array
The data for the language used.
getEmbeddedTemplateProfile(array $subProfiles=array())
getIncludedTemplateProfile(array $subProfiles=array())
getMacroProfile(array $subProfiles=array())