-
{{#str}} preview, tiny_c4l {{/str}}
+
+
{{#str}} preview, tiny_elements {{/str}}
-
{{#str}} previewdefault, tiny_c4l {{/str}}
+
{{#str}} previewdefault, tiny_elements {{/str}}
{{#buttons}}
-
{{{htmlcode}}}
+
{{{htmlcode}}}
{{/buttons}}
{{/preview}}
diff --git a/tests/behat/basic.feature b/tests/behat/basic.feature
deleted file mode 100644
index 9b149d0..0000000
--- a/tests/behat/basic.feature
+++ /dev/null
@@ -1,23 +0,0 @@
-@editor @tiny @editor_tiny @tiny_c4l
-Feature: Tiny editor components for learning
- Write text with the c4l editor plugin
- Background:
- Given the following "courses" exist:
- | shortname | fullname |
- | C1 | Course 1 |
- And the following "users" exist:
- | username | firstname | lastname | email |
- | teacher1 | Teacher | 1 | teacher1@example.com |
- And the following "course enrolments" exist:
- | user | course | role |
- | teacher1 | C1 | editingteacher |
- And the following "activities" exist:
- | activity | name | intro | introformat | course | contentformat | idnumber |
- | page | PageName1 | PageDesc1 | 1 | C1 | 1 | 1 |
- @javascript @external
- Scenario: TinyMCE can be used to embed an C4L Content
- And I am on the PageName1 "page activity editing" page logged in as admin
- And I click on the "C4L" button for the "Page content" TinyMCE editor
- And I click on "Tip" "button"
- And I press "Save and display"
- And I should see "Lorem ipsum"
diff --git a/tests/local/utils_test.php b/tests/local/utils_test.php
new file mode 100644
index 0000000..902d450
--- /dev/null
+++ b/tests/local/utils_test.php
@@ -0,0 +1,158 @@
+.
+
+namespace tiny_elements\local;
+
+use core\hook\output\before_http_headers;
+use stdClass;
+
+/**
+ * Test class for the utils functions.
+ *
+ * @package tiny_elements
+ * @copyright 2024 ISB Bayern
+ * @author Philipp Memmel
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+final class utils_test extends \advanced_testcase {
+ /**
+ * Tests the caching and cache invalidation functionality for the delivering of the tiny_elements css.
+ *
+ * @covers \tiny_elements\local\utils::get_complete_css_as_string
+ * @covers \tiny_elements\local\utils::purge_css_cache
+ * @covers \tiny_elements\local\utils::rebuild_css_cache
+ */
+ public function test_get_complete_css_as_string(): void {
+ global $DB;
+ $this->resetAfterTest();
+
+ $compcatrecord1 = new stdClass();
+ $compcatrecord1->name = 'testcategory1';
+ $compcatrecord1->displayname = 'Category 1';
+ $compcatrecord1->css = '.testcategory1{margin:3rem}';
+ $compcatrecord1id = $DB->insert_record('tiny_elements_compcat', $compcatrecord1);
+ $compcatrecord2 = new stdClass();
+ $compcatrecord2->name = 'testcategory2';
+ $compcatrecord2->displayname = 'Category 2';
+ $compcatrecord2->css = '.testcategory2{padding:3rem}';
+ $compcatrecord2id = $DB->insert_record('tiny_elements_compcat', $compcatrecord2);
+
+ $componentrecord1 = new stdClass();
+ $componentrecord1->name = 'testcomponent1';
+ $componentrecord1->displayname = 'Component 1';
+
+ $componentrecord1->compcat = $compcatrecord1id;
+ $componentrecord1->css = 'div.testcomponent1{background-color:red}';
+ $DB->insert_record('tiny_elements_component', $componentrecord1);
+
+ $componentrecord2 = new stdClass();
+ $componentrecord2->name = 'testcomponent2';
+ $componentrecord2->displayname = 'Component 2';
+
+ $componentrecord2->compcat = $compcatrecord2id;
+ $componentrecord2->css = 'p.testcomponent2{background-color:green}';
+ $DB->insert_record('tiny_elements_component', $componentrecord2);
+
+ $flavorrecord1 = new stdClass();
+ $flavorrecord1->name = 'testflavor1';
+ $flavorrecord1->displayname = 'Flavor 1';
+ $flavorrecord1->css = '#testflavor{color:blue}';
+ $DB->insert_record('tiny_elements_flavor', $flavorrecord1);
+
+ $flavorrecord2 = new stdClass();
+ $flavorrecord2->name = 'testflavor2';
+ $flavorrecord2->displayname = 'Flavor 2';
+ $flavorrecord2->css = '#testflavor2{color:grey}';
+ $DB->insert_record('tiny_elements_flavor', $flavorrecord2);
+
+ $flavorrecord3 = new stdClass();
+ $flavorrecord3->name = 'testflavor3';
+ $flavorrecord3->displayname = 'Flavor 3';
+ $flavorrecord3->css = '#testflavor3{color:red}';
+ $flavorrecord3->hideforstudents = 1;
+ $flavorrecord3id = $DB->insert_record('tiny_elements_flavor', $flavorrecord3);
+
+ $starttime = time();
+ $this->mock_clock_with_frozen($starttime);
+
+ // We need to initially build the cache.
+ // This is usually being triggered by the before_http_headers hook.
+ $mpage = new \moodle_page();
+ $rbase = new \renderer_base($mpage, "/");
+ $beforehttpheadershook = new before_http_headers($rbase);
+ hook_callbacks::add_elements_data_to_dom($beforehttpheadershook);
+
+ $css = utils::get_css_from_cache();
+ $this->assertStringContainsString($compcatrecord1->css, $css);
+ $this->assertStringContainsString($compcatrecord2->css, $css);
+ $this->assertStringContainsString($componentrecord1->css, $css);
+ $this->assertStringContainsString($componentrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord1->css, $css);
+ $this->assertStringContainsString($flavorrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord3->css, $css);
+
+ $dbreadsbefore = $DB->perf_get_queries();
+ hook_callbacks::add_elements_data_to_dom($beforehttpheadershook);
+ $this->assertEquals($dbreadsbefore, $DB->perf_get_queries());
+ $this->mock_clock_with_frozen($starttime + 10);
+ $css = utils::get_css_from_cache();
+ $this->assertStringContainsString($compcatrecord1->css, $css);
+ $this->assertStringContainsString($compcatrecord2->css, $css);
+ $this->assertStringContainsString($componentrecord1->css, $css);
+ $this->assertStringContainsString($componentrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord1->css, $css);
+ $this->assertStringContainsString($flavorrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord3->css, $css);
+
+ $this->mock_clock_with_frozen($starttime + 20);
+ $compcatrecord1 = $DB->get_record('tiny_elements_compcat', ['id' => $compcatrecord1id]);
+ $compcatrecord1->css = 'p{color:pink}';
+ $DB->update_record('tiny_elements_compcat', $compcatrecord1);
+ $flavorrecord3 = $DB->get_record('tiny_elements_flavor', ['id' => $flavorrecord3id]);
+ $flavorrecord3->hideforstudents = 0;
+ $DB->update_record('tiny_elements_flavor', $flavorrecord3);
+ // This needs to be called from the admin interface whenever there is a change in the configuration.
+ utils::purge_css_cache();
+ // Now the callback should trigger a cache rebuild.
+ $dbreadsbefore = $DB->perf_get_queries();
+ hook_callbacks::add_elements_data_to_dom($beforehttpheadershook);
+ $this->assertGreaterThan($dbreadsbefore, $DB->perf_get_queries());
+ $css = utils::get_css_from_cache();
+ $this->assertStringContainsString($compcatrecord1->css, $css);
+ $this->assertStringContainsString($compcatrecord2->css, $css);
+ $this->assertStringContainsString($componentrecord1->css, $css);
+ $this->assertStringContainsString($componentrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord1->css, $css);
+ $this->assertStringContainsString($flavorrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord3->css, $css);
+
+ // Check if it also works if we purge all the caches of moodle.
+ purge_all_caches();
+ // If we purge the moodle caches the hook callback should trigger a cache rebuild.
+ $dbreadsbefore = $DB->perf_get_queries();
+ hook_callbacks::add_elements_data_to_dom($beforehttpheadershook);
+ $this->assertGreaterThan($dbreadsbefore, $DB->perf_get_queries());
+ $this->mock_clock_with_frozen($starttime + 30);
+ $css = utils::get_css_from_cache();
+ $this->assertStringContainsString($compcatrecord1->css, $css);
+ $this->assertStringContainsString($compcatrecord2->css, $css);
+ $this->assertStringContainsString($componentrecord1->css, $css);
+ $this->assertStringContainsString($componentrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord1->css, $css);
+ $this->assertStringContainsString($flavorrecord2->css, $css);
+ $this->assertStringContainsString($flavorrecord3->css, $css);
+ }
+}
diff --git a/tests/manager_test.php b/tests/manager_test.php
new file mode 100644
index 0000000..ba6bd3d
--- /dev/null
+++ b/tests/manager_test.php
@@ -0,0 +1,466 @@
+.
+
+namespace tiny_elements;
+
+use advanced_testcase;
+use tiny_elements\local\constants;
+use tiny_elements\manager;
+
+/**
+ * Class manager_test
+ *
+ * @package tiny_elements
+ * @copyright 2025 ISB Bayern
+ * @author Stefan Hanauska
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @covers \tiny_elements\manager
+ */
+final class manager_test extends advanced_testcase {
+ /**
+ * Create a test set.
+ *
+ * @param manager $manager
+ * @return array
+ */
+ public function create_items(manager $manager): array {
+ $draftitemid = file_get_unused_draft_itemid();
+ file_prepare_draft_area($draftitemid, $manager->get_contextid(), 'tiny_elements', 'images', 0, constants::FILE_OPTIONS);
+
+ $categoryid = $manager->add_compcat((object)[
+ 'name' => 'test',
+ 'displayname' => 'test',
+ 'css' => '',
+ 'compcatfiles' => $draftitemid,
+ ]);
+ $category2id = $manager->add_compcat((object)[
+ 'name' => 'test2',
+ 'displayname' => 'test2',
+ 'css' => '',
+ 'compcatfiles' => $draftitemid,
+ ]);
+
+ $flavorid = $manager->add_flavor((object)[
+ 'name' => 'testflavor',
+ 'displayname' => 'testflavor',
+ 'css' => '',
+ 'iconurl' => '',
+ ]);
+ $flavor2id = $manager->add_flavor((object)[
+ 'name' => 'testflavor2',
+ 'displayname' => 'testflavor2',
+ 'css' => '',
+ 'iconurl' => '',
+ ]);
+
+ $variantid = $manager->add_variant((object)[
+ 'name' => 'testvariant',
+ 'displayname' => 'testvariant',
+ 'css' => '',
+ 'iconurl' => '',
+ ]);
+ $variant2id = $manager->add_variant((object)[
+ 'name' => 'testvariant2',
+ 'displayname' => 'testvariant2',
+ 'css' => '',
+ 'iconurl' => '',
+ ]);
+
+ $componentid = $manager->add_component((object)[
+ 'name' => 'testcomponent',
+ 'displayname' => 'testcomponent',
+ 'css' => '',
+ 'js' => '',
+ 'iconurl' => '',
+ 'flavors' => ['testflavor'],
+ 'variants' => ['testvariant', 'testvariant2'],
+ 'categoryname' => 'test',
+ ]);
+ $component2id = $manager->add_component((object)[
+ 'name' => 'testcomponent2',
+ 'displayname' => 'testcomponent2',
+ 'css' => '',
+ 'js' => '',
+ 'iconurl' => '',
+ 'flavors' => ['testflavor', 'testflavor2'],
+ 'variants' => ['testvariant'],
+ 'categoryname' => 'test2',
+ ]);
+
+ return [
+ 'categoryid' => $categoryid,
+ 'category2id' => $category2id,
+ 'flavorid' => $flavorid,
+ 'flavor2id' => $flavor2id,
+ 'componentid' => $componentid,
+ 'component2id' => $component2id,
+ 'variantid' => $variantid,
+ 'variant2id' => $variant2id,
+ ];
+ }
+
+ /**
+ * Test delete_compcat method.
+ */
+ public function test_delete_compcat(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ // Delete the category.
+ $manager->delete_compcat($data['categoryid']);
+
+ $this->assertFalse($DB->record_exists('tiny_elements_compcat', ['id' => $data['categoryid']]));
+ $this->assertFalse($DB->record_exists('tiny_elements_component', ['id' => $data['componentid']]));
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'testcomponent', 'flavorname' => 'testflavor'])
+ );
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent', 'variant' => 'testvariant'])
+ );
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent', 'variant' => 'testvariant2'])
+ );
+
+ $this->assertTrue($DB->record_exists('tiny_elements_compcat', ['id' => $data['category2id']]));
+ $this->assertTrue($DB->record_exists('tiny_elements_component', ['id' => $data['component2id']]));
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'testcomponent2', 'flavorname' => 'testflavor'])
+ );
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'testcomponent2', 'flavorname' => 'testflavor2'])
+ );
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent2', 'variant' => 'testvariant'])
+ );
+ }
+
+
+ /**
+ * Test delete_flavor method.
+ */
+ public function test_delete_flavor(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ // Delete one flavor.
+ $manager->delete_flavor($data['flavorid']);
+
+ // Verify the flavor is deleted.
+ $this->assertFalse($DB->record_exists('tiny_elements_flavor', ['id' => $data['flavorid']]));
+ $this->assertFalse($DB->record_exists('tiny_elements_comp_flavor', ['flavorname' => 'testflavor']));
+
+ // Verify the other flavor is not deleted.
+ $this->assertTrue($DB->record_exists('tiny_elements_flavor', ['id' => $data['flavor2id']]));
+ $this->assertTrue($DB->record_exists('tiny_elements_comp_flavor', ['flavorname' => 'testflavor2']));
+ }
+
+ /**
+ * Test delete_variant method.
+ */
+ public function test_delete_variant(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ // Delete one variant.
+ $manager->delete_variant($data['variantid']);
+
+ // Verify the variant is deleted.
+ $this->assertFalse($DB->record_exists('tiny_elements_variant', ['id' => $data['variantid']]));
+ $this->assertFalse($DB->record_exists('tiny_elements_comp_variant', ['variant' => 'testvariant']));
+
+ // Verify the other variant is not deleted.
+ $this->assertTrue($DB->record_exists('tiny_elements_variant', ['id' => $data['variant2id']]));
+ $this->assertTrue($DB->record_exists('tiny_elements_comp_variant', ['variant' => 'testvariant2']));
+ }
+
+ /**
+ * Test delete_component method.
+ */
+ public function test_delete_component(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ // Delete the component.
+ $manager->delete_component($data['componentid']);
+
+ // Verify the component is deleted.
+ $this->assertFalse($DB->record_exists('tiny_elements_component', ['id' => $data['componentid']]));
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'testcomponent', 'flavorname' => 'testflavor'])
+ );
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent', 'variant' => 'testvariant'])
+ );
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent', 'variant' => 'testvariant2'])
+ );
+
+ // Verify the other component is not deleted.
+ $this->assertTrue($DB->record_exists('tiny_elements_component', ['id' => $data['component2id']]));
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'testcomponent2', 'flavorname' => 'testflavor'])
+ );
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'testcomponent2', 'flavorname' => 'testflavor2'])
+ );
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent2', 'variant' => 'testvariant'])
+ );
+ }
+
+ /**
+ * Test add_compcat method.
+ *
+ * @return void
+ */
+ public function test_add_compcat(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $draftitemid = file_get_unused_draft_itemid();
+ file_prepare_draft_area($draftitemid, $manager->get_contextid(), 'tiny_elements', 'images', 0, constants::FILE_OPTIONS);
+
+ $categoryid = $manager->add_compcat((object)[
+ 'name' => 'test',
+ 'displayname' => 'test',
+ 'css' => '',
+ 'compcatfiles' => $draftitemid,
+ ]);
+
+ $this->assertTrue($DB->record_exists('tiny_elements_compcat', ['id' => $categoryid]));
+ }
+
+ /**
+ * Test add_flavor method.
+ *
+ * @return void
+ */
+ public function test_add_flavor(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $flavorid = $manager->add_flavor((object)[
+ 'name' => 'testflavor',
+ 'displayname' => 'testflavor',
+ 'css' => '',
+ 'iconurl' => '',
+ ]);
+
+ $this->assertTrue($DB->record_exists('tiny_elements_flavor', ['id' => $flavorid]));
+ }
+
+ /**
+ * Test add_variant method.
+ *
+ * @return void
+ */
+ public function test_add_variant(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $variantid = $manager->add_variant((object)[
+ 'name' => 'testvariant',
+ 'displayname' => 'testvariant',
+ 'css' => '',
+ 'iconurl' => '',
+ ]);
+
+ $this->assertTrue($DB->record_exists('tiny_elements_variant', ['id' => $variantid]));
+ }
+
+ /**
+ * Test add_component method.
+ *
+ * @return void
+ */
+ public function test_add_component(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ $this->assertTrue($DB->record_exists('tiny_elements_component', ['id' => $data['componentid']]));
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'testcomponent', 'flavorname' => 'testflavor'])
+ );
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent', 'variant' => 'testvariant'])
+ );
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'testcomponent', 'variant' => 'testvariant2'])
+ );
+ }
+
+ /**
+ * Test update_compcat method.
+ */
+ public function test_update_compcat(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ $draftitemid = file_get_unused_draft_itemid();
+ file_prepare_draft_area($draftitemid, $manager->get_contextid(), 'tiny_elements', 'images', 0, constants::FILE_OPTIONS);
+
+ $manager->update_compcat((object)[
+ 'id' => $data['categoryid'],
+ 'name' => 'changedname',
+ 'displayname' => 'changeddisplayname',
+ 'css' => '',
+ 'compcatfiles' => $draftitemid,
+ ]);
+
+ $category = $DB->get_record('tiny_elements_compcat', ['id' => $data['categoryid']]);
+ $this->assertEquals('changedname', $category->name);
+ $this->assertEquals('changeddisplayname', $category->displayname);
+ $category2 = $DB->get_record('tiny_elements_compcat', ['id' => $data['category2id']]);
+ $this->assertEquals('test2', $category2->name);
+ $this->assertEquals('test2', $category2->displayname);
+ }
+
+ /**
+ * Test update_flavor method.
+ */
+ public function test_update_flavor(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ $manager->update_flavor((object)[
+ 'id' => $data['flavorid'],
+ 'name' => 'changedname',
+ 'displayname' => 'changeddisplayname',
+ 'css' => '',
+ ]);
+
+ $flavor = $DB->get_record('tiny_elements_flavor', ['id' => $data['flavorid']]);
+ $this->assertEquals('changedname', $flavor->name);
+ $this->assertEquals('changeddisplayname', $flavor->displayname);
+ $flavor2 = $DB->get_record('tiny_elements_flavor', ['id' => $data['flavor2id']]);
+ $this->assertEquals('testflavor2', $flavor2->name);
+ $this->assertEquals('testflavor2', $flavor2->displayname);
+ }
+
+ /**
+ * Test update_variant method.
+ */
+ public function test_update_variant(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ $manager->update_variant((object)[
+ 'id' => $data['variantid'],
+ 'name' => 'changedname',
+ 'displayname' => 'changeddisplayname',
+ 'css' => '',
+ 'iconurl' => '',
+ ]);
+
+ $variant = $DB->get_record('tiny_elements_variant', ['id' => $data['variantid']]);
+ $this->assertEquals('changedname', $variant->name);
+ $this->assertEquals('changeddisplayname', $variant->displayname);
+ $variant2 = $DB->get_record('tiny_elements_variant', ['id' => $data['variant2id']]);
+ $this->assertEquals('testvariant2', $variant2->name);
+ $this->assertEquals('testvariant2', $variant2->displayname);
+ }
+
+ /**
+ * Test update_component method.
+ */
+ public function test_update_component(): void {
+ global $DB;
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+ $contextid = 1;
+ $manager = new manager($contextid);
+
+ $data = $this->create_items($manager);
+
+ $manager->update_component((object)[
+ 'id' => $data['componentid'],
+ 'name' => 'changedname',
+ 'displayname' => 'changeddisplayname',
+ 'css' => '',
+ 'js' => '',
+ 'iconurl' => '',
+ 'flavors' => ['testflavor2'],
+ 'variants' => ['testvariant'],
+ 'categoryname' => 'testcategory2',
+ ]);
+
+ $component = $DB->get_record('tiny_elements_component', ['id' => $data['componentid']]);
+ $this->assertEquals('changedname', $component->name);
+ $this->assertEquals('changeddisplayname', $component->displayname);
+ $this->assertEquals('testcategory2', $component->categoryname);
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'changedname', 'flavorname' => 'testflavor2'])
+ );
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_flavor', ['componentname' => 'changedname', 'flavorname' => 'testflavor'])
+ );
+ $this->assertTrue(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'changedname', 'variant' => 'testvariant'])
+ );
+ $this->assertFalse(
+ $DB->record_exists('tiny_elements_comp_variant', ['componentname' => 'changedname', 'variant' => 'testvariant2'])
+ );
+ }
+}
diff --git a/version.php b/version.php
index 9158192..6c8ca22 100644
--- a/version.php
+++ b/version.php
@@ -15,17 +15,18 @@
// along with Moodle. If not, see .
/**
- * Tiny C4L plugin version details.
+ * Tiny Elements plugin version details.
*
- * @package tiny_c4l
- * @copyright 2022 Marc Català
+ * @package tiny_elements
+ * @copyright 2025 ISB Bayern
+ * @author Stefan Hanauska
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
-$plugin->component = 'tiny_c4l';
-$plugin->release = '3.0.1';
-$plugin->requires = 2022112800;
-$plugin->maturity = MATURITY_STABLE;
-$plugin->version = 2024042901;
+$plugin->component = 'tiny_elements';
+$plugin->release = '1.0.0';
+$plugin->requires = 2024042200;
+$plugin->maturity = MATURITY_BETA;
+$plugin->version = 2025052001;