@@ -285,4 +285,39 @@ public function test_start_session_lockout_neg() {
285
285
\mod_observation \session_manager::start_session ($ obid , $ oberid , $ this ->observee ->id );
286
286
\mod_observation \session_manager::start_session ($ obid , $ oberid , $ this ->observee2 ->id );
287
287
}
288
+
289
+ /**
290
+ * Tests CRUD operations for observation point with expected data.
291
+ */
292
+ public function test_crud_expected () {
293
+ global $ DB ;
294
+
295
+ // Create session and submit point response.
296
+ $ sessionid = $ this ->create_session ();
297
+ $ response = (object )self ::VALID_RESPONSE ;
298
+ \mod_observation \observation_manager::submit_point_response ($ sessionid , $ this ->pointid1 , $ response );
299
+
300
+ $ responses = $ DB ->get_records ('observation_point_responses ' , ['obs_pt_id ' => $ this ->pointid1 ]);
301
+ $ this ->assertCount (1 , $ responses );
302
+
303
+ // Delete session and test response is also deleted.
304
+ \mod_observation \session_manager::delete_observation_session ($ this ->instance ->id , $ sessionid );
305
+
306
+ $ responses = $ DB ->get_records ('observation_point_responses ' , ['obs_pt_id ' => $ this ->pointid1 ]);
307
+ $ this ->assertCount (0 , $ responses );
308
+
309
+ // Create another session and submit point response.
310
+ $ sessionid = $ this ->create_session ();
311
+ $ response = (object )self ::VALID_RESPONSE ;
312
+ \mod_observation \observation_manager::submit_point_response ($ sessionid , $ this ->pointid1 , $ response );
313
+
314
+ $ responses = $ DB ->get_records ('observation_point_responses ' , ['obs_pt_id ' => $ this ->pointid1 ]);
315
+ $ this ->assertCount (1 , $ responses );
316
+
317
+ // Delete point and test related responses are deleted.
318
+ \mod_observation \observation_manager::delete_observation_point ($ this ->instance ->id , $ this ->pointid1 );
319
+
320
+ $ responses = $ DB ->get_records ('observation_point_responses ' , ['obs_pt_id ' => $ this ->pointid1 ]);
321
+ $ this ->assertCount (0 , $ responses );
322
+ }
288
323
}
0 commit comments