ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilPluginStateDBOverIlDBInterfaceTest Class Reference
+ Inheritance diagram for ilPluginStateDBOverIlDBInterfaceTest:
+ Collaboration diagram for ilPluginStateDBOverIlDBInterfaceTest:

Public Member Functions

 testIsPluginActivated ()
 
 testGetCurrentPluginVersion ()
 
 testGetCurrentPluginDBVersion ()
 
 testSetCurrentPluginVersionKnownPlugin ()
 
 testSetActivation ()
 
 testRemove ()
 
 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 ()
 
 setUp ()
 

Protected Attributes

ilDBInterface $il_db
 
Data Factory $data_factory
 
ilPluginStateDBOverIlDBInterface $db
 

Detailed Description

Definition at line 22 of file ilNullPluginStateDBTest.php.

Member Function Documentation

◆ setUp() [1/2]

ilPluginStateDBOverIlDBInterfaceTest::setUp ( )
protected

Definition at line 24 of file ilNullPluginStateDBTest.php.

24  : void
25  {
26  $this->db = new \ilNullPluginStateDB();
27  }

◆ setUp() [2/2]

ilPluginStateDBOverIlDBInterfaceTest::setUp ( )
protected

Definition at line 43 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testGetCurrentPluginDBVersion() [1/2]

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginDBVersion ( )

Definition at line 43 of file ilNullPluginStateDBTest.php.

43  : void
44  {
45  $this->assertEquals(null, $this->db->getCurrentPluginDBVersion("plg1"));
46  $this->assertEquals(null, $this->db->getCurrentPluginDBVersion("plg2"));
47  $this->assertEquals(null, $this->db->getCurrentPluginVersion("plg3"));
48  }

◆ testGetCurrentPluginDBVersion() [2/2]

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginDBVersion ( )

Definition at line 89 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testGetCurrentPluginVersion() [1/2]

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginVersion ( )

Definition at line 36 of file ilNullPluginStateDBTest.php.

36  : void
37  {
38  $this->assertEquals(null, $this->db->getCurrentPluginVersion("plg1"));
39  $this->assertEquals(null, $this->db->getCurrentPluginVersion("plg2"));
40  $this->assertEquals(null, $this->db->getCurrentPluginVersion("plg3"));
41  }

◆ testGetCurrentPluginVersion() [2/2]

ilPluginStateDBOverIlDBInterfaceTest::testGetCurrentPluginVersion ( )

Definition at line 71 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testIsPluginActivated() [1/2]

ilPluginStateDBOverIlDBInterfaceTest::testIsPluginActivated ( )

Definition at line 29 of file ilNullPluginStateDBTest.php.

29  : void
30  {
31  $this->assertFalse($this->db->isPluginActivated("plg1"));
32  $this->assertFalse($this->db->isPluginActivated("plg2"));
33  $this->assertFalse($this->db->isPluginActivated("plg3"));
34  }

◆ testIsPluginActivated() [2/2]

ilPluginStateDBOverIlDBInterfaceTest::testIsPluginActivated ( )

Definition at line 53 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testRemove() [1/2]

ilPluginStateDBOverIlDBInterfaceTest::testRemove ( )

Definition at line 68 of file ilNullPluginStateDBTest.php.

68  : void
69  {
70  $PLUGIN_ID = "plg1";
71  $this->db->remove($PLUGIN_ID);
72 
73  $this->assertTrue(true); // Should simply work...
74  }

◆ testRemove() [2/2]

ilPluginStateDBOverIlDBInterfaceTest::testRemove ( )

Definition at line 239 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetActivation()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivation ( )

Definition at line 61 of file ilNullPluginStateDBTest.php.

61  : void
62  {
63  $this->expectException(\InvalidArgumentException::class);
64  $this->db->setActivation("SOME_ID", true);
65  }

◆ testSetActivationFalse()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationFalse ( )

Definition at line 208 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetActivationNotExistingPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationNotExistingPlugin ( )

Definition at line 172 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetActivationTrue()

ilPluginStateDBOverIlDBInterfaceTest::testSetActivationTrue ( )

Definition at line 178 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetCurrentPluginVersionKnownPlugin() [1/2]

ilPluginStateDBOverIlDBInterfaceTest::testSetCurrentPluginVersionKnownPlugin ( )

Definition at line 50 of file ilNullPluginStateDBTest.php.

50  : void
51  {
52  $PLUGIN_ID = "plg2";
53  $VERSION = $this->data_factory->version("1.0.0");
54  $DB_VERSION = 23;
55 
56  $this->db->setCurrentPluginVersion($PLUGIN_ID, $VERSION, $DB_VERSION);
57 
58  $this->assertTrue(true); // Should simply work...
59  }

◆ testSetCurrentPluginVersionKnownPlugin() [2/2]

ilPluginStateDBOverIlDBInterfaceTest::testSetCurrentPluginVersionKnownPlugin ( )

Definition at line 107 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

◆ testSetCurrentPluginVersionUnknownPlugin()

ilPluginStateDBOverIlDBInterfaceTest::testSetCurrentPluginVersionUnknownPlugin ( )

Definition at line 140 of file ilPluginStateDBOverIlDBInterfaceTest.php.

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

Field Documentation

◆ $data_factory

Data Factory ilPluginStateDBOverIlDBInterfaceTest::$data_factory
protected

Definition at line 40 of file ilPluginStateDBOverIlDBInterfaceTest.php.

◆ $db

ilPluginStateDBOverIlDBInterface ilPluginStateDBOverIlDBInterfaceTest::$db
protected

Definition at line 41 of file ilPluginStateDBOverIlDBInterfaceTest.php.

◆ $il_db

ilDBInterface ilPluginStateDBOverIlDBInterfaceTest::$il_db
protected

Definition at line 39 of file ilPluginStateDBOverIlDBInterfaceTest.php.

◆ $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 files: