ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPluginStateDBOverIlDBInterfaceTest Class Reference
+ Inheritance diagram for ilPluginStateDBOverIlDBInterfaceTest:
+ Collaboration diagram for ilPluginStateDBOverIlDBInterfaceTest:

Public Member Functions

 testIsPluginActivated ()
 
 testGetCurrentPluginVersion ()
 
 testGetCurrentPluginDBVersion ()
 
 testSetCurrentPluginVersionKnownPlugin ()
 
 testSetCurrentPluginVersionUnknownPlugin ()
 
 testSetActivationNotExistingPlugin ()
 
 testSetActivationTrue ()
 
 testSetActivationFalse ()
 
 testRemove ()
 

Static Public Attributes

static array $plugin_data
 
static array last_update_version
 

Protected Member Functions

 setUp ()
 

Detailed Description

Definition at line 22 of file ilPluginStateDBOverIlDBInterfaceTest.php.

Member Function Documentation

◆ setUp()

ilPluginStateDBOverIlDBInterfaceTest::setUp ( )
protected

Definition at line 39 of file ilPluginStateDBOverIlDBInterfaceTest.php.

39  : void
40  {
41  $this->il_db = $this->createMock(\ilDBInterface::class);
42  $this->data_factory = new Data\Factory();
43  $this->db = new \ilPluginStateDBOverIlDBInterface(
44  $this->data_factory,
45  $this->il_db
46  );
47  }

◆ testGetCurrentPluginDBVersion()

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginDBVersion ( )

Definition at line 85 of file ilPluginStateDBOverIlDBInterfaceTest.php.

85  : void
86  {
87  $handle = $this->createMock(\ilDBStatement::class);
88 
89  $this->il_db->expects($this->once())
90  ->method("query")
91  ->with("SELECT * FROM il_plugin")
92  ->willReturn($handle);
93  $this->il_db->expects($this->once())
94  ->method("fetchAll")
95  ->with($handle)
96  ->willReturn(self::$plugin_data);
97 
98  $this->assertEquals(12, $this->db->getCurrentPluginDBVersion("plg1"));
99  $this->assertEquals(0, $this->db->getCurrentPluginDBVersion("plg2"));
100  $this->assertEquals(null, $this->db->getCurrentPluginVersion("plg3"));
101  }

◆ testGetCurrentPluginVersion()

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginVersion ( )

Definition at line 67 of file ilPluginStateDBOverIlDBInterfaceTest.php.

67  : void
68  {
69  $handle = $this->createMock(\ilDBStatement::class);
70 
71  $this->il_db->expects($this->once())
72  ->method("query")
73  ->with("SELECT * FROM il_plugin")
74  ->willReturn($handle);
75  $this->il_db->expects($this->once())
76  ->method("fetchAll")
77  ->with($handle)
78  ->willReturn(self::$plugin_data);
79 
80  $this->assertEquals($this->data_factory->version("1.0.1"), $this->db->getCurrentPluginVersion("plg1"));
81  $this->assertEquals($this->data_factory->version("2.3.4"), $this->db->getCurrentPluginVersion("plg2"));
82  $this->assertEquals(null, $this->db->getCurrentPluginVersion("plg3"));
83  }

◆ testIsPluginActivated()

ilPluginStateDBOverIlDBInterfaceTest::testIsPluginActivated ( )

Definition at line 49 of file ilPluginStateDBOverIlDBInterfaceTest.php.

49  : void
50  {
51  $handle = $this->createMock(\ilDBStatement::class);
52 
53  $this->il_db->expects($this->once())
54  ->method("query")
55  ->with("SELECT * FROM il_plugin")
56  ->willReturn($handle);
57  $this->il_db->expects($this->once())
58  ->method("fetchAll")
59  ->with($handle)
60  ->willReturn(self::$plugin_data);
61 
62  $this->assertTrue($this->db->isPluginActivated("plg1"));
63  $this->assertFalse($this->db->isPluginActivated("plg2"));
64  $this->assertFalse($this->db->isPluginActivated("plg3"));
65  }

◆ testRemove()

ilPluginStateDBOverIlDBInterfaceTest::testRemove ( )

Definition at line 235 of file ilPluginStateDBOverIlDBInterfaceTest.php.

235  : void
236  {
237  $PLUGIN_ID = "plg1";
238 
239  $this->il_db->expects($this->once())
240  ->method("quote")
241  ->with($PLUGIN_ID, "text")
242  ->willReturn("PLUGIN_ID");
243  $this->il_db->expects($this->once())
244  ->method("manipulate")
245  ->with("DELETE FROM il_plugin WHERE plugin_id = PLUGIN_ID");
246 
247  $this->db->remove($PLUGIN_ID);
248  }

◆ testSetActivationFalse()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationFalse ( )

Definition at line 204 of file ilPluginStateDBOverIlDBInterfaceTest.php.

204  : void
205  {
206  $handle = $this->createMock(\ilDBStatement::class);
207 
208  $this->il_db->expects($this->once())
209  ->method("query")
210  ->with("SELECT * FROM il_plugin")
211  ->willReturn($handle);
212  $this->il_db->expects($this->once())
213  ->method("fetchAll")
214  ->with($handle)
215  ->willReturn(self::$plugin_data);
216 
217  $PLUGIN_ID = "plg1";
218 
219  $this->il_db->expects($this->once())
220  ->method("update")
221  ->with(
222  "il_plugin",
223  [
224  "active" => ["integer", 0],
225  ],
226  [
227  "plugin_id" => ["text", $PLUGIN_ID],
228  ]
229  );
230 
231  $this->db->setActivation($PLUGIN_ID, false);
232  }

◆ testSetActivationNotExistingPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationNotExistingPlugin ( )

Definition at line 168 of file ilPluginStateDBOverIlDBInterfaceTest.php.

168  : void
169  {
170  $this->expectException(\InvalidArgumentException::class);
171  $this->db->setActivation("SOME_ID", true);
172  }

◆ testSetActivationTrue()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationTrue ( )

Definition at line 174 of file ilPluginStateDBOverIlDBInterfaceTest.php.

174  : void
175  {
176  $handle = $this->createMock(\ilDBStatement::class);
177 
178  $this->il_db->expects($this->once())
179  ->method("query")
180  ->with("SELECT * FROM il_plugin")
181  ->willReturn($handle);
182  $this->il_db->expects($this->once())
183  ->method("fetchAll")
184  ->with($handle)
185  ->willReturn(self::$plugin_data);
186 
187  $PLUGIN_ID = "plg1";
188 
189  $this->il_db->expects($this->once())
190  ->method("update")
191  ->with(
192  "il_plugin",
193  [
194  "active" => ["integer", 1],
195  ],
196  [
197  "plugin_id" => ["text", $PLUGIN_ID],
198  ]
199  );
200 
201  $this->db->setActivation($PLUGIN_ID, true);
202  }

◆ testSetCurrentPluginVersionKnownPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetCurrentPluginVersionKnownPlugin ( )

Definition at line 103 of file ilPluginStateDBOverIlDBInterfaceTest.php.

103  : void
104  {
105  $handle = $this->createMock(\ilDBStatement::class);
106 
107  $this->il_db->expects($this->once())
108  ->method("query")
109  ->with("SELECT * FROM il_plugin")
110  ->willReturn($handle);
111  $this->il_db->expects($this->once())
112  ->method("fetchAll")
113  ->with($handle)
114  ->willReturn(self::$plugin_data);
115 
116  $PLUGIN_ID = "plg2";
117  $VERSION = $this->data_factory->version("1.0.0");
118  $DB_VERSION = 23;
119 
120  $this->il_db->expects($this->once())
121  ->method("update")
122  ->with(
123  "il_plugin",
124  [
125  "last_update_version" => ["text", (string) $VERSION],
126  "db_version" => ["integer", $DB_VERSION]
127  ],
128  [
129  "plugin_id" => ["text", $PLUGIN_ID]
130  ]
131  );
132 
133  $this->db->setCurrentPluginVersion($PLUGIN_ID, $VERSION, $DB_VERSION);
134  }

◆ testSetCurrentPluginVersionUnknownPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetCurrentPluginVersionUnknownPlugin ( )

Definition at line 136 of file ilPluginStateDBOverIlDBInterfaceTest.php.

136  : void
137  {
138  $handle = $this->createMock(\ilDBStatement::class);
139 
140  $this->il_db->expects($this->once())
141  ->method("query")
142  ->with("SELECT * FROM il_plugin")
143  ->willReturn($handle);
144  $this->il_db->expects($this->once())
145  ->method("fetchAll")
146  ->with($handle)
147  ->willReturn(self::$plugin_data);
148 
149  $PLUGIN_ID = "plg3";
150  $VERSION = $this->data_factory->version("1.0.0");
151  $DB_VERSION = 23;
152 
153  $this->il_db->expects($this->once())
154  ->method("insert")
155  ->with(
156  "il_plugin",
157  [
158  "plugin_id" => ["text", $PLUGIN_ID],
159  "active" => ["integer", 0],
160  "last_update_version" => ["text", (string) $VERSION],
161  "db_version" => ["integer", $DB_VERSION]
162  ]
163  );
164 
165  $this->db->setCurrentPluginVersion($PLUGIN_ID, $VERSION, $DB_VERSION);
166  }

Field Documentation

◆ $plugin_data

array ilPluginStateDBOverIlDBInterfaceTest::$plugin_data
static
Initial value:
= [
[
"plugin_id" => "plg1",
"active" => true

Definition at line 24 of file ilPluginStateDBOverIlDBInterfaceTest.php.

◆ last_update_version

array ilPluginStateDBOverIlDBInterfaceTest::last_update_version
static
Initial value:
=> "1.0.1",
"db_version" => 12
],
[
"plugin_id" => "plg2",
"active" => false,
"last_update_version" => "2.3.4",
"db_version" => 0
]
]

Definition at line 28 of file ilPluginStateDBOverIlDBInterfaceTest.php.


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