11<?php namespace Tests ;
2+ use LaravelDoctrine \ORM \Facades \Registry ;
3+ use models \summit \Presentation ;
4+ use models \utils \SilverstripeBaseModel ;
5+
26/**
37 * Copyright 2018 OpenStack Foundation
48 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -341,6 +345,16 @@ public function testDisassociateTrack2TrackGroup(){
341345
342346 $ this ->assertResponseStatus (201 );
343347
348+ // verify presentations of defaultTrack have a selection plan before disassociation
349+ $ presentations = self ::$ defaultTrack ->getPresentationsBySelectionPlanIds (
350+ self ::$ defaultTrackGroup ->getSelectionPlanIds ()
351+ );
352+ $ this ->assertNotEmpty ($ presentations );
353+ foreach ($ presentations as $ presentation ) {
354+ $ this ->assertTrue ($ presentation ->getSelectionPlanId () > 0 );
355+ }
356+ $ presentation_ids = array_map (fn ($ p ) => $ p ->getId (), $ presentations );
357+
344358 // now disassociate
345359 $ response = $ this ->action (
346360 "DELETE " ,
@@ -353,6 +367,14 @@ public function testDisassociateTrack2TrackGroup(){
353367 );
354368
355369 $ this ->assertResponseStatus (204 );
370+
371+ // reset EM (closed after the API transaction) and re-fetch presentations to verify selection plan was cleared
372+ self ::$ em = Registry::resetManager (SilverstripeBaseModel::EntityManager);
373+ foreach ($ presentation_ids as $ id ) {
374+ $ presentation = self ::$ em ->find (Presentation::class, $ id );
375+ $ this ->assertNotNull ($ presentation );
376+ $ this ->assertEquals (0 , $ presentation ->getSelectionPlanId ());
377+ }
356378 }
357379
358380 public function testAddPrivateTrackGroup (){
@@ -480,4 +502,4 @@ public function testDeleteExistentTrackGroup(){
480502 $ content = $ response ->getContent ();
481503 $ this ->assertResponseStatus (204 );
482504 }
483- }
505+ }
0 commit comments