27             "plugin_id" => 
"plg1",
    29             "last_update_version" => 
"1.0.1",
    33             "plugin_id" => 
"plg2",
    35             "last_update_version" => 
"2.3.4",
    42     protected \ilPluginStateDBOverIlDBInterface 
$db;
    44     protected function setUp(): void
    46         $this->il_db = $this->createMock(\ilDBInterface::class);
    47         $this->data_factory = 
new Data\Factory();
    48         $this->db = new \ilPluginStateDBOverIlDBInterface(
    56         $handle = $this->createMock(\ilDBStatement::class);
    58         $this->il_db->expects($this->once())
    60             ->with(
"SELECT * FROM il_plugin")
    61             ->willReturn($handle);
    62         $this->il_db->expects($this->once())
    65             ->willReturn(self::$plugin_data);
    67         $this->assertTrue($this->db->isPluginActivated(
"plg1"));
    68         $this->assertFalse($this->db->isPluginActivated(
"plg2"));
    69         $this->assertFalse($this->db->isPluginActivated(
"plg3"));
    74         $handle = $this->createMock(\ilDBStatement::class);
    76         $this->il_db->expects($this->once())
    78             ->with(
"SELECT * FROM il_plugin")
    79             ->willReturn($handle);
    80         $this->il_db->expects($this->once())
    83             ->willReturn(self::$plugin_data);
    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"));
    92         $handle = $this->createMock(\ilDBStatement::class);
    94         $this->il_db->expects($this->once())
    96             ->with(
"SELECT * FROM il_plugin")
    97             ->willReturn($handle);
    98         $this->il_db->expects($this->once())
   101             ->willReturn(self::$plugin_data);
   103         $this->assertEquals(12, $this->db->getCurrentPluginDBVersion(
"plg1"));
   104         $this->assertEquals(0, $this->db->getCurrentPluginDBVersion(
"plg2"));
   105         $this->assertEquals(null, $this->db->getCurrentPluginVersion(
"plg3"));
   110         $handle = $this->createMock(\ilDBStatement::class);
   112         $this->il_db->expects($this->once())
   114             ->with(
"SELECT * FROM il_plugin")
   115             ->willReturn($handle);
   116         $this->il_db->expects($this->once())
   119             ->willReturn(self::$plugin_data);
   122         $VERSION = $this->data_factory->version(
"1.0.0");
   125         $this->il_db->expects($this->once())
   130                     "last_update_version" => [
"text", (
string) $VERSION],
   131                     "db_version" => [
"integer", $DB_VERSION]
   134                     "plugin_id" => [
"text", $PLUGIN_ID]
   138         $this->db->setCurrentPluginVersion($PLUGIN_ID, $VERSION, $DB_VERSION);
   143         $handle = $this->createMock(\ilDBStatement::class);
   145         $this->il_db->expects($this->once())
   147             ->with(
"SELECT * FROM il_plugin")
   148             ->willReturn($handle);
   149         $this->il_db->expects($this->once())
   152             ->willReturn(self::$plugin_data);
   155         $VERSION = $this->data_factory->version(
"1.0.0");
   158         $this->il_db->expects($this->once())
   163                     "plugin_id" => [
"text", $PLUGIN_ID],
   164                     "active" => [
"integer", 0],
   165                     "last_update_version" => [
"text", (
string) $VERSION],
   166                     "db_version" => [
"integer", $DB_VERSION]
   170         $this->db->setCurrentPluginVersion($PLUGIN_ID, $VERSION, $DB_VERSION);
   175         $this->expectException(\InvalidArgumentException::class);
   176         $this->db->setActivation(
"SOME_ID", 
true);
   181         $handle = $this->createMock(\ilDBStatement::class);
   183         $this->il_db->expects($this->once())
   185             ->with(
"SELECT * FROM il_plugin")
   186             ->willReturn($handle);
   187         $this->il_db->expects($this->once())
   190             ->willReturn(self::$plugin_data);
   194         $this->il_db->expects($this->once())
   199                     "active" => [
"integer", 1],
   202                     "plugin_id" => [
"text", $PLUGIN_ID],
   206         $this->db->setActivation($PLUGIN_ID, 
true);
   211         $handle = $this->createMock(\ilDBStatement::class);
   213         $this->il_db->expects($this->once())
   215             ->with(
"SELECT * FROM il_plugin")
   216             ->willReturn($handle);
   217         $this->il_db->expects($this->once())
   220             ->willReturn(self::$plugin_data);
   224         $this->il_db->expects($this->once())
   229                     "active" => [
"integer", 0],
   232                     "plugin_id" => [
"text", $PLUGIN_ID],
   236         $this->db->setActivation($PLUGIN_ID, 
false);
   244         $this->il_db->expects($this->once())
   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");
   252         $this->db->remove($PLUGIN_ID);
 static array $plugin_data
 
testSetCurrentPluginVersionUnknownPlugin()
 
ilPluginStateDBOverIlDBInterface $db
 
testSetCurrentPluginVersionKnownPlugin()
 
testSetActivationNotExistingPlugin()
 
testGetCurrentPluginDBVersion()
 
testGetCurrentPluginVersion()
 
Data Factory $data_factory
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...