1212 * limitations under the License.
1313 **/
1414
15+ use App \Models \Foundation \Main \IGroup ;
16+ use models \summit \SummitBadgeFeatureType ;
1517
1618/**
1719 * Class OAuth2SummitBadgesApiTest
1820 */
1921class OAuth2SummitBadgesApiTest extends ProtectedApiTestCase
2022{
23+ use InsertSummitTestData;
2124
22- public function testGetAllBySummit ($ summit_id =27 ){
25+ protected function setUp (): void
26+ {
27+ $ this ->current_group = IGroup::TrackChairs;
28+ parent ::setUp ();
29+ self ::$ defaultMember = self ::$ member ;
30+ self ::insertSummitTestData ();
31+
32+ // add a badge feature type and assign it to the badge so the inner join on features returns results
33+ $ feature = new SummitBadgeFeatureType ();
34+ $ feature ->setName ('TEST_FEATURE ' );
35+ $ feature ->setDescription ('Test badge feature ' );
36+ self ::$ summit ->addFeatureType ($ feature );
37+
38+ // find the attendee's badge and add the feature
39+ $ attendees = self ::$ summit ->getAttendees ();
40+ foreach ($ attendees as $ attendee ) {
41+ foreach ($ attendee ->getTickets () as $ ticket ) {
42+ $ badge = $ ticket ->getBadge ();
43+ if (!is_null ($ badge )) {
44+ $ badge ->addFeature ($ feature );
45+ }
46+ }
47+ }
48+
49+ self ::$ em ->flush ();
50+ }
51+
52+ protected function tearDown (): void
53+ {
54+ self ::clearSummitTestData ();
55+ parent ::tearDown ();
56+ }
57+
58+ public function testGetAllBySummit (){
2359 $ params = [
24- 'id ' => $ summit_id ,
60+ 'id ' => self :: $ summit -> getId () ,
2561 'expand ' => 'ticket,ticket.order,type,type.access_levels,features '
2662 ];
2763
28- $ headers = [
29- "HTTP_Authorization " => " Bearer " . $ this ->access_token ,
30- "CONTENT_TYPE " => "application/json "
31- ];
32-
3364 $ response = $ this ->action (
3465 "GET " ,
3566 "OAuth2SummitBadgesApiController@getAllBySummit " ,
3667 $ params ,
3768 [],
3869 [],
3970 [],
40- $ headers
71+ $ this -> getAuthHeaders ()
4172 );
4273
4374 $ content = $ response ->getContent ();
4475 $ this ->assertResponseStatus (200 );
4576 $ data = json_decode ($ content );
46- $ this ->assertTrue (!is_null ($ data ));
77+ $ this ->assertNotNull ($ data );
78+ $ this ->assertGreaterThan (0 , $ data ->total );
4779 return $ data ;
4880 }
4981
50- public function testGetAllBySummitCSV ($ summit_id = 27 ){
82+ public function testGetAllBySummitCSV (){
5183 $ params = [
52- 'id ' => $ summit_id ,
53- 'expand ' => 'ticket,ticket.order,type,type.access_levels,features '
84+ 'id ' => self ::$ summit ->getId (),
85+ ];
86+
87+ $ response = $ this ->action (
88+ "GET " ,
89+ "OAuth2SummitBadgesApiController@getAllBySummitCSV " ,
90+ $ params ,
91+ [],
92+ [],
93+ [],
94+ $ this ->getAuthHeaders ()
95+ );
96+
97+ $ this ->assertResponseStatus (200 );
98+ $ content = $ response ->getContent ();
99+ $ this ->assertNotEmpty ($ content );
100+ }
101+
102+ public function testGetAllBySummitWithFilter (){
103+ $ params = [
104+ 'id ' => self ::$ summit ->getId (),
105+ 'filter ' => 'owner_first_name=@ ' . substr (self ::$ member ->getFirstName (), 0 , 3 ),
106+ 'expand ' => 'ticket,type ' ,
54107 ];
55108
56- $ headers = [
57- "HTTP_Authorization " => " Bearer " . $ this ->access_token ,
58- "CONTENT_TYPE " => "application/json "
109+ $ response = $ this ->action (
110+ "GET " ,
111+ "OAuth2SummitBadgesApiController@getAllBySummit " ,
112+ $ params ,
113+ [],
114+ [],
115+ [],
116+ $ this ->getAuthHeaders ()
117+ );
118+
119+ $ content = $ response ->getContent ();
120+ $ this ->assertResponseStatus (200 );
121+ $ data = json_decode ($ content );
122+ $ this ->assertNotNull ($ data );
123+ }
124+
125+ public function testGetAllBySummitWithOrder (){
126+ $ params = [
127+ 'id ' => self ::$ summit ->getId (),
128+ 'order ' => '-created ' ,
59129 ];
60130
61131 $ response = $ this ->action (
62132 "GET " ,
63- "OAuth2SummitBadgesApiController@getAllBySummitCSV " ,
133+ "OAuth2SummitBadgesApiController@getAllBySummit " ,
64134 $ params ,
65135 [],
66136 [],
67137 [],
68- $ headers
138+ $ this -> getAuthHeaders ()
69139 );
70140
71141 $ content = $ response ->getContent ();
72142 $ this ->assertResponseStatus (200 );
73143 $ data = json_decode ($ content );
74- $ this ->assertTrue (! is_null ( $ data) );
75- return $ data ;
144+ $ this ->assertNotNull ( $ data );
145+ $ this -> assertGreaterThan ( 0 , $ data-> total ) ;
76146 }
77- }
147+ }
0 commit comments