@@ -56,11 +56,10 @@ protected function setUp()
5656 /**
5757 * Create a single task process assigned to $this->user
5858 */
59- private function createTestProcess ()
59+ private function createTestProcess (array $ data = [] )
6060 {
61- $ process = factory (Process::class)->create ([
62- 'bpmn ' => Process::getProcessTemplate ('SingleTask.bpmn ' )
63- ]);
61+ $ data ['bpmn ' ] = Process::getProcessTemplate ('SingleTask.bpmn ' );
62+ $ process = factory (Process::class)->create ($ data );
6463 //Assign the task to $this->user
6564 $ taskUuid = 'UserTaskUID ' ;
6665 factory (ProcessTaskAssignment::class)->create ([
@@ -107,10 +106,10 @@ public function testExecuteAProcess()
107106 */
108107 public function testGetListOfStartEvents ()
109108 {
110- $ route = route ('processes.show ' , [$ this ->process ->uuid_text , 'include ' => 'events ' ]);
109+ $ route = route ('processes.show ' , [$ this ->process ->uuid_text , 'include ' => 'events ' ]);
111110 $ response = $ this ->json ('GET ' , $ route );
112111 //Check the inclusion of events
113- $ response ->assertJsonStructure (['events ' => [['id ' ,'name ' ]]]);
112+ $ response ->assertJsonStructure (['events ' => [['id ' , 'name ' ]]]);
114113 }
115114
116115 /**
@@ -194,4 +193,38 @@ public function testUpdateTaskInvalidStatus()
194193 $ response = $ this ->json ('PUT ' , $ route , $ data );
195194 $ response ->assertStatus (422 );
196195 }
196+
197+ /**
198+ * Get the list of processes to start with categories and start events.
199+ */
200+ public function testGetListProcessesToStart ()
201+ {
202+ //Create two additional processes
203+ $ this ->createTestProcess ();
204+ $ uncProcess = $ this ->createTestProcess (['process_category_uuid ' => null ]);
205+ //Get the start event id
206+ $ uncProcessEvents = $ uncProcess ->events ;
207+ //Get the list of processes (with and without category) and its start events
208+ $ route = route ('processes.index ' , ['include ' => 'events,category ' , 'order_by ' => 'name ' ]);
209+ $ response = $ this ->json ('GET ' , $ route );
210+ //Check the inclusion of events
211+ $ response ->assertJsonStructure (['data ' => ['* ' => ['events ' => [['id ' , 'name ' ]], 'category ' ]]]);
212+ $ data = $ response ->json ('data ' );
213+ $ list = ['Uncategorized ' => []];
214+ foreach ($ data as $ process ) {
215+ $ categoryName = $ process ['category ' ] ? $ process ['category ' ]['name ' ] : 'Uncategorized ' ;
216+ $ list [$ categoryName ][] = $ process ;
217+ }
218+ $ this ->assertArraySubset (
219+ [
220+ 'Uncategorized ' => [
221+ [
222+ 'name ' => $ uncProcess ->name ,
223+ 'events ' => [
224+ ['id ' => $ uncProcessEvents [0 ]['id ' ]]
225+ ]
226+ ]
227+ ]
228+ ], $ list );
229+ }
197230}
0 commit comments