ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 ()
 

Protected Attributes

ilDBInterface $il_db
 
Data Factory $data_factory
 
ilPluginStateDBOverIlDBInterface $db
 

Detailed Description

Definition at line 23 of file ilPluginStateDBOverIlDBInterfaceTest.php.

Member Function Documentation

◆ setUp()

ilPluginStateDBOverIlDBInterfaceTest::setUp ( )
protected

Definition at line 44 of file ilPluginStateDBOverIlDBInterfaceTest.php.

44  : void
45  {
46  $this->il_db = $this->createMock(\ilDBInterface::class);
47  $this->data_factory = new Data\Factory();
48  $this->db = new \ilPluginStateDBOverIlDBInterface(
49  $this->data_factory,
50  $this->il_db
51  );
52  }

◆ testGetCurrentPluginDBVersion()

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginDBVersion ( )

Definition at line 90 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testGetCurrentPluginVersion()

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginVersion ( )

Definition at line 72 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testIsPluginActivated()

ilPluginStateDBOverIlDBInterfaceTest::testIsPluginActivated ( )

Definition at line 54 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testRemove()

ilPluginStateDBOverIlDBInterfaceTest::testRemove ( )

Definition at line 240 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetActivationFalse()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationFalse ( )

Definition at line 209 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetActivationNotExistingPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationNotExistingPlugin ( )

Definition at line 173 of file ilPluginStateDBOverIlDBInterfaceTest.php.

173  : void
174  {
175  $this->expectException(\InvalidArgumentException::class);
176  $this->db->setActivation("SOME_ID", true);
177  }

◆ testSetActivationTrue()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationTrue ( )

Definition at line 179 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetCurrentPluginVersionKnownPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetCurrentPluginVersionKnownPlugin ( )

Definition at line 108 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetCurrentPluginVersionUnknownPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetCurrentPluginVersionUnknownPlugin ( )

Definition at line 141 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

Field Documentation

◆ $data_factory

Data Factory ilPluginStateDBOverIlDBInterfaceTest::$data_factory
protected

Definition at line 41 of file ilPluginStateDBOverIlDBInterfaceTest.php.

◆ $db

ilPluginStateDBOverIlDBInterface ilPluginStateDBOverIlDBInterfaceTest::$db
protected

Definition at line 42 of file ilPluginStateDBOverIlDBInterfaceTest.php.

◆ $il_db

ilDBInterface ilPluginStateDBOverIlDBInterfaceTest::$il_db
protected

Definition at line 40 of file ilPluginStateDBOverIlDBInterfaceTest.php.

◆ $plugin_data

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

Definition at line 25 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 29 of file ilPluginStateDBOverIlDBInterfaceTest.php.


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