@@ -40,7 +40,7 @@ public function test_tag_sources_identifier(tag_source $source) {
40
40
$ this ->assertGreaterThan (0 , $ count );
41
41
}
42
42
43
- public static function is_tagging_enabled_provider (): array {
43
+ public static function is_tagging_enabled_and_supported_provider (): array {
44
44
return [
45
45
'neither config nor fs supports ' => [
46
46
'enabledinconfig ' => false ,
@@ -61,9 +61,9 @@ public static function is_tagging_enabled_provider(): array {
61
61
}
62
62
63
63
/**
64
- * @dataProvider is_tagging_enabled_provider
64
+ * @dataProvider is_tagging_enabled_and_supported_provider
65
65
*/
66
- public function test_is_tagging_enabled (bool $ enabledinconfig , bool $ supportedbyfs , bool $ expected ) {
66
+ public function test_is_tagging_enabled_and_supported (bool $ enabledinconfig , bool $ supportedbyfs , bool $ expected ) {
67
67
global $ CFG ;
68
68
// Set config.
69
69
set_config ('taggingenabled ' , $ enabledinconfig , 'tool_objectfs ' );
@@ -76,7 +76,7 @@ public function test_is_tagging_enabled(bool $enabledinconfig, bool $supportedby
76
76
manager::set_objectfs_config ($ config );
77
77
$ CFG ->phpunit_objectfs_supports_object_tagging = $ supportedbyfs ;
78
78
79
- $ this ->assertEquals ($ expected , tag_manager::is_tagging_enabled ());
79
+ $ this ->assertEquals ($ expected , tag_manager::is_tagging_enabled_and_supported ());
80
80
}
81
81
82
82
public function test_query_local_tags () {
@@ -210,4 +210,24 @@ public function test_get_objects_needing_sync_limit() {
210
210
$ this ->assertCount (2 , tag_manager::get_objects_needing_sync (2 ));
211
211
$ this ->assertCount (1 , tag_manager::get_objects_needing_sync (1 ));
212
212
}
213
+
214
+ public function test_replicate_local_to_external_tags_for_object () {
215
+ global $ DB ;
216
+
217
+ // Enable tagging, setup test fs.
218
+ $ config = manager::get_objectfs_config ();
219
+ $ config ->taggingenabled = true ;
220
+ $ config ->enabletasks = true ;
221
+ $ config ->filesystem = '\\tool_objectfs \\tests \\test_file_system ' ;
222
+ manager::set_objectfs_config ($ config );
223
+
224
+ // Setup object, mark as needing sync.
225
+ $ object = $ this ->create_remote_object ();
226
+ $ DB ->set_field ('tool_objectfs_objects ' , 'tagsyncstatus ' , tag_manager::SYNC_STATUS_NEEDS_SYNC , ['id ' => $ object ->id ]);
227
+ tag_manager::replicate_local_to_external_tags_for_object ($ object ->contenthash );
228
+
229
+ // Ensure status is now set as not needing sync.
230
+ $ status = $ DB ->get_field ('tool_objectfs_objects ' , 'tagsyncstatus ' , ['id ' => $ object ->id ]);
231
+ $ this ->assertEquals (tag_manager::SYNC_STATUS_SYNC_NOT_REQUIRED , $ status );
232
+ }
213
233
}
0 commit comments