ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IliasMocks.php
Go to the documentation of this file.
1 <?php
2 
6 
7 trait IliasMocks
8 {
14  protected function mockUIFactory()
15  {
16  $ui_reflection = new ReflectionClass(UIFactory::class);
17  $methods = array_map(
18  function ($m) {
19  return $m->getName();
20  },
21  $ui_reflection->getMethods()
22  );
23 
24  $ui_factory = $this->getMockBuilder(UIFactory::class)
25  ->setMethods($methods)
26  ->getMock();
27 
28  $signal_generator = new SignalGenerator();
29  $ui_factory->method('button')
30  ->willReturn(new CImpl\Button\Factory());
31  $ui_factory->method('viewControl')
32  ->willReturn(new CImpl\ViewControl\Factory($signal_generator));
33 
34  $ui_factory->method('breadcrumbs')
35  ->will($this->returnCallback([static::class, 'uiFactoryBreadcrumbs']));
36 
37  $ui_factory->method('link')
38  ->willReturn(new CImpl\Link\Factory());
39 
40  return $ui_factory;
41  }
42 
43 
44  public function uiFactoryBreadcrumbs()
45  {
46  $args = func_get_args();
47  return new CImpl\Breadcrumbs\Breadcrumbs($args[0]);
48  }
49 
50 
51  protected function mockIlLanguage()
52  {
53  $lng = $this->getMockBuilder(ilLanguage::class)
54  ->disableOriginalConstructor()
55  ->setMethods(['txt'])
56  ->getMock();
57  $lng->method('txt')
58  ->willReturn('');
59 
60  return $lng;
61  }
62 }
$lng