ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Tests\Setup\CLI\HasAgentTest Class Reference
+ Inheritance diagram for ILIAS\Tests\Setup\CLI\HasAgentTest:
+ Collaboration diagram for ILIAS\Tests\Setup\CLI\HasAgentTest:

Public Member Functions

 setUp ()
 
 testGetRelevantAgentWithoutOption ()
 
 testGetRelevantAgentWithNoPluginOption ()
 
 testGetRelevantAgentWithPluginNameOptions ()
 

Protected Attributes

AgentFinder $agent_finder
 
 $has_agent
 

Detailed Description

Definition at line 29 of file HasAgentTest.php.

Member Function Documentation

◆ setUp()

ILIAS\Tests\Setup\CLI\HasAgentTest::setUp ( )

Definition at line 34 of file HasAgentTest.php.

34 : void
35 {
36 $this->agent_finder = $this->createMock(AgentFinder::class);
37 $this->has_agent = new class ($this->agent_finder) {
38 use HasAgent;
39 public function __construct($af)
40 {
41 $this->agent_finder = $af;
42 }
43
44 public function _getRelevantAgent($i)
45 {
46 return $this->getRelevantAgent($i);
47 }
48 };
49 }
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76
trait HasAgent
Add this to an Command that has an agent.
Definition: HasAgent.php:30
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40

References ILIAS\Tests\Setup\CLI\HasAgentTest\$agent_finder, ILIAS\__construct(), ILIAS\Setup\CLI\getRelevantAgent(), and ILIAS\Setup\CLI\HasAgent.

+ Here is the call graph for this function:

◆ testGetRelevantAgentWithNoPluginOption()

ILIAS\Tests\Setup\CLI\HasAgentTest::testGetRelevantAgentWithNoPluginOption ( )

Definition at line 71 of file HasAgentTest.php.

71 : void
72 {
73 $ii = $this->createMock(InputInterface::class);
74 $ac = $this->createMock(AgentCollection::class);
75
76 $ii
77 ->method("hasOption")
78 ->willReturn(true);
79
80 $ii
81 ->method("getOption")
82 ->will($this->returnValueMap([
83 ["no-legacy-plugins", true],
84 ["skip-legacy-plugin", null]
85 ]));
86
87 $this->agent_finder
88 ->expects($this->once())
89 ->method("getComponentAgents")
90 ->with()
91 ->willReturn($ac);
92
93 $agent = $this->has_agent->_getRelevantAgent($ii);
94
95 $this->assertEquals($ac, $agent);
96 }

◆ testGetRelevantAgentWithoutOption()

ILIAS\Tests\Setup\CLI\HasAgentTest::testGetRelevantAgentWithoutOption ( )

Definition at line 51 of file HasAgentTest.php.

51 : void
52 {
53 $ii = $this->createMock(InputInterface::class);
54 $ac = $this->createMock(AgentCollection::class);
55
56 $ii
57 ->method("getOption")
58 ->willReturn(null);
59
60 $this->agent_finder
61 ->expects($this->once())
62 ->method("getAgents")
63 ->with()
64 ->willReturn($ac);
65
66 $agent = $this->has_agent->_getRelevantAgent($ii);
67
68 $this->assertEquals($ac, $agent);
69 }

◆ testGetRelevantAgentWithPluginNameOptions()

ILIAS\Tests\Setup\CLI\HasAgentTest::testGetRelevantAgentWithPluginNameOptions ( )

Definition at line 98 of file HasAgentTest.php.

98 : void
99 {
100 $ii = $this->createMock(InputInterface::class);
101 $ac = $this->createMock(AgentCollection::class);
102
103
104 $ii
105 ->method("hasOption")
106 ->willReturn(true);
107
108 $ii
109 ->method("getOption")
110 ->will($this->returnValueMap([
111 ["no-legacy-plugins", null],
112 ["legacy-plugin", "foobar"],
113 ["skip-legacy-plugin", null]
114 ]));
115
116 $this->agent_finder
117 ->expects($this->once())
118 ->method("getPluginAgent")
119 ->with("foobar")
120 ->willReturn($ac);
121
122 $agent = $this->has_agent->_getRelevantAgent($ii);
123
124 $this->assertEquals($ac, $agent);
125 }

Field Documentation

◆ $agent_finder

AgentFinder ILIAS\Tests\Setup\CLI\HasAgentTest::$agent_finder
protected

Definition at line 31 of file HasAgentTest.php.

Referenced by ILIAS\Tests\Setup\CLI\HasAgentTest\setUp().

◆ $has_agent

ILIAS\Tests\Setup\CLI\HasAgentTest::$has_agent
protected

Definition at line 32 of file HasAgentTest.php.


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